Warning: file_get_contents(/data/phpspider/zhask/data//catemap/6/mongodb/11.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/0/jpa/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Python 属性错误:';例外响应';对象没有属性';寄存器';(TCP/IP上的ModbusRTU)?_Python_Attributeerror_Modbus_Pymodbus - Fatal编程技术网

Python 属性错误:';例外响应';对象没有属性';寄存器';(TCP/IP上的ModbusRTU)?

Python 属性错误:';例外响应';对象没有属性';寄存器';(TCP/IP上的ModbusRTU)?,python,attributeerror,modbus,pymodbus,Python,Attributeerror,Modbus,Pymodbus,首先,我很抱歉创建一个单独的论坛,我知道相同的问题在单独的论坛中得到了回答,但是。。这些似乎都不能解决我所面临的问题。因此,我正在pymodbus库中创建ModbusRTU主机(或服务器-客户端术语中的客户端)。问题是RTU从设备(现场设备)通过TCP/IP发送串行消息。因此,我正在使用modbuscpclient和modbusrutframer来实现Modbus RTU主机,该主机通过TCP端口发送ModbusRTU查询帧,监听响应并将其记录在csv文件中。下面是我的代码,但当我执行它时,我得

首先,我很抱歉创建一个单独的论坛,我知道相同的问题在单独的论坛中得到了回答,但是。。这些似乎都不能解决我所面临的问题。因此,我正在
pymodbus
库中创建ModbusRTU主机(或服务器-客户端术语中的客户端)。问题是RTU从设备(现场设备)通过TCP/IP发送串行消息。因此,我正在使用
modbuscpclient
modbusrutframer
来实现Modbus RTU主机,该主机通过TCP端口发送ModbusRTU查询帧,监听响应并将其记录在csv文件中。下面是我的代码,但当我执行它时,我得到了以下错误。我寻求专家帮助解决这个问题

 2020-06-07 17:59:58,895 MainThread     DEBUG    ModbusRTU_DataCollection_Script:42       Reading Input Registers
 2020-06-07 17:59:58,903 MainThread     DEBUG    transaction    :114      Current transaction state - IDLE
 2020-06-07 17:59:58,908 MainThread     DEBUG    transaction    :119      Running transaction 1
 2020-06-07 17:59:58,912 MainThread     DEBUG    transaction    :219      SEND: 0x1 0x4 0x75 0xf8 0x0 0x8 0x6a 0x31
 2020-06-07 17:59:58,918 MainThread     DEBUG    sync           :75       New Transaction state 'SENDING'
 2020-06-07 17:59:58,924 MainThread     DEBUG    transaction    :228      Changing transaction state from 'SENDING' to 'WAITING FOR REPLY'
 2020-06-07 17:59:58,929 MainThread     DEBUG    transaction    :304      Changing transaction state from 'WAITING FOR REPLY' to 'PROCESSING REPLY'
 2020-06-07 17:59:58,934 MainThread     DEBUG    transaction    :233      RECV: 0x1 0x84 0x2 0xc2 0xc1
 2020-06-07 17:59:58,939 MainThread     DEBUG    rtu_framer     :180      Getting Frame - 0x84 0x2
 2020-06-07 17:59:58,944 MainThread     DEBUG    factory        :266      Factory Response[132]
 2020-06-07 17:59:58,948 MainThread     DEBUG    rtu_framer     :115      Frame advanced, resetting header!!
 2020-06-07 17:59:58,953 MainThread     DEBUG    transaction    :383      Adding transaction 1
 2020-06-07 17:59:58,958 MainThread     DEBUG    transaction    :394      Getting transaction 1
 2020-06-07 17:59:58,962 MainThread     DEBUG    transaction    :193      Changing transaction state from 'PROCESSING REPLY' to 'TRANSACTION_COMPLETE'
 Traceback (most recent call last):
   File "D:\JOB FILES\ModbusRTU_Master_DataCollector\ModbusRTU_DataCollection_Script.py", line 65, in <module
     run_sync_client()
   File "D:\JOB FILES\ModbusRTU_Master_DataCollector\ModbusRTU_DataCollection_Script.py", line 51, in run_sync_client
     decoder = BinaryPayloadDecoder.fromRegisters(result.registers,Endian.Little,wordorder=Endian.Little)
 AttributeError: 'ExceptionResponse' object has no attribute 'registers'
提前谢谢
尊敬的B先生,我想您可能需要删除30000偏移量,请尝试更改此行:

result = client.read_input_registers(200,8,unit=UNIT)

@Macos G。感谢您的回复,我们将尝试返回。再次感谢@Marcos G先生。它成功了。我想知道你是怎么发现的:)。请给我一个提示如何调试这个模块,如果它适合你。谢谢@Macos G先生。不客气,B先生。我有过很多次同样的问题。我不知道调试需要什么提示,您已经有了调试信息。不幸的是,。正如你所看到的,有时候它并没有那么有用。但是你可以随便问你需要什么
result = client.read_input_registers(200,8,unit=UNIT)