I have been trying to connect to a device using a serial port and RTU Modbus. The device is a variable frequency controller:
Which is connected to my laptop via the following RS485 to USB converter:
https://www.amazon.co.uk/gp/product/B01E8JRL6O/ref=ppx_yo_dt_b_search_asin_title?ie=UTF8&psc=1
The instructions with the device I'm connected to provide a usage example for reading data with Modbus, as shown below:
With the above, provided, I have tried to perform a read request with the below code:
from pymodbus.client.sync import ModbusSerialClient as ModbusClient
modbus = ModbusClient(method='rtu', port='/dev/tty.usbserial-AQ00BYCR', baudrate=9600, timeout=1)
modbus.connect()
test = modbus.read_holding_registers(1, 1, unit=1)
print (test)
Where I assume, above, that the line:
test = modbus.read_holding_registers(1, 1, unit=1)
means that register address 1 is read, for 1 reading frame, and for device ID 1. To my understanding, this request corresponds to the instruction example shown above. Unfortunately, however, I consistently get the error message:
Modbus Error: [Input/Output] Modbus Error: [Invalid Message] Incomplete message received, expected at least 2 bytes (1 received)
Does anyone know why I am getting this error? And, secondly, is the CRC calculated on-the-fly by the pymodbus? Or am I supposed to some how calculate this and include it?
Any help is much appreciated!