RS485 Modbus-RTU设备给出的错误是什么?

问题描述 投票:1回答:1

我正在使用minimalmodbus通过RS485使用PID controller (Love 16C-3)USB-RS485 adapter cable进行通信。

但是,在尝试读取寄存器时,会显示以下错误。这个错误是什么意思?

raise ValueError('The slave is indicating an error. The response is: {!r}'.format(response))
ValueError: The slave is indicating an error. The response is: '\x01\x83\x02\xc0\xf1'

从硬件手册

enter image description here

Python代码

instrument = minimalmodbus.Instrument(port, 1, 'rtu')
instrument.serial.baudrate = 9600
instrument.serial.bytesize=8
instrument.serial.parity='E'
instrument.serial.stopbits=1
instrument.read_register(4096,1)

enter image description here

python serial-port modbus rs485 minimalmodbus
1个回答
0
投票

如果您参考modbus规范,您会发现函数的异常是通过在函数字节中设置MSB来实现的...有效地将0x80添加到答复中的函数号。

在您的示例中,您试图读取保持寄存器。您的请求使用的函数号为0x03。您收到的异常是函数0x03,MSB设置为高,导致回复函数为0x83。异常代码是函数编号后面的数字,在您的情况下是0x02。

在Modbus规范中,当不支持寄存器地址时,使用异常代码2。

BTW,modbus是一个非常简单的协议,原始规格本身很小,很容易获得。如果您计划在任何深度使用modbus,我强烈建议至少手头有这个:Modbus Application Protocol v1.1

© www.soinside.com 2019 - 2024. All rights reserved.