Modbus Error: [Input/Output] Unable to decode request #2474
-
Hi, In the Jeedom plugin for a modbus implementation, a user encounters a problem with his setup. He has a serial communication behind a gateway (serial/TCP) and when a request is send (all the previous log are irrelevant) the log looks like this and repeats itself .
"Chaudière" is the equipment name in Jeedom. It appears that the gateway, and maybe the device too, sends too many bytes :
The error occurs before any decoding has been done according to the logs. In my program, in the decoding part, logs are written but these logs don't appear here. It is obvious that the device sends something wrong, this does not make any doubt, but would it be possible to avoid the error? Any idea? |
Beta Was this translation helpful? Give feedback.
Replies: 4 comments
-
You do not write which version of pymodbus you use, nor whether is sync/async and which call you are using ? The Send
Looks like a tcp/socket connection. So that is all correct.
Length is 8, This is the reason the packet cannot be decoded. I have no idea, why it repeats itself, it is something outside pymodbus !! Pymodbus raises pymodbus.exceptions.ModbusIOException, and waits for a new request. pymodbus do not accept illegal packets, the simple reason being that it is impossible. The simplest way is to use the trace_recv_packet method, which receives the byte stream and allows modifications. The new version of the trace methods are available on dev, and will be part of v3.8.0 |
Beta Was this translation helpful? Give feedback.
-
Of course, sorry... Thank you for your answer. So in the received packet, there are 8 bytes of data (5 would have been enough for "standart" response) and after the 2 bytes data, there are 3 bytes more. The 3 more bytes should/could be ignored and only the byte count (in this example 2 bytes = 1 register) should be used. Somehow, the response is well formed : the data length is 2 bytes (1 register). The response length is odd, but the count is ok. He is still making some tests. He may deactivate the RFC 2117 feature, it may help. |
Beta Was this translation helpful? Give feedback.
-
The response is NOT well formed, the byte count field is wrong ! But knowing the request, the MBAP length is wrong and the message contain too many bytes. The RFC 2117 is normally with frameType.RTU and not with frameType.SOCKET. |
Beta Was this translation helpful? Give feedback.
-
The gateway may introduce the error in the frame after a conversion (RTU->socket). It may have some option to disable such stuff. I will tell him to look in this direction. Thank you again! |
Beta Was this translation helpful? Give feedback.
You do not write which version of pymodbus you use, nor whether is sync/async and which call you are using ?
The Send
Looks like a tcp/socket connection.
Length is 6,
Slave is 10
Function code is read input registers
address is 12
count is 1
So that is all correct.
The device responds with:
Length is 8,
Slave is 10
Function code is read input registers
byte count is 2
BUT the there are 5 data bytes, which is WRONG, first of all data are a multiple of 2, and byte count must correspond with that.
This is the reason the packet cannot be decoded.
I have no idea, why it repeats i…