For Programmers: Free Programming Magazines  


Home > Archive > Unix Programming > November 2007 > Serialport termios & timeout









You are viewing an archived Text-only version of the thread. To view this thread in it's original format and/or if you want to reply to this thread please [click here]

 

Author Serialport termios & timeout
simnav@gmail.com

2007-11-17, 8:08 am

I'm trying to understand how to use the VTIME field of c_cc meber
structure in termios. I need to write an application that reads one
ore more bytes at time with an interchar timeout; I think that
setting the serial terminal as non canonical and the opportune values
for VTIME and VMIN I can do it, right ? What I don't understand very
well is how to detect the timeout condition: reading manpages I found
that read can return the number of read bytes or -1 in case of error
and in errno the error code. I see that EINTR code signals a signal
interruption: timeout timer elapse will generate a signal so will I
get this error code ? What's happen if any other signal are received
by my process during read execution ? EINTR again ? If so how it's
possible to distinguish the two cases ?

Thanks in advance to everyone can help me.
Best regards,
Simone Navari.
Robert Harris

2007-11-17, 7:09 pm

simnav@gmail.com wrote:
> I'm trying to understand how to use the VTIME field of c_cc meber
> structure in termios. I need to write an application that reads one
> ore more bytes at time with an interchar timeout; I think that
> setting the serial terminal as non canonical and the opportune values
> for VTIME and VMIN I can do it, right ? What I don't understand very
> well is how to detect the timeout condition: reading manpages I found
> that read can return the number of read bytes or -1 in case of error
> and in errno the error code. I see that EINTR code signals a signal
> interruption: timeout timer elapse will generate a signal so will I
> get this error code ? What's happen if any other signal are received
> by my process during read execution ? EINTR again ? If so how it's
> possible to distinguish the two cases ?
>
> Thanks in advance to everyone can help me.
> Best regards,
> Simone Navari.


If VTIME expires before any characters are read, then read() returns 0;
that information is buried somewhere in the "man termios" pages.

Robert
Sponsored Links







Also available: Server administration forum archive | Web Design forum archive | Software forum archive | Hardware reviews archive

Copyright 2008 codecomments.com