write method

  1. @override
Future<int> write(
  1. Uint8List bytes, {
  2. Duration? timeout,
})

Write data to the serial port.

Returns the amount of bytes written.

Implementation

@override
Future<int> write(Uint8List bytes, {Duration? timeout}) async {
  if (_usbPort != null) {
    await _usbPort!
        .write(bytes)
        .timeout(timeout ?? const Duration(seconds: 60));
    return bytes.length; // TODO: how to get the written data amout?
  }
  return 0;
}