Uploaded image for project: 'Apache PLC4X'
  1. Apache PLC4X
  2. PLC4X-333

Multiple Items in ADS Read

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Open
    • Major
    • Resolution: Unresolved
    • 0.10.0
    • None
    • Driver-ADS
    • None

    Description

      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 !

      Attachments

        Activity

          People

            Unassigned Unassigned
            ThijsM Thijs M
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

            Dates

              Created:
              Updated: