serial_port 0.2.2+1 copy "serial_port: ^0.2.2+1" to clipboard
serial_port: ^0.2.2+1 copied to clipboard

outdatedDart 1 only

Dart extension library to communicate on serial port.

#Serial Port

pub package Build Status Coverage Status

SerialPort is a Dart Api to provide access read and write access to serial port. Sorry, Windows is not (yet) supported.

Inspiration come from node-serialport.

Compilation #

Why ? #

Yes, it must be compiled because it's a VM extension, depending of execution platform.

What I need ? #

gcc, make and dart must be in PATH

How compile it ? #

  • Install Dart dependencies
pub get
  • Run bin/serial_port.dart compile, cc files will be compiled, and some dart tests will be launched

Output

[serial_port]> bin/serial_port.dart compile
Building project "/Users/nicolasfrancois/Documents/dart-bots/serial_port/lib/src/serial_port.yaml"
Building complete successfully

How use it ? #

Echo #


import 'package:serial_port/serial_port.dart';
import 'dart:async';

main(){
  var arduino = new SerialPort("/dev/tty.usbmodem1421");
  arduino.onRead.map(BYTES_TO_STRING).listen(print);
  arduino.open().then((_) {
    print("Ctrl-c to close");
    new Timer(new Duration(seconds: 2), () => arduino.writeString("Hello !"));
  });
}

void setup(){
  Serial.begin(9600);
}

void loop(){
  while (Serial.available() > 0) {
    Serial.write(Serial.read());
  }
}

List connected serial ports #


import 'package:serial_port/serial_port.dart';
import 'dart:async';

main(){
  SerialPort.availablePortNames.then((portNames) {
  	print("${portNames.length} devices founded:");
    portNames.forEach((device) => print(">$device"));
  });
}


Nexts developments #

  • Have a better implementation for writing bytes.
  • Wait for TODO(turnidge): Currently handle_concurrently is ignoredfrom Dart VM.
  • Support serial port communication parameter like (parity, stopbits, FLOWCONTROLS, ...).
1
likes
0
pub points
71%
popularity

Publisher

unverified uploader

Dart extension library to communicate on serial port.

Repository (GitHub)
View/report issues

License

unknown (LICENSE)

Dependencies

ccompile

More

Packages that depend on serial_port