serial_port 0.3.1

#Serial Port

pub package Build Status Build status Coverage Status

SerialPort is a Dart Api to provide access read and write access to serial port. <br/> Binaries are provided for:

  • Win 64 bits
  • Linux 64 bits
  • MacOS 64 bits

Inspiration come from node-serialport.

How use it ? #

Echo #

Simple program :

  • Arduino repeat all character send to it.
  • Dart send "Hello !" and print what Arduino send.

Dart part:


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

main() async {
  var arduino = new SerialPort("/dev/tty.usbmodem1421");
  arduino.onRead.map(BYTES_TO_STRING).listen(print);
  await arduino.open();
  // Wait a little bit before sending data
  new Timer(new Duration(seconds: 2), () => arduino.writeString("Hello !"));
}

Arduino part:

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';

main() async {
  final portNames = await SerialPort.availablePortNames;
  print("${portNames.length} devices found:");
  portNames.forEach((device) => print(">$device"));
}


Executable #

Install serial_port with as pub global executable.

pub global activate serial_port

And use it to list available serial ports.

serial_port list

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 (FLOWCONTROLS, ...).

0.3.1: #

  • Update SDK to 1.12.1 and dev dependencies
  • Update tools librairies

0.3.0 #

  • Update dev dependencies
  • Use test package instead of unittest
  • Windows support
  • Basic support for parity and stopbits
  • Provided compiled lib for Linux 64, MacOSX 64 and Windows 64
  • Grinder as dev task tool

0.2.3 #

  • Fix for SDK 1.9.1
  • Use async/await

0.2.2 #

  • Rewrite tests with expectAsync and remove mock files from 0.2.1
  • Fix naming typo

0.2.1 #

  • Use Mockable File for testing
  • Increase test coverage
  • Internals changes
  • Increase require Dart SDK to 1.8

0.2.0 #

  • MacOSX : retrieve all serial devices (bluetooth include)
  • Remove type on Future returned
  • Add a command line tools in bin directory

0.1.0 #

  • Fix on types

0.0.4 #

  • Move build script to bin

0.0.3 #

  • List devices

0.0.2 #

  • Internal changes for writing bytes
  • Add getter to check if open

0.0.1 #

  • Open/close connection
  • Write/Read bytes
  • Write String

Use this package as an executable

1. Install it

You can install the package from the command line:


$ pub global activate serial_port

2. Use it

The package has the following executables:


$ serial_port

Use this package as a library

1. Depend on it

Add this to your package's pubspec.yaml file:


dependencies:
  serial_port: ^0.3.1

2. Install it

You can install packages from the command line:

with pub:


$ pub get

Alternatively, your editor might support pub get. Check the docs for your editor to learn more.

3. Import it

Now in your Dart code, you can use:


import 'package:serial_port/serial_port.dart';
  
Popularity:
Describes how popular the package is relative to other packages. [more]
52
Health:
Code health derived from static analysis. [more]
--
Maintenance:
Reflects how tidy and up-to-date the package is. [more]
--
Overall:
Weighted score of the above. [more]
26
Learn more about scoring.

The package version is not analyzed, because it does not support Dart 2. Until this is resolved, the package will receive a health and maintenance score of 0.

Analysis issues and suggestions

Support Dart 2 in pubspec.yaml.

The SDK constraint in pubspec.yaml doesn't allow the Dart 2.0.0 release. For information about upgrading it to be Dart 2 compatible, please see https://dart.dev/dart-2#migration.

Maintenance issues and suggestions

Make sure dartdoc successfully runs on your package's source files. (-10 points)

Dependencies were not resolved.