non-blocking I/O on serial port problems

Denys Vlasenko vda.linux at googlemail.com
Mon May 25 23:21:06 UTC 2009


On Monday 25 May 2009 16:53, Michael D wrote:
> 
> 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...

This does not sound relevant to busybox.

> Anybody else ever see this or have any idea why?

Because poll and select do not guarantee that data
will be available. They say when it MIGHT be available.

> For a quick example, below is a snippet from efaxos.c
> 
> This code never returns.

1. At which line precisely does it stop?
2. I do not see where you enable non-blocking io.

> Any ideas.

Maybe write more coherent problem description?

> 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 ;
> 
> }
> _______________________________________________
> busybox mailing list
> busybox at busybox.net
> http://lists.busybox.net/mailman/listinfo/busybox
> 
--
vda


More information about the busybox mailing list