digitalpetri / modbus

Modbus TCP, Modbus RTU/TCP, and Modbus RTU/Serial for Java 17+.
Eclipse Public License 2.0
654 stars 222 forks source link

ERROR com.digitalpetri.modbus.examples.master.ReadCoilsMaster - Completed exceptionally, message=functionCode=ReadCoils, exceptionCode=IllegalFunction #15

Closed allon3721 closed 7 years ago

allon3721 commented 7 years ago

ModbusTcpMasterConfig config = new ModbusTcpMasterConfig.Builder("localhost").build(); ModbusTcpMaster master = new ModbusTcpMaster(config);

    CompletableFuture<ReadCoilsResponse> future =
            master.sendRequest(new ReadCoilsRequest(0, 2), 0);

future.thenAccept(response -> { ByteBuf coilStatus = response.getCoilStatus();

ReferenceCountUtil.release(response);

});

kevinherron commented 7 years ago

IllegalFunction typically means whatever slave you're talking to hasn't implemented the function code you're trying to use.