mirror of
https://github.com/elua/elua.git
synced 2025-01-25 01:02:54 +08:00
Cover zero timeout better with serial library.
This commit is contained in:
parent
d890fd3c50
commit
9604c94f06
@ -174,10 +174,17 @@ void ser_set_timeout_ms( ser_handler id, u32 timeout )
|
|||||||
if( timeout == SER_INF_TIMEOUT )
|
if( timeout == SER_INF_TIMEOUT )
|
||||||
{
|
{
|
||||||
termdata.c_cc[ VTIME ] = 0;
|
termdata.c_cc[ VTIME ] = 0;
|
||||||
|
fcntl( id, F_SETFL, 0 ); // calls block
|
||||||
|
}
|
||||||
|
else if( timeout == SER_NO_TIMEOUT)
|
||||||
|
{
|
||||||
|
termdata.c_cc[ VTIME ] = 0;
|
||||||
|
fcntl( id, F_SETFL, FNDELAY ); // no blocking, timeout
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
termdata.c_cc[ VTIME ] = timeout / 100;
|
termdata.c_cc[ VTIME ] = timeout / 100;
|
||||||
|
fcntl( id, F_SETFL, 0 ); // calls block
|
||||||
}
|
}
|
||||||
tcsetattr( id, TCSANOW, &termdata );
|
tcsetattr( id, TCSANOW, &termdata );
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user