79289947

Date: 2024-12-18 04:05:33
Score: 0.5
Natty:
Report link
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~

Reasons:
  • Long answer (-0.5):
  • Has code block (-0.5):
  • Self-answer (0.5):
  • Low reputation (1):
Posted by: qricis