-
Notifications
You must be signed in to change notification settings - Fork 940
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
ReadDeviceInformationRequest fails with struct error #307
Comments
This should be fixed in ModbusRtuFramer.checkFrame(), which should catch the struct error from populateHeader() and return False, as it already does with IndexError and KeyError. There should also be some kind of timeout which ensures advanceFrame() is called if the packet is irretrievably broken or will never come, but I expect that's already there since you're already handling IndexError and KeyError in exactly the same way. A time.sleep() timeout is not the best thing to add here. |
Fixed with v2.1.0 |
Hello, I've run into a curious issue in sync.py's _wait_for_data(). I have two USB to RS485 converters. One behaves well, but the other, which unfortunately I am strapped with, does not. Specifically the poorly behaving converter will send along about 9 bytes, then buffer the remaining bytes. This buffering takes longer than the 0.01 second threshold in _wait_for_data(), such that _wait_for_data() breaks out of its while loop since it sees no new data for more than 10ms. The response is approximately 119 bytes long (ReadDeviceInformationRequest) Changing works around the problem, at least for the length of data I'm expecting. Do you think increasing that timeout is wise? Is there a better approach? Here is a link to the code in question: Thank you for your time, |
@aharrah can you give some more info on your setup (os, pymodbus version etc?) |
OS: Windows 10 I am communicating with sensors from www.vaisala.com, specifically their temperature and CO2 sensors. The only issue is with The USB to RS485 adapter provided by Vaisala behaves well, but the generic USB to RS485 adapter does not behave well. |
I was also able to reproduce the behavior on Linux. We are using a PLC (https://revolution.kunbus.com/revpi-connect/) that runs Linux. uname -a: |
On Windows you probably will have to use |
The issue is with the In some cases 10ms is too short and the loop exits prematurely. Increasing the wait on line 553 to 30ms will work around the problem, at least for my particular situation. -- There is a related issue in On both Linux and Windows |
Hi! I am also using Vaisala Temp sensor and expereince the same issue using FTDI based USB to RS485 adapter and talking Modbus. Do you know about any other solution except increasing sleep to 30ms? I would prefer not to customize sync.py. |
I had the same preference. I patch sync.py at runtime. To use the code below just execute
|
aharrah. |
Versions
Pymodbus Specific
Description
Trying to execute mei message (ReadDeviceInformationRequest) and ReportSlaveIdRequest results in struct error. This is partly because these requests do not
get_response_pdu_size
methods implemented and expected response length is passed asNone
. The_wait_for_data
method in client.sync.ModbusSerialClient class for some devices does not wait for the complete data to come in to the read buffer, thereby returning partial data .Code and Logs
The text was updated successfully, but these errors were encountered: