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

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

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