Re: Contributions with Access to PLC's

2020-07-31 Thread Christofer Dutz
Hi Turan,

and also welcome ... great to have you here :-)

There are generally a lot of ways you can contribute:
- Start using PLC4X drivers and report/fix issues you encounter
- Add features to drivers or improve existing drivers if we did things in a 
less-ideal way
- Implement new drivers If you have some hardware you would like to talk to but 
we haven't got any drivers for yet
- Bring PLC4X to new languages (I'm currently working on porting to C ... 
others were thinking of reinitiating the Python efforts)

Implementing drivers and porting to new languages definitely sounds like more 
work than it is, but we have created tooling for code-generation that takes 
care of most of the annoying parts of this.

If you want to get started with any particular thing, please tell us about it 
and we'll do our best to get you setup :-)

Chris



Am 30.07.20, 16:23 schrieb "Lukas Ott" :

Hi Ryan,

A warm welcome to PLC4X project.

There are several ways to contribute to PLC4X project.

If you are a developer checkout here:
https://plc4x.apache.org/developers/contributing.html

If you are a user then you may start here:
https://plc4x.apache.org/users/plc4j/gettingstarted.html and start
accessing you PLCs.
-> If you get errors please add Wireshark dumps to you issue and hand it in
here -> https://issues.apache.org/jira/projects/PLC4X/issues/


-> A good way to contribute is to improve the documentation for users e.g.
writing and helping to improve getting started etc.
-> We also have a Hands on Webinar here: https://youtu.be/MIp_0OcDTr4

So start testing and come back to mailing list (open issues, improve
documentation) and enjoy yourself and good Toddy coffee :D.

Again welcome to the PLX4X project.

Kind regards
Lukas


Am Do., 30. Juli 2020 um 15:58 Uhr schrieb Truran, Ryan S :

> What is the best way for me to contribute, I have access to multiple PLC
> Types, Allen Bradley, S7, Wago (Modbus), etc.
>
> Regards,
> Ryan Truran
> Controls Engineer
> Texas Instruments
>



Re: Reading Array of Int

2020-07-31 Thread Christofer Dutz
Hi Cesar,

if you fixed any issues in that branch, that are not related to 
publish-subscribe and alarms, it would be great if you could port that to 
develop.

Chris



Am 30.07.20, 17:34 schrieb "Cesar Garcia" :

Hi Stefano,

I have made several modifications to the branch for a 0.6.1 revision.

If you have the time to try it you can download it from here

https://github.com/glcj/plc4x/tree/s7alarm

and a number of examples here,

https://github.com/glcj/PLC4XS7Examples

What version of PLC do you have?

Like the rest of the team, I will order to help you if you find any problem.

Best regards,

El mié., 29 jul. 2020 a las 6:32, Stefano Bossi ()
escribió:

