apache / plc4x

PLC4X The Industrial IoT adapter
https://plc4x.apache.org/
Apache License 2.0
1.25k stars 402 forks source link

[Feature Request]: plc4j-driver-modbus need to have Slave Id configuration when reading TagAddress #1450

Closed yangshuyi closed 6 months ago

yangshuyi commented 7 months ago

What would you like to happen?

When I try to connect Modbus and read data from address with a slave id like 22, I cannot find the slave id configuration in the plc4j-driver-modbus library.

I get a little confused, because other's lib like modbus4j has this feature.

Without slave id, it looks always reading from a default slave-id, like 1 which does not exist, then it will cause timeout exception:

java.util.concurrent.ExecutionException: java.util.concurrent.TimeoutException at java.base/java.util.concurrent.CompletableFuture.reportGet(CompletableFuture.java:396) at java.base/java.util.concurrent.CompletableFuture.get(CompletableFuture.java:2073) at com.primustech.siriusplus.dae.modbus.client.ModbusReader.readData(ModbusReader.java:82) at com.primustech.siriusplus.dae.modbus.processor.ModbusConnPoolingThread.readData(ModbusConnPoolingThread.java:20) at com.primustech.siriusplus.dae.core.processor.ConnPollingThreadAbstract.lambda$run$0(ConnPollingThreadAbstract.java:43) at com.primustech.siriusboot.common.base.tracelog.utils.TracelogSpringScheduleUtils.execute(TracelogSpringScheduleUtils.java:20) at com.primustech.siriusplus.dae.core.processor.ConnPollingThreadAbstract.run(ConnPollingThreadAbstract.java:42) at java.base/java.lang.VirtualThread.run(VirtualThread.java:309) Caused by: java.util.concurrent.TimeoutException: null at org.apache.plc4x.java.spi.netty.NettyHashTimerTimeoutManager.lambda$0(NettyHashTimerTimeoutManager.java:54) at io.netty.util.HashedWheelTimer$HashedWheelTimeout.run(HashedWheelTimer.java:715) at io.netty.util.concurrent.ImmediateExecutor.execute(ImmediateExecutor.java:34) at io.netty.util.HashedWheelTimer$HashedWheelTimeout.expire(HashedWheelTimer.java:703) at io.netty.util.HashedWheelTimer$HashedWheelBucket.expireTimeouts(HashedWheelTimer.java:790) at io.netty.util.HashedWheelTimer$Worker.run(HashedWheelTimer.java:503) at java.base/java.lang.Thread.run(Thread.java:1583)

Programming Languages

Protocols

chrisdutz commented 7 months ago

The "unit-identifier" doesn't help? https://plc4x.apache.org/users/protocols/modbus.html It's part of the connection-string.

splatch commented 6 months ago

If its about various slave ids then its a duplicate of #1234.

yangshuyi commented 6 months ago

Got it. I tried and it works. It might be good if the document can update. Thanks a lot.

chrisdutz commented 6 months ago

I added the comment "or slave-id" to the description of the unit-identifier.