我正在与太阳能逆变器进行一场激烈的战斗(INGETEAM 3play),我通过TCP / IP连接。
我需要了解如何调整通话方式,因为我没有想要的答案,而且我也不知道我在等待多少位。这是我需要拨打的电话:
我确定ID为03的数字表示保留寄存器,那么我如何调整其余的(00 00 00 06)?这是代码:
FORMAT = ('%(asctime)-15s %(threadName)-15s '
'%(levelname)-8s %(module)-15s:%(lineno)-8s %(message)s')
logging.basicConfig(format=FORMAT)
log = logging.getLogger('pymodbus.protocol')
log.setLevel(logging.DEBUG)
variables = [0,6,12,18,24,30,36,70,72,74,76,78,342,344]
data = client.read_holding_registers(0, 2, unit=1)
decoder = BinaryPayloadDecoder.fromRegisters(data.registers, Endian.Big)
eastron = round(decoder.decode_32bit_float(), 3)
print (eastron)
我知道我必须和client.read_holding_registers一起玩,但是如何?该文档是这样的:
也许我想念的就是Modicon这个事实?
总结问题:
示例
DEBUG:pymodbus.transaction:Current transaction state - TRANSACTION_COMPLETE
DEBUG:pymodbus.transaction:Running transaction 6
DEBUG:pymodbus.transaction:SEND: 0x1 0x3 0x0 0x0 0x0 0x2 0xc4 0xb
DEBUG:pymodbus.framer.rtu_framer:Changing state to IDLE - Last Frame End - 1580425865.276049, Current Time stamp - 1580425955.463177
DEBUG:pymodbus.client.sync:New Transaction state 'SENDING'
DEBUG:pymodbus.transaction:Changing transaction state from 'SENDING' to 'WAITING FOR REPLY'
DEBUG:pymodbus.transaction:Changing transaction state from 'WAITING FOR REPLY' to 'PROCESSING REPLY'
DEBUG:pymodbus.transaction:RECV: 0x1 0x3 0x4 0x41 0x60 0x0 0x0 0xee 0x11
DEBUG:pymodbus.framer.rtu_framer:Getting Frame - 0x3 0x4 0x41 0x60 0x0 0x0
DEBUG:pymodbus.factory:Factory Response[ReadHoldingRegistersResponse: 3]
DEBUG:pymodbus.framer.rtu_framer:Frame advanced, resetting header!!
DEBUG:pymodbus.transaction:Adding transaction 1
DEBUG:pymodbus.transaction:Getting transaction 1
DEBUG:pymodbus.transaction:Changing transaction state from 'PROCESSING REPLY' to 'TRANSACTION_COMPLETE'
DEBUG:pymodbus.payload:[16736, 0]
DEBUG:pymodbus.payload:[b'A`', b'\x00\x00']
提前感谢!
- 如何调整我的通话使其与通话01 03 00 00 00 06相匹配?
对此解码,我们得到:
01-单位ID; 1个字节; 0103-功能代码; 1个字节; 0x03 =读取保持寄存器00 00-起始地址; 2个字节(big-Endian);地址000 06-寄存器数量; 2个字节(big-Endian);长度6
这意味着以上是对单元ID 1的请求,要求从寄存器0开始“读保持寄存器”(3),返回六个寄存器。
要使用pymodbus复制此内容,请使用client.read_holding_registers(0, 6, unit=1)
。
- 为什么当我拨打电话01 03 00 00 00 06我得到所有答案(年到秒)我不应该只得到秒吗? (认为pdf中的30006代表呼叫本身03 00 00 00 06)
如上所述,该请求需要六个寄存器(因此包括全时)。
- 我如何记录拨打电话时得到的调试?我正在覆盆子中这样做,我不确定我是否能够看到像我在jupyter上一样打电话
根据您的示例,您似乎已经在生成调试信息。由于modbus是standard,因此在使用体面的库为您处理时,通常不需要查看正在发送/接收的字节。