-
Notifications
You must be signed in to change notification settings - Fork 1k
WIP: Recall socket recv until get a complete response. #180
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
Conversation
pymodbus/transaction.py
Outdated
| ''' Checks if the response is a Modbus Exception. | ||
| ''' | ||
| if isinstance(self.client.framer, ModbusSocketFramer): | ||
| if len(response) >= 8 and ord(response[7]) > 128: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just an early heads up, do not use ord directly , instead use byte2int from pymodbus.compat module, this way the code works fine in both python version.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ok, thanks for the advice.
In these days i'm a bit busy, probably i will submit the final PR by the next week because i still have to test it and review the changes.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sure, Thanks.
Socket recv waits until it gets some data from the host but not necessarily the entire response that can be fragmented in many packets. In this case it receives an incomplete frame that is rejected by the frame handler. This commit solves this issue by recalling socket recv until get a complete modbus response.
|
Hi, i tested the patch using RTU and Socket framers and it seems to work. |
|
Thanks @ccatterina , I will give a test and merge if everything seems good. |
|
@ccatterina I could only test on real device with RTU and TCP modes , I will take the liberty that most of the people out there aren't using the binary/ascii modes and hope it will work for them as well. Thanks for your efforts |
Socket recv waits until it gets some data from the host but not necessarily the entire response that can be fragmented in many packets. In this case it receives an incomplete frame that is rejected by the frame handler. This commit solves this issue by recalling socket recv until get a complete modbus response.
Socket recv waits until it gets some data from the host but not necessarily the entire response that can be fragmented in many packets. In this case it receives an incomplete frame that is rejected by the frame handler. This commit solves this issue by recalling socket recv until get a complete modbus response.
Socket recv waits until it gets some data from the host but not necessarily the entire response that can be fragmented in many packets. In this case it receives an incomplete frame that is rejected by the frame handler.
This commit solves this issue by recalling socket recv until get a complete modbus response.