No commit activity in last 3 years
No release in over 3 years
EventMachine compatible serialport library
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
 Dependencies

Development

~> 1.3.0
~> 10.1.0
~> 2.14.0

Runtime

 Project Readme

em-printer-serialport

Eventmachine compatible asynchronous, ruby-serialport library. A fork of em-serialport that is maintained by PrintToPeer.

Installation

gem install em-printer-serialport

Usage

If you are on Mac, you need to set up a virtual USB serial port by installing a driver from http://www.ftdichip.com/Drivers/VCP.htm. Identify your serial port device. For ex: /dev/tty.usbserial-xxxxxxxx

EM.run do
  serial = EventMachine.open_serial('/dev/tty.usbserial-xxxxxxxx', 9600, 8, 1, 0)
  serial.send_data 'foo'

  serial.on_data do |data|
    # do something with data
  end
end

Serial Monitor

The gem comes with a simple command line Serial Monitor. Launch it as:

bundle exec serial-monitor /dev/tty.usbserial-xxxxxxxx

Here is a working example, tested with arduino echo server. It simply reads and writes data to serial port from command line.

Serial monitor initialized. Enter data followed by a newline character.
Ctrl-C to stop
hello
received: hello
A very long sentence
received: A v
received: ery long
received:  sentence