Linux Programming Discussions

Martin McCormick martin at x.it.okstate.edu
Tue Aug 31 19:35:16 UTC 2010


	I am writing some C code to manage the operation of a
new scanner radio and it is mostly coming along well but I have
run in to some odd behavior from a RS-232 port routine I stole
from a Linux HowTo on serial communications.

	One calls the routine and it stores characters in to a
buffer or transmits data from a buffer. Receiving 50 or 60
characters is a piece of cake. Everything works as expected but
receiving a longer string such as 60 to 70 or more characters,
the first read brings back some of the chars from the previous
read even though the buffer was zero'd out. A second read gets
all the character that should have been there in the first read.

	Needless to say, this is not good but I discovered I can
put a 1-second sleep before the next read and then it always
gives the correct data.

	When I get through, the radio will be totally accessible
thanks to its serial control capabilities and to Linux, in this
case, Vinux.

	Are there any Linux discussion groups that would be
really good for this question?

	The receiver control program really creeps along with
those forced 1-second pauses before every serial read.
Interestingly enough, I wouldn't call it flaky because it does
exactly the same wrong thing every time and it is always on a
longer receive string. The buffer is set for 1024 characters and
none of the reads have even come close to overflowing it so
that's not the problem. Also, if the sleep is even slightly less
than 1 full second, such as .75 seconds, I still get the bogus
read.

	Again, any ideas as to where to take this question are
appreciated.

Martin




More information about the Blinux-list mailing list