Introducing Rubyserial

by Javier Cervantes

Today we are happy to announce Rubyserial, a new Ruby gem for reading from and writing to serial ports.

Unlike other Ruby serial port implementations, it supports all of the most popular Ruby implementations (MRI, JRuby, & Rubinius) on the most popular operating systems (OSX, Linux, & Windows). And it does not require any native compilation thanks to using RubyFFI.

The interface to RubySerial should be (mostly) compatible with other Ruby serialport gems, so you should be able to drop in the new gem, change the require and use it as a replacement. If not, please let us know so we can address any issues.

The Artoo drivers for Arduino, Sphero and Neurosky have been already migrated to use Rubyserial by default.

If you want to give it a try, install via rubygems:

gem install rubyserial

And start using it:

require 'rubyserial'
serialport = '/dev/ttyACM0', 57600

We currently support the following methods:

  • write(data : String) -> Int : Returns the number of bytes written.
  • read(length : Int) -> String : Returns a string up to length long.
  • getbyte -> Fixnum or nil : Returns an 8 bit byte or nil if no data is available.

All of them emit a RubySerial::Exception on error.

We are very excited to have this initial version out, and we will be pleased to have your feedback and contributions in the Github Repository.

Have fun!

comments powered by Disqus