我有一个Modbus RTU设备,它的信息存储在非标准的数据地址中.
例如,它将读取值(32位IEEE-754浮点数,转换器链路)存储在寄存器号1003-1004中.
我认为这意味着我不能再使用标准的Python + Modbus RTU库,比如modbus-tk
和pymodbus
。
在这种情况下能做些什么呢?
设备规范
发布于 2020-05-28 08:35:22
通过将modbus-tk作为execute
方法的可选参数,可以使用不同类型的数据格式。
# 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
我希望它能帮上忙
https://stackoverflow.com/questions/60085935
复制相似问题