callbackpymodbus

pymodbus server callback fo particular modbus function code


I have a Modbus server implemented with pymodbus. This server has a thread that update the internal registers to simulate a variable environment from the field. I need to update a file when I receive a frame containing a write function code. I tried to implement the CustomDataBlock as suggested here, but that's not exactly what I need: in this example, the code is called every time a value is changed, hence also in my "internal" updating writer function. I want some code to be called only when my server receive a frame with writing function codes. Any idea? Thank you


Solution

  • I found the solution by myself:

    1. inherit ModbusRtuFramer
    2. overload processIncomingPacket function