我想使用 DartLang 通过串口与 Arduino 通信,而不是通过 TCP/ip。
我找到了 DartLang chrome package和 Chrome Serial reference ,这是解决方案吗?或者还有其他一些解决方案可以将串行端口与 DartLang 一起使用?
最佳答案
编辑 :https://pub.dev/packages/dart_serial_port在最近的评论中提到并使用 Dart FFI。
——
Nicolas François 构建了一个原生的 Dart VM 扩展来执行以下操作:
https://github.com/nfrancois/SerialPort
您需要自己编译它(需要 gcc
、 make
、 pub
):
关于如何使用它的信息并不多,但有 some tests和 dart class这应该有用:
看起来你会像这样使用它:
var serial = new SerialPort(dummySerialPort.path);
serial.onRead.listen((s) => print('Got: $s'));
serial.open()
.then((_) => serial.write("Hello"))
//.then((_) => serial.close());
关于serial-port - 使用 DartLang 通过串口进行通信,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/25367468/