Serial Link - Setting Read Timeouts < 1/10 sec?

bridged with qdn.public.neutrino
Post Reply
Ian Macafee

Serial Link - Setting Read Timeouts < 1/10 sec?

Post by Ian Macafee » Tue Sep 02, 2003 9:16 am

Using VMIN and VTIME parts of c_cc in termios I'm able to set up a blocking
read on a serial link to return when VMIN bytes are received or a gap of
VTIME tenths of a second occurs since receiving the previous byte.

My problem is that I'm receiving variable length serial input at up to 10 Hz
and therefore I cannot always separate the messages using this mechanism.

Is is possible to set the timeout to less than 100ms?

Alternatively I have to read a byte at a time......

Bill Caroselli

Re: Serial Link - Setting Read Timeouts < 1/10 sec?

Post by Bill Caroselli » Tue Sep 02, 2003 1:16 pm

Ian Macafee <imacafee@radamec.co.uk> wrote:
IM > Using VMIN and VTIME parts of c_cc in termios I'm able to set up a blocking
IM > read on a serial link to return when VMIN bytes are received or a gap of
IM > VTIME tenths of a second occurs since receiving the previous byte.

IM > My problem is that I'm receiving variable length serial input at up to 10 Hz
IM > and therefore I cannot always separate the messages using this mechanism.

IM > Is is possible to set the timeout to less than 100ms?

IM > Alternatively I have to read a byte at a time......

You'll probibly have to create some kind of header on your
communications records. Then you're receiving software can scan for
that header and ignore bytes that aren't part og the last record up to
the beginning of the next record.

Keep a count of the bytes skipped and fragments skipped. If those
numbers ever get too high (like 1) then that's a sign that there is
a comm problem.

--
Bill Caroselli -- Q-TPS Consulting
1-(626) 824-7983
qtps@earthlink.net

Post Reply

Return to “qdn.public.neutrino”