Ruby SerialPorts

Posted by Seth Archer on Stack Overflow See other posts from Stack Overflow or by Seth Archer
Published on 2010-03-28T06:05:54Z Indexed on 2010/03/28 6:13 UTC
Read the original article Hit count: 402

I'm using the ruby serial port gem. After I open up the port I send the data I want like this.

sp.write [200.chr, 30.chr, 7.chr, 5.chr, 1.chr, 2.chr, 0.chr, 245.chr].to_s

It doesn't work, but if I put it in a loop of around 200 times:

200.times do
  sp.write [200.chr, 30.chr, 7.chr, 5.chr, 1.chr, 2.chr, 0.chr, 245.chr].to_s
end

It works. Any ideas on why this is happening?

© Stack Overflow or respective owner

Related posts about ruby

Related posts about serial-port