MangoAutomation / modbus4j

A high-performance and ease-of-use implementation of the Modbus protocol written in Java. Supports ASCII, RTU, TCP, and UDP transports as slave or master, automatic request partitioning and response data type parsing.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

创建 createTcpListener 如何让多个从站跟你建立连接

Zhao-ChengHu opened this issue · comments

public ModbusTCPClient(String host, int port) throws ModbusInitException {
    IpParameters params = new IpParameters();
    params.setHost(host);
    params.setPort(port);
    params.setEncapsulated(false);
    this.rtuMaster = modbusFactory.createTcpListener(params);
    //设置超时时间
    this.rtuMaster.setTimeout(2000);
    //设置重连次数
    this.rtuMaster.setRetries(3);
    //初始化
    this.rtuMaster.init();
}

解决了,我重写了你的TcpListener类