Commit 375f0ee7 authored by Pavel Vainerman's avatar Pavel Vainerman

(ComPort485F): added error handling for read.

parent e8a25d0f
...@@ -125,6 +125,9 @@ unsigned char ComPort485F::m_receiveByte( bool wait ) ...@@ -125,6 +125,9 @@ unsigned char ComPort485F::m_receiveByte( bool wait )
{ {
rc = ::read(fd, tbuf, sizeof(tbuf)); rc = ::read(fd, tbuf, sizeof(tbuf));
if( rc < 0 && errno != EAGAIN )
break;
if( rc > 0 ) if( rc > 0 )
{ {
if( remove_echo(tbuf, rc) ) if( remove_echo(tbuf, rc) )
...@@ -144,6 +147,9 @@ unsigned char ComPort485F::m_receiveByte( bool wait ) ...@@ -144,6 +147,9 @@ unsigned char ComPort485F::m_receiveByte( bool wait )
{ {
rc = ::read(fd, tbuf, sizeof(tbuf)); rc = ::read(fd, tbuf, sizeof(tbuf));
if( rc < 0 && errno != EAGAIN )
break;
if( rc > 0 ) if( rc > 0 )
{ {
if( remove_echo(tbuf, rc) ) if( remove_echo(tbuf, rc) )
...@@ -302,6 +308,9 @@ void ComPort485F::m_read( timeout_t tmsec ) ...@@ -302,6 +308,9 @@ void ComPort485F::m_read( timeout_t tmsec )
{ {
rc = ::read(fd, tbuf, sizeof(tbuf)); rc = ::read(fd, tbuf, sizeof(tbuf));
if( rc < 0 && errno != EAGAIN )
break;
if( rc > 0 ) if( rc > 0 )
{ {
if( remove_echo(tbuf, rc) ) if( remove_echo(tbuf, rc) )
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment