6

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?

dsolimano
  • 8,870
  • 3
  • 48
  • 63
Domenico Monaco
  • 1,236
  • 12
  • 21

1 Answers1

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