-1

I am using pymodbus to communicate with indicators and displays. The indicators are straightforward to read and write to, using

client.read_holding_registers(address, unit)

and

client.write_register(address, value, unit)

However, the instructions for the displays I have outline reading and writing by sending and receiving bytes display instructions

I have tried using the same code as before, setting the unit to 01 and address to either 4 or 6 for reading/writing respectively. Attempting to read from the register errors with 'Unable to decode response', and I don't know where to begin with writing the byte code to the displays.

I read a bit on payload building, but didn't get it to work. I can't come across how to read/write pure messages without separately specifying registers and values. Any guidance on this would be greatly appreciated!

adaone
  • 1

1 Answers1

1

If you look at the Modbus Protocol Specification, you'll see the documentation you've shared is just a breakdown of the Modbus RTU frame. That frame has an address of 1, function code of 06, register address of 0 and value of 8888. The framing is handled by pymodbus, so this is equivalent to:

client.write_register(0,8888,1)

Have you tried using logging to identify what exactly your pymodbus master is sending? There are many great examples on the Github, but a basic example is:

import logging
FORMAT = ('%(asctime)-15s %(threadName)-15s '
          '%(levelname)-8s %(module)-15s:%(lineno)-8s %(message)s')
logging.basicConfig(format=FORMAT)
log = logging.getLogger()
log.setLevel(logging.DEBUG)

You should also confirm the setup of your serial client. Do the parity, stopbits, and bytesize match your slave setup?