Hi Chris,

I think if you figured out how to setup your system to properly use the example 
here for Java
https://infosys.beckhoff.com/english.php?content=../content/1033/tcsample_java/html/tcjavatoads_sample01.html&id=
you've actually reached more than I did, so far

Right now I'm using a small C# application to read from ADS Server (described 
here 
https://infosys.beckhoff.com/english.php?content=../content/1033/tcsample_java/html/tcjavatoads_sample01.html&id=)
 and then in the same application pass the data on via UDP Client and on the 
same machine a Java Application runs a UDP Server to capture the ADS Data and 
do some business logic.
[VERY MESSY]
I can share my stuff, if it is of interest as soon as I debugged it.

But as you see, this is nothing I want to go to production with ... 

Cheers,
Jonas

-----Ursprüngliche Nachricht-----
Von: Christofer Dutz [mailto:christofer.d...@c-ware.de] 
Gesendet: Freitag, 31. Juli 2020 10:17
An: dev@plc4x.apache.org
Betreff: Re: How to compose Read requests for ADS Protocol with PLC4X?

Hi think i found it ...

I needed the Ads.dll itself ... of course that's not documented in the 
documentation ;-)


Chris



Am 31.07.20, 09:59 schrieb "Christofer Dutz" <christofer.d...@c-ware.de>:

    Hi Jonas,

    I think I can possibly help you now … as I worked on the new Beckhoff 
driver I finally got to working with the ADS protocol.
    I think the problem you are having is that the address you are using is 
simply not correct.

    The PLC doesn’t find an address called “BOOL1” … After discussing things 
with the Beckhoff Tech-Staff I learned, that you should address resources with 
symbolic addresses like:

    main.f_trigDateiGelesen.M:BOOL

    Please note that there seems to be differences between TwinCat2 and 
TwinCat3 devices regarding this symbolic address format. The older ones seem to 
simply start without the module name. Like: “.f_trigDateiGelesen.M:BOOL” (But I 
haven’t been able to verify this)

    The other option would be to use fixed addresses, like:

    0x0000f005/0x1a800000:BOOL

    Which is however considered bad practice, as adding one single byte to the 
PLC could ruin all of your addesses.

    Hope this helps a little more.

    Chris



    Von: "Hillenbrand, Jonas (wbk)" <jonas.hillenbr...@kit.edu>
    Antworten an: <dev@plc4x.apache.org>
    Datum: Mittwoch, 29. Juli 2020 um 11:25
    An: "dev@plc4x.apache.org" <dev@plc4x.apache.org>
    Betreff: How to compose Read requests for ADS Protocol with PLC4X?

    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$mapFields$3(AdsAbstractPlcConnection.java:184)
            at 
java.base/java.util.concurrent.ConcurrentHashMap.computeIfAbsent(ConcurrentHashMap.java:1708)
            at 
org.apache.plc4x.java.ads.connection.AdsAbstractPlcConnection.mapFields(AdsAbstractPlcConnection.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.java:195)
            at 
java.base/java.util.stream.ReferencePipeline$2$1.accept(ReferencePipeline.java:177)
            at 
java.base/java.util.LinkedList$LLSpliterator.forEachRemaining(LinkedList.java:1242)
            at 
java.base/java.util.stream.AbstractPipeline.copyInto(AbstractPipeline.java:484)
            at 
java.base/java.util.stream.ForEachOps$ForEachTask.compute(ForEachOps.java:290)
            at 
java.base/java.util.concurrent.CountedCompleter.exec(CountedCompleter.java:746)
            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(ForEachOps.java:173)
            at 
java.base/java.util.stream.AbstractPipeline.evaluate(AbstractPipeline.java:233)
            at 
java.base/java.util.stream.ReferencePipeline.forEach(ReferencePipeline.java:497)
            at 
org.apache.plc4x.java.ads.connection.AdsAbstractPlcConnection.mapFields(AdsAbstractPlcConnection.java:157)
            at 
org.apache.plc4x.java.ads.connection.AdsAbstractPlcConnection.read(AdsAbstractPlcConnection.java:103)
            at 
org.apache.plc4x.java.base.messages.DefaultPlcReadRequest.execute(DefaultPlcReadRequest.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