TApxComPort.ModemStatus

TApxComPort

property ModemStatus : Byte

Returns the modem status byte and clears all delta bits.

The status is returned in the byte format used by the UART's modem status register. The returned value can be used with the following bit masks to isolate the desired bits:

Constant
Value
Description
DeltaCTSMask
01h
CTS changed since last read
DeltaDSRMask
02h
DSR changed since last read
DeltaRIMask
04h
RI changed since last read
DeltaDCDMask
08h
DCD changed since last read
CTSMask
10h
Clear to send
DSRMask
20h
Data set ready
RIMask
40h
Ring indicator
DCDMask
80h
Data carrier detect

You'll probably find it easier to use the CTS, DSR, RI, DCD, and related DeltaXxx properties instead of ModemStatus, but ModemStatus is more efficient when you need to check several signals at once.

ModemStatus also clears the internal "delta" bits used to indicate changes in the CTS, DSR, RI, and DCD signals. This affects the results of subsequent checks of DeltaCTS, etc.

The following example uses ModemStatus to check for dropped carrier. It would have been simpler in this case to check the DCD property directly:

Status := ApxComPort.ModemStatus;
if Status and DCDMask = 0 then
...port dropped carrier

See also: CTS, DCD, DeltaCTS, DeltaDCD, DeltaDSR, DeltaRI, DSR, RI