I used to test PLC4X-ADS with below code:
https://gist.github.com/splatch/7a886f76ee2482a77b501cb07fd238ae

If you have ADS device then you need to setup ADS routes first. I did it
with Beckhoff tools. It doesn't work with linux out of the box, hence
you can also test pyads in above gist.

Cheers,
Łukasz


On 30.07.2020 10:58, Hillenbrand, Jonas (wbk) wrote:
> Thanks Chris,
> 
> I'm working with PLC4X 0.6.0.
> 
> If you need any other information just let me know.
> 
> Thanks in advance for your efforts.
> 
> Kind Regards
> Jonas
> 
> -----Ursprüngliche Nachricht-----
> Von: Christofer Dutz [mailto:christofer.d...@c-ware.de] 
> Gesendet: Mittwoch, 29. Juli 2020 11:33
> An: dev@plc4x.apache.org
> Betreff: Re: How to compose Read requests for ADS Protocol with PLC4X?
> 
> Hi Jonas and welcome to the PLC4X project :-)
> 
> I’ll do my best to help you with your setup … first … please let me ask you 
> which version of PLC4X you are using?
> I’m asking cause we deleted and replaced ALL drivers from 0.6.0 and replaced 
> them in 0.7.0 and beyond with ones generated by our in-house framework.
> 
> Unfortunately I have seen that the migration of the Beckhoff drivers was 
> never finished, but the person doing it disappeared.
> 
> I will do my best to pick up the ball and finish this asap … even if I 
> actually don’t have the time to do it, the feeling of having this important 
> driver un-finished is worse than keeping my deadlines ;-)
> 
> 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
> 

Reply via email to