-
Notifications
You must be signed in to change notification settings - Fork 951
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fixes for malformed stream #356 #363
Conversation
Reset frame when checkframe fails as it is impossible to know what is a valid start packet if CRC or mid frame is in buffer.
I Had it one level too deep. This alongside with pymodbus-dev#361 Tested. Task cancellation due to async timeout. Recovers correctly Malformed RTU packets with CRC errors now recover. Only issue I can see with this is if the serial stream is so continuous that you always are pulling mid stream and the discarding of the buffer will create a perpetual discarding of the buffer. But as it is a call and response, I can't see this happening in any real world examples but my modbus knowledge is a bit low for this.
The following tests also have to do with PR #361 |
Dev branch.
|
PR #361 branch.
|
Dev Branch:
|
PR #356 Branch:
|
PR #361 + PR #356
|
@pazzarpj Thanks for the PR and the detailed testing, I will give it a try this week and update. |
Looks like the changes in this PR is also part of #361 . I will be closing this for the time being. |
Whoops, looks like for the first PR I used my forked master branch which polluted this PR with the other changes. Sorry. |
Changing processIncomingPacket in RTU framer so that if a frame is ready but fails the self.checkFrame(), it will reset the frame.
Tests as per below see comments
Test Setup.
Simulator - Modbus Slave Windows 10
com0com - Serial port loopback
Client - Modbus RTU Async
pip install async_timeout
19200 Baud
8 Data bits
None Parity
1 Stop bit
RTU
Slave 1:
Unit ID 1:
Address 0
Value 1
Slave 2:
Unit ID 1:
Address 0-9
Value 1-10
Slave 3:
Unit ID 3:
Address 0-10
Value 0-0
Periodic poll using this setup