-
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
Single byte error response handling #1924
Comments
Let's start by the basic, the mdap header (first 7 bytes) says the data length is 2, and you receive 84 02.... why do you think you only receive 84 ? A modbus package is minimum 2 byte (funcion code and data byte). |
But anyhow if the code change solve your problem, then please submit a pull request so other can benefit from it. I am still wondering why wireshark says it is a malformed mode tcp-packet, that seems to be another problem. |
@janiversen Unfortunately I have no idea about modbus, but I followed the data a little following your 2 byte hint. The second byte is truncated here (error = False): pymodbus/pymodbus/framer/socket_framer.py Line 144 in 6913e9c
So a totally different code change that fixes my problem is deleting the pymodbus/pymodbus/framer/socket_framer.py Line 99 in 6913e9c
pymodbus/pymodbus/framer/socket_framer.py Line 80 in 6913e9c
By doing that, I get an |
I will take a closer look later this week, I can easily simulate the wireshark packet. |
P.S. I mentioned the data is only 0x84. That's what I get looking at |
Solved in #1925 |
Versions
Pymodbus Specific
Description
Current State
When I query my sungrow inverter with a register I'm not supposed to be querying, I'm gettting a malformed package and the connection is dopped.
Wireshark:
TCP Payload: 00 02 00 00 00 02 01 84 02
Request
This line of code assumes that
data
has more than a single element. However,data
in my case is only b'\x84'.The response is being assigned correctly: Exception Response(132, 4, IllegalFunction)
But in the marked line I'm getting an pymodbus.logging:General exception: index out of range
See
pymodbus/pymodbus/factory.py
Line 351 in 6913e9c
I can fix this locally by changing
to
but I really have no idea what I'm doing here.
However that change allows me to handle the error super nicely on the response object:
Code and Logs
The text was updated successfully, but these errors were encountered: