int write(Uint8List data) {
try {
if (!_serialPort.isOpen) {
if (!open()) {
return -1;
}
}
return _serialPort.write(data,timeout: 500);
} catch (e) {
debugPrint("Error writing to port $portName: $e");
logManager.addLog("Error writing to port $portName: $e");
return -1;
}
}
/// Write data to the serial port.
///
/// If `timeout` is 0 or greater, the write operation is blocking.
/// The timeout is specified in milliseconds. Pass 0 to wait infinitely.
///
/// Returns the amount of bytes written.
int write(Uint8List bytes, {int timeout = -1});
so I can change timeout to 0 or >0,and it works well now~