我是 modbus 的新手,但我有一個小項目要處理。我需要從電能表中讀取一些值。我從互聯網上找到的一些例子中寫了這個:import loggingfrom pymodbus.client.sync import ModbusTcpClient as ModbusClientlogging.basicConfig()log = logging.getLogger()log.setLevel(logging.DEBUG)client = ModbusClient('192.168.80.210')client.connect() rr = client.read_holding_registers(40012, 1)print rrclient.close()它似乎連接到儀表,因為這是我的輸出:DEBUG:pymodbus.transaction:Current transaction state - IDLEDEBUG:pymodbus.transaction:Running transaction 1DEBUG:pymodbus.transaction:SEND: 0x0 0x1 0x0 0x0 0x0 0x6 0x0 0x3 0x9c 0x4c 0x0 0x1DEBUG:pymodbus.client.sync:New Transaction state 'SENDING'DEBUG:pymodbus.transaction:Changing transaction state from 'SENDING' to 'WAITING FOR REPLY'DEBUG:pymodbus.transaction:Transaction failed. (Modbus Error: [Invalid Message] Incomplete message received, expected at least 8 bytes (0 received)) DEBUG:pymodbus.framer.socket_framer:Processing: DEBUG:pymodbus.transaction:Getting transaction 1DEBUG:pymodbus.transaction:Changing transaction state from 'PROCESSING REPLY' to 'TRANSACTION_COMPLETE'Modbus Error: [Input/Output] Modbus Error: [Invalid Message] Incomplete message received, expected at least 8 bytes (0 received)我想從寄存器中讀取40012到40014,這是Modbusdbus映射我有: 的Modbus地圖
添加回答
舉報
0/150
提交
取消