Re: serial port question.
- From: Henrik Carlqvist <Henrik.Carlqvist@xxxxxxxxxxxx>
- Date: Tue, 30 May 2006 23:14:06 +0200
Chris.Reath@xxxxxxxxx wrote:
And I was successfully able to send and recieve an unsigned character
array of 255 chars. (from 00 to FF) However, I was only able to do so
by sending and receiving one byte at a time. I have been unable to
accurately send and receive more then 6 - 7 bytes at one time,
It sounds as if you haven't detected and dealt with short reads and short
writes. If your program does something like this:
ret = write(serial, "Hello World", 11);
You should look at the return value to see if all data was sent. If ret is
only 7 you have only sent the first 7 bytes and should then do a new call
with something like:
ret = write(serial, "orld", 4);
Of course the best thing for you is to write wrapper functions for read
and write that handles short reads and writes.
It was a long time since I wrote code for serial ports, but if I remember
right it was possible to avoid this behavior by turning off O_NONBLOCK
with an fcntl.
regards Henrik
--
The address in the header is only to prevent spam. My real address is:
hc8(at)uthyres.com Examples of addresses which go to spammers:
root@xxxxxxxxxxxxx root@localhost
.
- Follow-Ups:
- Re: serial port question.
- From: Chris . Reath
- Re: serial port question.
- References:
- serial port question.
- From: Chris . Reath
- serial port question.
- Prev by Date: serial port question.
- Next by Date: Re: The state of Linux FireWire
- Previous by thread: serial port question.
- Next by thread: Re: serial port question.
- Index(es):
Relevant Pages
|