> Thanks Chris,
>
> yes definitely this is a workaround, I am experimenting and learning.
>
> I really appreciate your time on the investigation of the issue.
>
> Thanks,
> Stefano Bossi
>
>
>
> On 29/07/2020 12:08, Christofer Dutz wrote:
>
> Well that’s a workaround, but not a fix …
>
> We should focus on fixing this.
>
> I’ll investigate the issue as soon as I’m done with the Beckhoff ADS/AMS 
stuff …
>
> Perhaps Julian could find some time to investigate?
>
> Chris
>
>
>
> Von: Stefano Bossi  
> Antworten an:  
> Datum: Mittwoch, 29. Juli 2020 um 11:41
> An:  
> Betreff: Re: Reading Array of Int
>
>
> I have adopted a workaround reading all the INT variable separated.
>
> --connection-string 's7:tcp://192.168.1.192?controller-type=S7_1200' 
--field-addresses '%DB1:274.0:INT' '%DB1:276.0:INT' '%DB1:278.0:INT' 
'%DB1:280.0:INT'
>
> In this way on the wire you have:
> the query:
>
> Frame 296: 111 bytes on wire (888 bits), 111 bytes captured (888 bits) on 
interface utun2, id 0
>
> Null/Loopback
>
> Internet Protocol Version 4, Src: 192.168.100.4, Dst: 192.168.1.192
>
> Transmission Control Protocol, Src Port: 57188, Dst Port: 102, Seq: 48, 
Ack: 50, Len: 67
>
> TPKT, Version: 3, Length: 67
>
> ISO 8073/X.224 COTP Connection-Oriented Transport Protocol
>
> S7 Communication
>
> Header: (Job)
>
> Parameter: (Read Var)
>
> Function: Read Var (0x04)
>
> Item count: 4
>
> Item [1]: (DB 1.DBX 274.0 INT 1)
>
> Item [2]: (DB 1.DBX 276.0 INT 1)
>
> Item [3]: (DB 1.DBX 278.0 INT 1)
>
> Item [4]: (DB 1.DBX 280.0 INT 1)
>
> the answer:
>
> Frame 297: 89 bytes on wire (712 bits), 89 bytes captured (712 bits) on 
interface utun2, id 0
>
> Null/Loopback
>
> Internet Protocol Version 4, Src: 192.168.1.192, Dst: 192.168.100.4
>
> Transmission Control Protocol, Src Port: 102, Dst Port: 57188, Seq: 50, 
Ack: 115, Len: 45
>
> TPKT, Version: 3, Length: 45
>
> ISO 8073/X.224 COTP Connection-Oriented Transport Protocol
>
> S7 Communication
>
> Header: (Ack_Data)
>
> Parameter: (Read Var)
>
> Function: Read Var (0x04)
>
> Item count: 4
>
> Data
>
> Item [1]: (Success)
>
> Item [2]: (Success)
>
> Item [3]: (Success)
>
> Item [4]: (Success)
>
> [INFO ] 10:15:44.727 it.fox.datapicker.HelloPlc4x.printResponse() - 
Value[value-0]: 10
>
> [INFO ] 10:15:44.733 it.fox.datapicker.HelloPlc4x.printResponse() - 
Value[value-1]: 11
>
> [INFO ] 10:15:44.737 it.fox.datapicker.HelloPlc4x.printResponse() - 
Value[value-2]: 12
>
> [INFO ] 10:15:44.741 it.fox.datapicker.HelloPlc4x.printResponse() - 
Value[value-3]: 13
>
> Unfortunately my java knowledge are not so advanced to fix the bug in 
reading the array in a single command, anyway there’s a workaround.
>
> Hope this mail help some newbies like me to find the right way to read 
data from the PLC.
>
> Regards,
> Stefano
>
> On 28/07/2020 11:38, Stefano Bossi wrote:
>
> Dear plc4x forum,
>
> I have found a possible problem in reading an array of INT.
> I am using the HelloPlc4x app for testing and I am trying to read the 
field address: '%DB1:274.0:INT[3]'
>
> In the request, captured via wireShark I can see the query:
>
> Frame 3: 75 bytes on wire (600 bits), 75 bytes captured (600 bits) on 
interface utun2, id 0
>
> Null/Loopback
>
> Internet Protocol Version 4, Src: 192.168.100.4, Dst: 192.168.1.192
>
> Transmission Control Protocol, Src Port: 54543, Dst Port: 102, Seq: 1, 
Ack: 1, Len: 31
>
> TPKT, Version: 3, Length: 31
>
> ISO 8073/X.224 COTP Connection-Oriented Transport Protocol
>
> S7 Communication
>
> Header: (Job)
>
> Parameter: (Read Var)
>
> Function: Read Var (0x04)
>
>

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-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 
java.base/java.util.stream.ForEachOps$ForEach

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 
java.base/java.util.concurrent.CountedCompleter.exec(CountedCom

Re: Contributions with Access to PLC's

2020-07-31 Thread Truran, Ryan S
Hi Chris, 
My plan is to get a piece of equipment setup in my office so that I can begin 
testing the modbus driver to get a feel for the codebase. Then develop a couple 
drivers, maybe DNP3 or LonWorks. 

Is there a roadmap of drivers that need to be created? 

C would be nice, as we could then look at the usage in embedded systems, I’m 
actually in the process of trying to get a few custom drivers ported over to a 
gateway type solution for work. 

Regards,
Ryan Truran

Sent from my iPhone

> On Jul 31, 2020, at 02:41, Christofer Dutz  wrote:
> 
> Hi Turan,
> 
> and also welcome ... great to have you here :-)
> 
> There are generally a lot of ways you can contribute:
> - Start using PLC4X drivers and report/fix issues you encounter
> - Add features to drivers or improve existing drivers if we did things in a 
> less-ideal way
> - Implement new drivers If you have some hardware you would like to talk to 
> but we haven't got any drivers for yet
> - Bring PLC4X to new languages (I'm currently working on porting to C ... 
> others were thinking of reinitiating the Python efforts)
> 
> Implementing drivers and porting to new languages definitely sounds like more 
> work than it is, but we have created tooling for code-generation that takes 
> care of most of the annoying parts of this.
> 
> If you want to get started with any particular thing, please tell us about it 
> and we'll do our best to get you setup :-)
> 
> Chris
> 
> 
> 
> Am 30.07.20, 16:23 schrieb "Lukas Ott" :
> 
>Hi Ryan,
> 
>A warm welcome to PLC4X project.
> 
>There are several ways to contribute to PLC4X project.
> 
>If you are a developer checkout here:
>https://plc4x.apache.org/developers/contributing.html
> 
>If you are a user then you may start here:
>https://plc4x.apache.org/users/plc4j/gettingstarted.html and start
>accessing you PLCs.
>-> If you get errors please add Wireshark dumps to you issue and hand it in
>here -> https://issues.apache.org/jira/projects/PLC4X/issues/
>
> 
>-> A good way to contribute is to improve the documentation for users e.g.
>writing and helping to improve getting started etc.
>-> We also have a Hands on Webinar here: https://youtu.be/MIp_0OcDTr4
> 
>So start testing and come back to mailing list (open issues, improve
>documentation) and enjoy yourself and good Toddy coffee :D.
> 
>Again welcome to the PLX4X project.
> 
>Kind regards
>Lukas
> 
> 
>>Am Do., 30. Juli 2020 um 15:58 Uhr schrieb Truran, Ryan S 
>> >> :
>> 
>> What is the best way for me to contribute, I have access to multiple PLC
>> Types, Allen Bradley, S7, Wago (Modbus), etc.
>> 
>> Regards,
>> Ryan Truran
>> Controls Engineer
>> Texas Instruments
>> 
> 


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

