Commit 2edec4a3 authored by Pavel Vainerman's avatar Pavel Vainerman

сменил реализацию ComPort::cleanupChannel

parent 3290b030
...@@ -576,6 +576,10 @@ int main( int argc, char **argv ) ...@@ -576,6 +576,10 @@ int main( int argc, char **argv )
msleep(200); msleep(200);
} }
} }
catch( ModbusRTU::mbException& ex )
{
cerr << "(mbtester): " << ex << endl;
}
catch(SystemError& err) catch(SystemError& err)
{ {
cerr << "(mbtester): " << err << endl; cerr << "(mbtester): " << err << endl;
......
...@@ -299,20 +299,18 @@ void ComPort::cleanupChannel() ...@@ -299,20 +299,18 @@ void ComPort::cleanupChannel()
if( fd < 0 ) if( fd < 0 )
return; return;
int fd2 = dup(fd); int oldfl = fcntl(fd, F_GETFL);
if( fd2 < 0 )
return;
fcntl(fd2,F_SETFL,O_NONBLOCK); fcntl(fd,F_SETFL,O_NONBLOCK);
unsigned char tmpbuf[100]; unsigned char tmpbuf[100];
int k = 0; int k = 0;
do do
{ {
k = ::read(fd2,tmpbuf,sizeof(tmpbuf)); k = ::read(fd,tmpbuf,sizeof(tmpbuf));
} }
while( k>0 ); while( k>0 );
close(fd2); fcntl(fd,F_SETFL,oldfl);
curSym = 0; curSym = 0;
bufLength=-1; bufLength=-1;
......
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