You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@plc4x.apache.org by "Thijs M (Jira)" <ji...@apache.org> on 2022/02/12 15:29:00 UTC

[jira] [Commented] (PLC4X-333) Multiple Items in ADS Read

    [ https://issues.apache.org/jira/browse/PLC4X-333?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17491369#comment-17491369 ] 

Thijs M commented on PLC4X-333:
-------------------------------

Is the protocol making use of the ADS-SUM Command to read multiple variables at once?

[https://infosys.beckhoff.com/english.php?content=../content/1033/tcadsamsspec/html/tcadsamsspec_intro.htm]

 

> Multiple Items in ADS Read
> --------------------------
>
>                 Key: PLC4X-333
>                 URL: https://issues.apache.org/jira/browse/PLC4X-333
>             Project: Apache PLC4X
>          Issue Type: Bug
>          Components: Driver-ADS
>    Affects Versions: 0.10.0
>            Reporter: Thijs M
>            Priority: Major
>
> Hi,
> For a POC I'am testing PLC4X with ADS/AMS PLC.  the PLC is a CX with twincat V2.11.0 (Build 2216) on it.
> So I made this test program with PLC4j (0.10.0_SNAPSHOT) to read 1 variable (BOOL).  This seems to work fine.  When I add a second variable (also BOOL) to the same request, I get an exception :
> Caused by: java.lang.ArrayIndexOutOfBoundsException: Index -1 out of bounds for length 0
>     at com.github.jinahya.bit.io.ArrayByteInput.read(ArrayByteInput.java:106)
>     at com.github.jinahya.bit.io.DefaultBitInput.read(DefaultBitInput.java:57)
>     at com.github.jinahya.bit.io.AbstractBitInput.unsigned8(AbstractBitInput.java:63)
>     at com.github.jinahya.bit.io.AbstractBitInput.unsigned16(AbstractBitInput.java:92)
>     at com.github.jinahya.bit.io.AbstractBitInput.readInt(AbstractBitInput.java:135)
>     at com.github.jinahya.bit.io.AbstractBitInput.readInt(AbstractBitInput.java:118)
>     at com.github.jinahya.bit.io.AbstractBitInput.readLong(AbstractBitInput.java:156)
>     at org.apache.plc4x.java.spi.generation.ReadBufferByteBased.readUnsignedLong(ReadBufferByteBased.java:190)
>     at org.apache.plc4x.java.spi.generation.ReadBuffer.readUnsignedLong(ReadBuffer.java:74)
>     at org.apache.plc4x.java.ads.protocol.AdsProtocolLogic.lambda$resolveMultipleSymbolicAddresses$65(AdsProtocolLogic.java:975)
>     at java.base/java.util.ArrayList.forEach(ArrayList.java:1540)
>     at org.apache.plc4x.java.ads.protocol.AdsProtocolLogic.lambda$resolveMultipleSymbolicAddresses$67(AdsProtocolLogic.java:972)
>     at org.apache.plc4x.java.spi.Plc4xNettyWrapper.decode(Plc4xNettyWrapper.java:175)
>     at io.netty.handler.codec.MessageToMessageCodec$2.decode(MessageToMessageCodec.java:81)
>     at io.netty.handler.codec.MessageToMessageDecoder.channelRead(MessageToMessageDecoder.java:88)
>  
> Here is my code:
> String clientIp = "192.168.0.192";
> String sourceAmsNetId = "172.16.13.147.1.1";
> int sourceAmsPort = 65534;
> String targetAmsNetId = "192.168.0.184.1.1";
> int targetAmsPort = 801;
> String connectionString = String.format("ads:tcp://%s?sourceAmsNetId=%s&sourceAmsPort=%d&targetAmsNetId=%s&targetAmsPort=%d", plcIp, sourceAmsNetId, sourceAmsPort, targetAmsNetId, targetAmsPort);
> try (PlcConnection plcConnection = new PlcDriverManager().getConnection(connectionString)){
> if (!plcConnection.getMetadata().canSubscribe()) {
> logger.error("This connection doesn't support subscribing.");
> return;
> }
> // Send Read Request
> CompletableFuture<? extends PlcReadResponse> requestFuture = plcConnection.readRequestBuilder()
> .addItem("value-1", ".OPC_bAuto_:BOOL")
> .addItem("value-2", ".OPC_bAuto_2:BOOL")
> .build()
> .execute();
> PlcReadResponse response = requestFuture.get();
>  
>   Any help would greatly be appreciated.  Thank you !



--
This message was sent by Atlassian Jira
(v8.20.1#820001)