You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
red = master.execute(1, cst.READ_HOLDING_REGISTERS, 64012, 1) # 这里可以修改需要读取的功能码
print(red)
if name == "main":
main()
return:
Traceback (most recent call last):
File "D:\WorkSpace\Test\main.py", line 20, in
main()
File "D:\WorkSpace\Test\main.py", line 15, in main
red = master.execute(1, cst.READ_HOLDING_REGISTERS, 64012, 1) # 这里可以修改需要读取的功能码
File "D:\WorkSpace\Test\venv\lib\site-packages\modbus_tk\utils.py", line 39, in new
raise excpt
File "D:\WorkSpace\Test\venv\lib\site-packages\modbus_tk\utils.py", line 37, in new
ret = fcn(*args, **kwargs)
File "D:\WorkSpace\Test\venv\lib\site-packages\modbus_tk\modbus.py", line 356, in execute
response_pdu = query.parse_response(response)
File "D:\WorkSpace\Test\venv\lib\site-packages\modbus_tk\modbus_rtu.py", line 60, in parse_response
raise ModbusInvalidResponseError("Invalid CRC in response")
modbus_tk.exceptions.ModbusInvalidResponseError: Invalid CRC in response
-- coding: utf_8 --
import serial
import modbus_tk
import modbus_tk.defines as cst
from modbus_tk import modbus_rtu
def mod(PORT="com9"):
red = []
alarm = ""
try:
# 设定串口为从站
master = modbus_rtu.RtuMaster(serial.Serial(port=PORT,
baudrate=38400, bytesize=8, parity='N', stopbits=1))
master.set_timeout(5.0)
master.set_verbose(True)
if name == "main":
mod()
return:
ModbusInvalidResponseError: Invalid CRC in response
The text was updated successfully, but these errors were encountered: