Hi there,

 

I'm working on using the PLC4X framework within my research projects
involving datalogging from Beckhoff PLC via ADS protocol.

 

I was able to connect with the PLC using the following code, but it fails on
the line where the read request is executed:

 

PlcConnection plcConnection = null;

String connectionStr = "
ads:tcp://127.0.0.1:48898/5.23.164.94.1.1:851/129.254.235.187.1.1:32835";


try {

                        plcConnection = new
PlcDriverManager().getConnection(connectionStr);

                        if (this.plcConnection.isConnected()){

                                    if (!this.isAdsReadable() ||
!this.isAdsWritable() || !this.isAdsSubscribable()) {

                                               return false;

                                   }

                                   this.logger.log("Connected successfully
with " + connectionStr);                                       

                                   return true;

                        } else {

                                   this.logger.log(Level.ERROR, "Could not
connect with " + connectionStr);

                                   return false;

                        }

            } catch (PlcConnectionException e) {

                        // TODO Auto-generated catch block

                        this.logger.log(e);

                        return false;

            }

            PlcReadRequest.Builder builder
=plcConnection.readRequestBuilder();

            builder.addItem("BOOL1", "BOOL1:BOOL");                      //
Boolean variable in GVL (global) list of SPS Project

            PlcReadRequest readRequest = builder.build();

            PlcReadResponse response = null;

            try {

                        response = readRequest.execute().get();
// CODE FAILS HERE

            } catch (InterruptedException e) {

                        // TODO Auto-generated catch block

                        this.logger.log(e);

            } catch (ExecutionException e) {

                        // TODO Auto-generated catch block

                        this.logger.log(e);

            }

 

Console Output:

        Connected successfully with
ads:tcp://127.0.0.1:48898/5.23.164.94.1.1:851/129.254.235.187.1.1:32835

 

Exception in thread "main"
org.apache.plc4x.java.api.exceptions.PlcRuntimeException: Non error code
received Result{AdsReturnCode{hex=0x0710, dec=1808, description='symbol not
found', possibleCauses='', solution=''}}

        at
org.apache.plc4x.java.ads.connection.AdsAbstractPlcConnection.lambda$mapFiel
ds$3(AdsAbstractPlcConnection.java:184)

        at
java.base/java.util.concurrent.ConcurrentHashMap.computeIfAbsent(ConcurrentH
ashMap.java:1708)

        at
org.apache.plc4x.java.ads.connection.AdsAbstractPlcConnection.mapFields(AdsA
bstractPlcConnection.java:163)

        at
java.base/java.util.stream.ForEachOps$ForEachOp$OfRef.accept(ForEachOps.java
:183)

        at
java.base/java.util.stream.ReferencePipeline$3$1.accept(ReferencePipeline.ja
va:195)

        at
java.base/java.util.stream.ReferencePipeline$2$1.accept(ReferencePipeline.ja
va:177)

        at
java.base/java.util.LinkedList$LLSpliterator.forEachRemaining(LinkedList.jav
a:1242)

        at
java.base/java.util.stream.AbstractPipeline.copyInto(AbstractPipeline.java:4
84)

        at
java.base/java.util.stream.ForEachOps$ForEachTask.compute(ForEachOps.java:29
0)

        at
java.base/java.util.concurrent.CountedCompleter.exec(CountedCompleter.java:7
46)

        at
java.base/java.util.concurrent.ForkJoinTask.doExec(ForkJoinTask.java:290)

        at
java.base/java.util.concurrent.ForkJoinTask.doInvoke(ForkJoinTask.java:408)

        at
java.base/java.util.concurrent.ForkJoinTask.invoke(ForkJoinTask.java:736)

        at
java.base/java.util.stream.ForEachOps$ForEachOp.evaluateParallel(ForEachOps.
java:159)

        at
java.base/java.util.stream.ForEachOps$ForEachOp$OfRef.evaluateParallel(ForEa
chOps.java:173)

        at
java.base/java.util.stream.AbstractPipeline.evaluate(AbstractPipeline.java:2
33)

        at
java.base/java.util.stream.ReferencePipeline.forEach(ReferencePipeline.java:
497)

        at
org.apache.plc4x.java.ads.connection.AdsAbstractPlcConnection.mapFields(AdsA
bstractPlcConnection.java:157)

        at
org.apache.plc4x.java.ads.connection.AdsAbstractPlcConnection.read(AdsAbstra
ctPlcConnection.java:103)

        at
org.apache.plc4x.java.base.messages.DefaultPlcReadRequest.execute(DefaultPlc
ReadRequest.java:44)

        at
net.sytes.botg.ads.MyADSClient.executeReadRequest(MyADSClient.java:108)

        at
net.sytes.botg.ads.UnitTest_MyADSClient.test2(UnitTest_MyADSClient.java:60)

        at
net.sytes.botg.ads.UnitTest_MyADSClient.main(UnitTest_MyADSClient.java:44)

 

Could anybody offer some help? Am I constructing the item for the read
request correctly, what if I'm trying to read variables in a subroutine
let's say in the Project "1Achser" my PLC Project name is "SPSObject" and I
have a PRG block named "MainGUI", in there I have the variable "CurPos
[LREAL]", how would I conceive the addItem Method?  -->
builder.addItem("CurPos", "1Achser.SPSObject.MainGUI.CurPos:LReal")?

Anyhelp would be appreciated.

 

And by the way, I like the idea of PLC4X very much and love to contribute,
given that I can make it work for my setup :D

 

Best Regards

Jonas

 

Attachment: smime.p7s
Description: S/MIME cryptographic signature

Reply via email to