Results 1 to 2 of 2
I am trying to write some code that interfaces with an AVR over a serial port. Basically I send a command then read the output which is 6 bytes.
I ...
- 05-05-2010 #1Just Joined!
- Join Date
- Oct 2009
- Posts
- 14
Read x bytes from serial port
I am trying to write some code that interfaces with an AVR over a serial port. Basically I send a command then read the output which is 6 bytes.
I need to receive all 6 bytes before the program continues. Is there a way to do this? If I use read() it returns -1 unless I add a delay before reading the port. Is there a way to get it to read the 6 bytes as soon as they arrive?
In python you simply say how many bytes you want and the max time you are willing to wait which seems a whole lot easier than read().
Thanks for the help!
Justin
- 05-06-2010 #2
Serial ports require some special handling for reading, due to the relatively slow, asynchronous, and unreliable nature of the input data. I reccommend review of the techniques explained in
Serial Programming Guide for POSIX Operating Systems
Serial Programming HOWTO
Serial HOWTO
--- rod.Stuff happens. Then stays happened.


Reply With Quote