$ZA with Terminal I/O
$ZA is implemented as a sequence of bit flags, with each bit indicating a specific piece of information. The following table shows the possible values, their meanings, and how to test them using the modulo (#) and integer divide (\) operators:
||A <CTRL-C> arrived, whether or not breaks were enabled.
||The READ timed out.
||InterSystems IRIS detected an invalid escape sequence.
||The hardware detected a parity or framing error.
||The process is disconnected from its principal device.
||For COM ports: CTS (Clear To Send). A signal sent from the modem to its computer indicating that transmission can proceed. For TCP devices: the device is functioning in Server mode.
||For COM ports: DSR (Data Set Ready). A signal sent from the modem to its computer indicating that it is ready to operate. For TCP devices: the device is currently in the Connected state talking to a remote host.
||Ring set if TRUE.
||Carrier detect set if TRUE.
||CE_BREAK COM port error state.
||CE_FRAME COM port error state.
||CE_IOE COM port error state.
||CE_OVERRUN COM port error state.
||CE_RXPARITY COM port error state.
||CE_TXFULL COM port error state.
||TXHOLD COM port error state. Set if any of the following fields are true in the error mask returned by ClearCommError(): fCtsHold, fDsrHold, fRlsdHold, fXoffHold, fXoffSent.
|24 & 25
||InterSystems IRIS requested DTR (Data Terminal Ready) setting: 0=DTR off. 1=DTR=on. 2=DTR handshaking. When set (1), indicates readiness to transmit and receive data.
While many of the conditions that $ZA shows are errors, they do not interrupt the program’s flow by trapping to $ZTRAP. (A <CTRL-C> with breaks enabled traps to $ZTRAP.) A program concerned with these errors must check $ZA after every READ.
COM ports use bits 12 through 15, 24 and 25 to report the status of modem control pins. This can be done regardless of whether InterSystems IRIS modem control checking is on or off for the port. A user can enable or disable $ZA error reporting for COM ports by setting the OPEN or USE command portstate parameter (byte 8, to be specific). If error reporting is enabled, the port error state is reported in bits 16 through 22. For further details, see Terminal I/O.
You can use the DisconnectErr()Opens in a new tab method of the %SYSTEM.ProcessOpens in a new tab class for modem disconnect detection for the current process. The system-wide default behavior can be established by setting the DisconnectErrOpens in a new tab property of the Config.MiscellaneousOpens in a new tab class.