non-blocking I/O on serial port problems
Michael D
bsd_mike at yahoo.com
Mon May 25 14:53:48 UTC 2009
I have a board which has a fax/modem connected to the RS-232 serial port. I have tried mgetty+fax and efax-0.9. Both applications want some kind
of non-blocking IO on the serial port.
If I enable non-blocking io, the serial port does not always return with
any data...
Anybody else ever see this or have any idea why?
For a quick example, below is a snippet from efaxos.c
This code never returns.
Any ideas.
Thanks,
-Mike
int tdata ( TFILE *f, int t)
{
fd_set fds ;
struct timeval timeout ;
if ( f->fd < 0 ) msg ( "Ecan't happen (faxdata)" ) ;
timeout.tv_sec = t / 10 ;
timeout.tv_usec = ( t % 10 ) * 100000 ;
FD_ZERO ( &fds ) ;
FD_SET ( f->fd, &fds ) ;
do {
n = select ( f->fd + 1, &fds, 0, 0, t<0 ? 0 : &timeout ) ;
if ( n < 0 ) {
if ( errno == EINTR ) {
msg ( "W0 select() interrupted in tdata()" ) ;
} else {
err = msg ( "ES2 select() failed in tdata():" ) ;
}
}
} while ( n < 0 && ! err ) ;
return n ;
}
More information about the busybox
mailing list