2020-07-31 Thread Hillenbrand, Jonas (wbk)
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" :

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='', so

Re: Reading Array of Int

2020-07-31 Thread Stefano Bossi
Hi Julian,

sorry for the late reply. I am using the 0.7 version.

Thanks for your help,
Stefano

Il gio 30 lug 2020, 07:49 Julian Feinauer  ha
scritto:

> Hey Stefano, I will try to have a look later today. Are you using plc4x
> version 0.6 or 0.7?
>
> Thank you!
>
> Julian
>
> Holen Sie sich Outlook für Android
>
> 
> Von: Stefano Bossi 
> Gesendet: Mittwoch, 29. Juli 2020, 12:32
> An: dev@plc4x.apache.org; Christofer Dutz
> Betreff: Re: Reading Array of Int
>
> Thanks Chris,
>
> yes definitely this is a workaround, I am experimenting and learning.
>
> I really appreciate your time on the investigation of the issue.
>
> Thanks,
> Stefano Bossi
>
>
>
> On 29/07/2020 12:08, Christofer Dutz wrote:
>
> Well that’s a workaround, but not a fix …
>
> We should focus on fixing this.
>
> I’ll investigate the issue as soon as I’m done with the Beckhoff ADS/AMS
> stuff …
>
> Perhaps Julian could find some time to investigate?
>
> Chris
>
>
>
> Von: Stefano Bossi  stefano.bo...@gmail.com>
> Antworten an: 
> Datum: Mittwoch, 29. Juli 2020 um 11:41
> An: 
> Betreff: Re: Reading Array of Int
>
>
> I have adopted a workaround reading all the INT variable separated.
>
> --connection-string 's7:tcp://192.168.1.192?controller-type=S7_1200'
> --field-addresses '%DB1:274.0:INT' '%DB1:276.0:INT' '%DB1:278.0:INT'
> '%DB1:280.0:INT'
>
> In this way on the wire you have:
> the query:
>
> Frame 296: 111 bytes on wire (888 bits), 111 bytes captured (888 bits) on
> interface utun2, id 0
>
> Null/Loopback
>
> Internet Protocol Version 4, Src: 192.168.100.4, Dst: 192.168.1.192
>
> Transmission Control Protocol, Src Port: 57188, Dst Port: 102, Seq: 48,
> Ack: 50, Len: 67
>
> TPKT, Version: 3, Length: 67
>
> ISO 8073/X.224 COTP Connection-Oriented Transport Protocol
>
> S7 Communication
>
> Header: (Job)
>
> Parameter: (Read Var)
>
> Function: Read Var (0x04)
>
> Item count: 4
>
> Item [1]: (DB 1.DBX 274.0 INT 1)
>
> Item [2]: (DB 1.DBX 276.0 INT 1)
>
> Item [3]: (DB 1.DBX 278.0 INT 1)
>
> Item [4]: (DB 1.DBX 280.0 INT 1)
>
> the answer:
>
> Frame 297: 89 bytes on wire (712 bits), 89 bytes captured (712 bits) on
> interface utun2, id 0
>
> Null/Loopback
>
> Internet Protocol Version 4, Src: 192.168.1.192, Dst: 192.168.100.4
>
> Transmission Control Protocol, Src Port: 102, Dst Port: 57188, Seq: 50,
> Ack: 115, Len: 45
>
> TPKT, Version: 3, Length: 45
>
> ISO 8073/X.224 COTP Connection-Oriented Transport Protocol
>
> S7 Communication
>
> Header: (Ack_Data)
>
> Parameter: (Read Var)
>
> Function: Read Var (0x04)
>
> Item count: 4
>
> Data
>
> Item [1]: (Success)
>
> Item [2]: (Success)
>
> Item [3]: (Success)
>
> Item [4]: (Success)
>
> [INFO ] 10:15:44.727 it.fox.datapicker.HelloPlc4x.printResponse() -
> Value[value-0]: 10
>
> [INFO ] 10:15:44.733 it.fox.datapicker.HelloPlc4x.printResponse() -
> Value[value-1]: 11
>
> [INFO ] 10:15:44.737 it.fox.datapicker.HelloPlc4x.printResponse() -
> Value[value-2]: 12
>
> [INFO ] 10:15:44.741 it.fox.datapicker.HelloPlc4x.printResponse() -
> Value[value-3]: 13
>
> Unfortunately my java knowledge are not so advanced to fix the bug in
> reading the array in a single command, anyway there’s a workaround.
>
> Hope this mail help some newbies like me to find the right way to read
> data from the PLC.
>
> Regards,
> Stefano
>
> On 28/07/2020 11:38, Stefano Bossi wrote:
>
> Dear plc4x forum,
>
> I have found a possible problem in reading an array of INT.
> I am using the HelloPlc4x app for testing and I am trying to read the
> field address: '%DB1:274.0:INT[3]'
>
> In the request, captured via wireShark I can see the query:
>
> Frame 3: 75 bytes on wire (600 bits), 75 bytes captured (600 bits) on
> interface utun2, id 0
>
> Null/Loopback
>
> Internet Protocol Version 4, Src: 192.168.100.4, Dst: 192.168.1.192
>
> Transmission Control Protocol, Src Port: 54543, Dst Port: 102, Seq: 1,
> Ack: 1, Len: 31
>
> TPKT, Version: 3, Length: 31
>
> ISO 8073/X.224 COTP Connection-Oriented Transport Protocol
>
> S7 Communication
>
> Header: (Job)
>
> Parameter: (Read Var)
>
> Function: Read Var (0x04)
>
> Item count: 1
>
> Item [1]: (DB 1.DBX 274.0 INT 3)
>
> Variable specification: 0x12
>
> Length of following address specification: 10
>
> Syntax Id: S7ANY (0x10)
>
> Transport size: INT (5)
>
> Length: 3
>
> DB number: 1
>
> Area: Data blocks (DB) (0x84)
>
> Address: 0x000890
>
> and the response:
>
> Frame 4: 75 bytes on wire (600 bits), 75 bytes captured (600 bits) on
> interface utun2, id 0
>
> Null/Loopback
>
> Internet Protocol Version 4, Src: 192.168.1.192, Dst: 192.168.100.4
>
> Transmission Control Protocol, Src Port: 102, Dst Port: 54543, Seq: 1,
> Ack: 32, Len:

