我有一个Modbus RTU设备,其信息存储在非标准数据地址中。
例如,它将读取的值(32位IEEE-754浮点型,converter link)存储在寄存器号1003-1004中。
我思考这意味着我不能再使用标准的Python + Modbus RTU库,例如modbus-tk
和pymodbus
。
在这种情况下可以做什么?
设备详细信息
您可以通过将其作为execute
方法的可选参数,将不同类型的数据格式与modbus-tk一起使用
# Read and write floats
# master.execute(1, cst.WRITE_MULTIPLE_REGISTERS, starting_address=0, output_value=[3.14], data_format='>f')
# logger.info(master.execute(1, cst.READ_HOLDING_REGISTERS, 0, 2, data_format='>f'))
data_format基于python struct
模块。期望值在这里列出。
https://docs.python.org/3.7/library/struct.html#format-characters
希望对您有帮助