Description

Simple crossplatform work with serailport

Package Information

Version0.1.4 (2017-May-03)
Repository https://github.com/deviator/serialport
LicenseMIT
CopyrightCopyright © 2017
AuthorsOleg Butko (deviator)
Registered byOleg
Dependencies none

Installation

To use this package, put the following dependency into your project's dependencies section:

dub.json
dub.sdl

Readme

SerialPort

Library provides simple work with serial port for Posix and Windows.

Simple usage:

auto com = new SerialPort("/dev/ttyUSB0", 19200);

com.write(someDataArry);

//                        write timeout
com.write(someDataArray, 500.dur!"usecs");

auto res1 = com.read(bufferForReading);

//                                     read timeout     frame end gap
auto res2 = com.read(bufferForReading, 500.dur!"msecs", 20.dur!"msecs");

Returned resN is slice of bufferForReading.

Warning: unix systems allow only standart speeds
[0, 50, 75, 110, 134, 150, 200, 300, 600, 1200, 1800, 2400, 4800, 9600, 19200, 38400, 57600, 115200, 230400]

Reading and writing algorithms use Fiber.yield if available, or Thread.yield otherwise. If you want redefine this behavior, you can set void delegate() yieldFunc field of SerialPort through ctor or directly.

Setting parameters examples:

com.config = SerialPort.Config(9600, Parity.none, DataBits.data8, StopBits.one)
com.set(19200).set(DataBits.data8);
com.stopBits = StopBits.two;

Available versions

0.1.4 0.1.3 0.1.2 0.1.1 0.1.0 ~master