No commit activity in last 3 years
No release in over 3 years
Ruby only library that relies on FFI instead of an extension, and inherits from IO
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
 Dependencies

Development

~> 13.0
~> 3.0.0

Runtime

~> 1.9, >= 1.9.3
 Project Readme

ccutrer-serialport

SerialPort is a simple Ruby gem for interacting with serial ports.

It does not require an extension thanks to using FFI.

SerialPort objects inherit from File (and thus IO), so are compatible with all IO methods, in particular read_partial, and asynchronous IO.

It was inspired by the rubyserial gem.

Usage

require 'ccutrer-rubyserial'
serialport = CCutrer::SerialPort.new '/dev/ttyACM0' # Defaults to 9600 baud, 8 data bits, and no parity
serialport = CCutrer::SerialPort.new '/dev/ttyACM0', baud: 57600
serialport = CCutrer::SerialPort.new '/dev/ttyACM0', baud: 19200, data_bits: 8, parity: :even

serialport.read(4096)
serialport.gets

require 'io/wait'
serialport.ready?
serialport.wait_readable(1)

Running the tests

The test suite is written using rspec, just use the rspec command.

Test dependencies

To run the tests, you must also have socat installed.

License

MIT. See LICENSE for more details.