readModemStatus method
Read the current state of the four DCE→DTE modem-status lines.
Production transports query the underlying driver
(sp_get_signals for libserialport, GetCommModemStatus for
Windows). The default throws so existing custom transports
keep compiling; override to expose this capability.
Implementation
@override
Future<ModemStatus> readModemStatus() async {
if (!isOpen) throw StateError('LibserialportSerialTransport not open');
final bitsPtr = malloc<Int32>();
try {
_check(
_bindings.spGetSignals(_port!, bitsPtr),
'sp_get_signals',
);
final bits = bitsPtr.value;
return ModemStatus(
cts: (bits & SpSignalMask.cts) != 0,
dsr: (bits & SpSignalMask.dsr) != 0,
ri: (bits & SpSignalMask.ri) != 0,
cd: (bits & SpSignalMask.dcd) != 0,
);
} finally {
malloc.free(bitsPtr);
}
}