pymodbus client出现Modbus Error: [Input/Output] No Response received from the remote unit错误

我在Windows上跑modbus server,在arm机器上跑modbus client,arm采集模拟的modbus server数据,server端出现:ERROR:pymodbus.server.sync:Socket error occurred Modbus Error 错误,client出现Modbus Error: [Input/Output] No Response received from the remote unit错误。

modbus client和modbus server同时在Windows端运行的时候没有错误,client能正常采集数据,但是client在arms上无法采集。

def connect(self):#连接server
    try:
        client = ModbusClient(method='rtu', port=self.com_port, timeout= 1)
        client.connect()
        self.client = client
        self.tconn = True
    except:
        myLogger.info("connect error")
        time.sleep(1)
        self.reconnect()
    return self.tconn

仔细查找了资料后,在Windows上运行,self.com_port对应的COM端口会自动设置波特率baudrate=9600,但是在arm上运行的时候对应的/dev下面的端口,没有设置对应的波特率(self.baudrate即modbus server的波特率)。

 
  
def connect(self):#连接server
    try:
        client = ModbusClient(method='rtu', port=self.com_port, timeout= 1, baudrate= self.baudrate)
        client.connect()
        self.client = client
        self.tconn = True
    except:
        myLogger.info("connect error")
        time.sleep(1)
        self.reconnect()
    return self.tconn

你可能感兴趣的:(pymodbus client出现Modbus Error: [Input/Output] No Response received from the remote unit错误)