I want to use DartLang to communicate with Arduino by Serial Port, not over TCP/ip. I've found DartLang chrome package and Chrome Serial reference, this is the solution ? Or there are some other solution to use Serial Port with DartLang?
Asked
Active
Viewed 3,855 times
6
-
1As far as I know the chrome package only makes the Chrome serial API (JavaScript) available to Dart. I guess you need to build a Dart native extension. – Günter Zöchbauer Aug 18 '14 at 16:13
-
1I found this library on github -- didn't test it -- maybe it can help: [SerialPort](https://github.com/nfrancois/SerialPort) – Claudio d'Angelis Aug 18 '14 at 16:35
-
thanks to both, second solution is exactly what has described @ Günter Zöchbauer... – Domenico Monaco Aug 19 '14 at 10:39
1 Answers
8
Edit: https://pub.dev/packages/dart_serial_port was mentioned in the comments which is much more recent and uses Dart FFI.
--
Nicolas François has built a native Dart VM extension that does this:
https://github.com/nfrancois/SerialPort
You'll need to compile it yourself (requires gcc
, make
, pub
):
There's not a huge amount of info on how to use it, but there are some tests and the dart class that should be useful:
Looks like you'd use it something like this:
var serial = new SerialPort(dummySerialPort.path);
serial.onRead.listen((s) => print('Got: $s'));
serial.open()
.then((_) => serial.write("Hello"))
//.then((_) => serial.close());

Christopher Moore
- 15,626
- 10
- 42
- 52

Danny Tuppeny
- 40,147
- 24
- 151
- 275
-
Since this answer is from 6 years ago I thought I'd update with another option that is available now: https://pub.dev/packages/dart_serial_port which uses Dart's new FFI. – Maks Oct 19 '20 at 09:27
-
Nowdays there's the https://pub.dev/packages/libserialport. Also for flutter girls and boys a wrapper around it: https://pub.dev/packages/flutter_libserialport – Dimitrios Desyllas Aug 22 '22 at 12:11