For clarity I am using Python and pyModbusTCP to communicate via modbus. If I am using function code 1 to read coil status, how can I determine the function code of the message that was sent back?
Below is an example of how I sent messages to a modbus slave:
self.ModbusClient_call = ModbusClient(host=self.ip, port=502, auto_open=True, debug=False)
...
coilData = self.ModbusClient_call.read_coils(self.modbus_address)
return coilData
Per the PyModbusTCP documentation using the read_coils method is equivalent to sending a message and indicating in the first byte the function code 0x01. I am having trouble figuring out how to extract the function code from the response message though, any help much appreciated!