我有 python 脚本,它从电表读取寄存器并将值保存到数据库。
脚本一直运行良好,直到今天我尝试运行它时出现错误:
AttributeError: 'ModbusIOException' object has no attribute 'registers'
我可以正常ping设备...
这是我的代码(一半)——即使是简单的打印价值也不再有效
from pymodbus.client import ModbusTcpClient
IP = "192.168.X.X"
client = ModbusTcpClient(IP)
reg = client.read_holding_registers(23322, 2)
calc = round((reg.registers[0] * pow(2, 16) + reg.registers[1]) * 0.01 / 1000, 2)
print(calc)
可能是什么问题?