Thursday, July 19, 2012

Ruby serialport and the missing byte

While developing a project @iralab about an Arm Cortex board which should control a DC motor, I found a very strange behaviour: sometimes I received from the serial port only 89/90 bytes.. other times 3/4 and so on..

So I googled something like 'ruby serialport missing byte' and I found a lot of useful hints such as

Unluckily none of these worked...

After some debug i found that only some chars were not sent/received.. 0xa0 to 0xbf..

And then I realized what I was doing wrong! I used the getc method to read from serial!
Switching to getbyte completely fixed the problem.

Here some reference:

Hope it helps

No comments:

Post a Comment

Note: Only a member of this blog may post a comment.