Re: Linux Programming Discussions

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Hmm, reading from the ttySx device should never give
duplicatedcharacters so it sounds like something is up with
your buffer. I wouldn't zero it out but just keep note of
the number of bytes read and when to stop. Also, after your
first read returns, don't sleep but rather call poll() on
the device which will return when there is data ready to be
read.

You could always post the function but yeah I don't know of
a serial specific list but you're basically just reading
from a character device at the end of the day.

S

On Tue, Aug 31, 2010 at 02:35:16PM -0500, Martin McCormick wrote:
> 	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
> 
> _______________________________________________
> Blinux-list mailing list
> Blinux-list@xxxxxxxxxx
> https://www.redhat.com/mailman/listinfo/blinux-list

_______________________________________________
Blinux-list mailing list
Blinux-list@xxxxxxxxxx
https://www.redhat.com/mailman/listinfo/blinux-list


[Index of Archives]     [Linux Speakup]     [Fedora]     [Linux Kernel]     [Yosemite News]     [Big List of Linux Books]