Re: How to compose Read requests for ADS Protocol with PLC4X?

2020-08-01 Thread Christofer Dutz
Hi Jonas,

In the end I managed to reverse engineer the missing parts with some captures I 
named to create and the documentation on the website and used that to extend 
what e had and am currently working on finishing the ads driver.

It'll probably take another few days, but I'm hopeful, that it'll be finished 
soon.

Then some testing would be highly valuable to us.

Chris


Von: Hillenbrand, Jonas (wbk) 
Gesendet: Freitag, 31. Juli 2020 13:36
An: dev@plc4x.apache.org 
Betreff: AW: How to compose Read requests for ADS Protocol with PLC4X?

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=
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=)
 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" :

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:

0xf005/0x1a80: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)" 
Antworten an: 
Datum: Mittwoch, 29. Juli 2020 um 11:25
An: "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

Re: How to compose Read requests for ADS Protocol with PLC4X?

2020-07-31 Thread Christofer Dutz
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" :

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:

0xf005/0x1a80: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)" 
Antworten an: 
Datum: Mittwoch, 29. Juli 2020 um 11:25
An: "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 

Re: How to compose Read requests for ADS Protocol with PLC4X?

2020-07-31 Thread Christofer Dutz
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:

0xf005/0x1a80: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)" 
Antworten an: 
Datum: Mittwoch, 29. Juli 2020 um 11:25
An: "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 

Re: How to compose Read requests for ADS Protocol with PLC4X?

2020-07-31 Thread Christofer Dutz
Hi Jonas,

could you perhaps help me? I had several chats (real ones with a phone and 
zoom) with the folks from Beckhoff yesterday.
Turns out the ADS Spec doesn't describe so-called SUM requests, where you can 
read/write multiple addresses in one request.
In order to generate some traffic with these features, I wanted to use the 
Beckhoff Java driver to produce some traffic.

Unfortunately I seem to be unable to get the Java driver to work as the DLL is 
missing stuff ... what did you do to set it up?

Chris



Am 30.07.20, 23:44 schrieb "Łukasz Dywicki" :

I believe so, it also gives you possiblity to run under linux and other
embedded devices in secure fashion. :-)

If you can use wireshark take a look if your requests are coming out.
For me they were sent but they never got an answer. This is clear
indication that you are missing an ADS route.

Cheers,
Łukasz

On 30.07.2020 23:22, Hillenbrand, Jonas (wbk) wrote:
> Thanks Lukasz,
> 
> 
> I will test your code...
> 
> 
> Meanwhile I got sth. working with a ADS-TCP-Bridge from C# to Java for 
logging data from my Beckhoff CPU (using the .NET Api dll from Beckhoff), but 
PLC4X is the better choice if I can make it work in plane Java!
> 
> 
> Greets
> 
> Jonas
> 
> 
> Von: Łukasz Dywicki 
> Gesendet: Donnerstag, 30. Juli 2020 22:53:07
> An: dev@plc4x.apache.org; Hillenbrand, Jonas (wbk)
> Betreff: Re: AW: How to compose Read requests for ADS Protocol with PLC4X?
> 
> 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)"  Antworten 
an: 
>> Datum: Mittwoch, 29. Juli 2020 um 11:25
>> An: "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;
>> }
>>   

Re: How to compose Read requests for ADS Protocol with PLC4X?

2020-07-29 Thread Christofer Dutz
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)" 
Antworten an: 
Datum: Mittwoch, 29. Juli 2020 um 11:25
An: "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