Re: Reading Array of Int

2020-07-31 Thread Cesar Garcia
Hi Chris.

With the 0.6.1 (Aka Frankenstein code :-)) I solved every problem that I
was finding to get to the handling of the subscription (Type handling,
optimization, asynchronous responses from the PLC, etc.).

J ... is helping me to incorporate the code to the development branch. I am
not a Git expert, and the last thing I want is to damage something jeje.

Also, all these points are documented in Jira (including the pcap files).

For my part, I am waiting next week to be able to install a VPN and give
access to the S7-300 / 400 equipment (physical) and the tests can be
finished.

Best regards,

El vie., 31 jul. 2020 a las 3:42, Christofer Dutz (<
christofer.d...@c-ware.de>) escribió:

> Hi Cesar,
>
> if you fixed any issues in that branch, that are not related to
> publish-subscribe and alarms, it would be great if you could port that to
> develop.
>
> Chris
>
>
>
> Am 30.07.20, 17:34 schrieb "Cesar Garcia" :
>
> Hi Stefano,
>
> I have made several modifications to the branch for a 0.6.1 revision.
>
> If you have the time to try it you can download it from here
>
> https://github.com/glcj/plc4x/tree/s7alarm
>
> and a number of examples here,
>
> https://github.com/glcj/PLC4XS7Examples
>
> What version of PLC do you have?
>
> Like the rest of the team, I will order to help you if you find any
> problem.
>
> Best regards,
>
> El mié., 29 jul. 2020 a las 6:32, Stefano Bossi (<
> stefano.bo...@gmail.com>)
> escribió:
>
> > Thanks Chris,
> >
> > yes definitely this is a workaround, I am experimenting and learning.
> >
> > I really appreciate your time on the investigation of the issue.
> >
> > Thanks,
> > Stefano Bossi
> >
> >
> >
> > On 29/07/2020 12:08, Christofer Dutz wrote:
> >
> > Well that’s a workaround, but not a fix …
> >
> > We should focus on fixing this.
> >
> > I’ll investigate the issue as soon as I’m done with the Beckhoff
> ADS/AMS stuff …
> >
> > Perhaps Julian could find some time to investigate?
> >
> > Chris
> >
> >
> >
> > Von: Stefano Bossi  <
> stefano.bo...@gmail.com>
> > Antworten an:  
> > Datum: Mittwoch, 29. Juli 2020 um 11:41
> > An:  
> > Betreff: Re: Reading Array of Int
> >
> >
> > I have adopted a workaround reading all the INT variable separated.
> >
> > --connection-string 's7:tcp://192.168.1.192?controller-type=S7_1200'
> --field-addresses '%DB1:274.0:INT' '%DB1:276.0:INT' '%DB1:278.0:INT'
> '%DB1:280.0:INT'
> >
> > In this way on the wire you have:
> > the query:
> >
> > Frame 296: 111 bytes on wire (888 bits), 111 bytes captured (888
> bits) on interface utun2, id 0
> >
> > Null/Loopback
> >
> > Internet Protocol Version 4, Src: 192.168.100.4, Dst: 192.168.1.192
> >
> > Transmission Control Protocol, Src Port: 57188, Dst Port: 102, Seq:
> 48, Ack: 50, Len: 67
> >
> > TPKT, Version: 3, Length: 67
> >
> > ISO 8073/X.224 COTP Connection-Oriented Transport Protocol
> >
> > S7 Communication
> >
> > Header: (Job)
> >
> > Parameter: (Read Var)
> >
> > Function: Read Var (0x04)
> >
> > Item count: 4
> >
> > Item [1]: (DB 1.DBX 274.0 INT 1)
> >
> > Item [2]: (DB 1.DBX 276.0 INT 1)
> >
> > Item [3]: (DB 1.DBX 278.0 INT 1)
> >
> > Item [4]: (DB 1.DBX 280.0 INT 1)
> >
> > the answer:
> >
> > Frame 297: 89 bytes on wire (712 bits), 89 bytes captured (712 bits)
> on interface utun2, id 0
> >
> > Null/Loopback
> >
> > Internet Protocol Version 4, Src: 192.168.1.192, Dst: 192.168.100.4
> >
> > Transmission Control Protocol, Src Port: 102, Dst Port: 57188, Seq:
> 50, Ack: 115, Len: 45
> >
> > TPKT, Version: 3, Length: 45
> >
> > ISO 8073/X.224 COTP Connection-Oriented Transport Protocol
> >
> > S7 Communication
> >
> > Header: (Ack_Data)
> >
> > Parameter: (Read Var)
> >
> > Function: Read Var (0x04)
> >
> > Item count: 4
> >
> > Data
> >
> > Item [1]: (Success)
> >
> > Item [2]: (Success)
> >
> > Item [3]: (Success)
> >
> > Item [4]: (Success)
> >
> > [INFO ] 10:15:44.727 it.fox.datapicker.HelloPlc4x.printResponse() -
> Value[value-0]: 10
> >
> > [INFO ] 10:15:44.733 it.fox.datapicker.HelloPlc4x.printResponse() -
> Value[value-1]: 11
> >
> > [INFO ] 10:15:44.737 it.fox.datapicker.HelloPlc4x.printResponse() -
> Value[value-2]: 12
> >
> > [INFO ] 10:15:44.741 it.fox.datapicker.HelloPlc4x.printResponse() -
> Value[value-3]: 13
> >
> > Unfortunately my java knowledge are not so advanced to fix the bug
> in reading the array in a single command, anyway there’s a workaround.
> >
> > Ho