pymodbus 读取仪表寄存器

我是 modbus 的新手,但我有一个小项目要处理。我需要从电能表中读取一些值。我从互联网上找到的一些例子中写了这个:


import logging

from pymodbus.client.sync import ModbusTcpClient as ModbusClient


logging.basicConfig()

log = logging.getLogger()

log.setLevel(logging.DEBUG)


client = ModbusClient('192.168.80.210')

client.connect() 

rr = client.read_holding_registers(40012, 1)

print rr


client.close()

它似乎连接到仪表,因为这是我的输出:


DEBUG:pymodbus.transaction:Current transaction state - IDLE

DEBUG:pymodbus.transaction:Running transaction 1

DEBUG:pymodbus.transaction:SEND: 0x0 0x1 0x0 0x0 0x0 0x6 0x0 0x3 0x9c 0x4c 0x0 0x1

DEBUG: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 1

DEBUG: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地图


慕容森
浏览 415回答 1
1回答
打开App,查看更多内容
随时随地看视频慕课网APP

相关分类

Python