Custom frame preprocessing #2476
-
Hello, I have a device that incorrectly creates Modbus frames - the data length is incorrectly calculated. Therefore before any further frame processing by pymodbus, the frame has to be manipulated to correct the data length, otherwise, there is a justified exception "RuntimeError: Received error response Modbus Error: [Input/Output] Unable to decode request" I was using a custom framer below PyModbus 3.7. In PyModbus 3.7.2, I could still use the custom framer approach but with the "old framer" API. In 3.7.3, the old framer was removed, so I switched to a custom Decoder. However, in 3.7.4, Decoders were reworked, so again I had to update my code. As I understand Decoder is treated as an internal interface so it can change in any release. Therefore, I'm wondering, if it is possible to accomplish the same with only the official API. Currently, my code is like this:
|
Beta Was this translation helpful? Give feedback.
Replies: 2 comments 2 replies
-
With the upcoming v3.8.0 (on dev) there are trace points where you can add your own methods and manipulate the data There are 4 trace points:
Currently we have not published an API to attach them, that is due later this week. |
Beta Was this translation helpful? Give feedback.
-
Actually the most proper solution would be to register a custom pdu, which overwrites the standard pdu, that way you can "persuade" pymodbus to accept a non-standard packet. The custom pdu can simply inherit from the standard pdu, and only overwrite (probably decode()) what is needed. |
Beta Was this translation helpful? Give feedback.
With the upcoming v3.8.0 (on dev) there are trace points where you can add your own methods and manipulate the data
There are 4 trace points:
Currently we have not published an API to attach them, that is due later this week.