Skip to content

If your ruby serial port doesn’t read what’ you’re sending…

2009 November 27

Some days ago I got my Novation launchpad an immediately started hacking with some Ruby and Arduino flavor. I wanted to port ccb23 Raindrops Project to launchpad.

For that, I needed Serial communication within ruby. Thanks to ruby-serialport first steps went quite well. I could write OR read from and to Arduino easily. But for some reasons, writing AND reading using the same instance didn’t work out.

I used a simple ‘send-input-back’ sketch on the Arduino side. So every byte I’m sending is returned back. I checked with the Arduino IDE Serialmonitor and a simple Processing script – everything worked alright. But using ruby it was different. Writing to serial port worked okay, but reading from it was just random. Sometimes I read the response, sometime I didn’t – really, really weird. Some headaches and a lot of time testing I finally found the solution: just open two instances of the serial port. One for sending, one for reading – and, surprise, surprise – it works perfect! Who would have guessed that!? Strange..

// To be completed
require ‘serialport’
port_write =
port_read =

Ok, continuing hacking, more soon…

One Response
  1. Jonathan permalink
    October 24, 2010

    wow.. nice work!
    I had the exact same issue and this solved it. Haven’t lost a bit since.


Comments are closed.