rogerwfrech / nmodbus

Automatically exported from code.google.com/p/nmodbus
0 stars 0 forks source link

Uninterruptible CRC error cycle during ModbusIpMaster work #61

Open GoogleCodeExporter opened 9 years ago

GoogleCodeExporter commented 9 years ago
What steps will reproduce the problem?
1. CreateIpMaster object
2. Connect remote device using RTUSerial
3. Generate some packet that contains CRC error and size of response must be 
greater than expected
4. After this steps CRC errors will be produced until TcpClient closes 
connection

This problem take place because method DiscardInBuffer() of TcpClientAdapter 
contains code that not clears input buffer. Read manul carefuly for Flush 
method. (code _tcpClient.GetStream().Flush(); - just do nothing at all), 
instead of Flush you must use something like this:

 if (_tcpClient.Available > 0)
 {
   while (_tcpClient.GetStream().ReadByte() > -1 &&
          _tcpClient.Available > 0)
                    ;
 }

What is the expected output? What do you see instead?
I expect only one CRC error and normal work after, instead i see unending 
stream of CRC error exceptions.

What version of the product are you using? On what operating system?
1.11.0.0, any OS

Please provide any additional information below.
please notify me about this bug to my second mail: taiwan@ya.ru

Original issue reported on code.google.com by taiwan....@gmail.com on 27 Apr 2012 at 3:43