0

In order to get the output of a measurment device I'm using pySerial as follows:

k = [addr, 0x04, (register/256)&0xFF, register&0xFF, (length/256)&0xFF, length&0xFF]

ser.write("".join([chr(x) for x in k]))

# read response
rsp = [ord(x) for x in ser.read(2000)]

rsp that I get is always an empty str

Do you have an idea?

Ben Jo
  • 71
  • 1
  • 15
  • Modbus already has a bunch of implementations in Python. I used pymodbusTCP to create a simple client that reads holding registers off a localhost tcp server. Since you need to read off a serial, you might need pymodbus or minimalmodbus. Example: http://pymodbus.readthedocs.io/en/latest/examples/synchronous-client.html – BoboDarph Oct 10 '17 at 14:29
  • I forgot the most important part: This question helped me pick the right module for my task. Maybe it will help you too: https://stackoverflow.com/questions/17081442/python-modbus-library – BoboDarph Oct 10 '17 at 14:38
  • I'm actually using a BBB as an interface between the Modbus and the Computer – Ben Jo Oct 10 '17 at 14:46
  • @BenJo, Are you trying to access the registers over ModbusRTU or Modbus ASCII ? Note BBB does not come with in built support to RS485 ,which is required for Modbus RTU. You will need to use external RS485 CAPE. Note There was a discussion to enable RS485 on BBB kernel but not sure how far it has gotten. – Sanju Oct 18 '17 at 05:07

0 Answers0