You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@plc4x.apache.org by Patrick Boisclair <pb...@noovelia.com> on 2020/12/17 14:33:53 UTC

Beckhoff with ADS protocol (0.0.8-SNAPSHOT)

Hello everyone,


Im' able to connect to my beckhoff PLC, read a value, but sometimes the read just "hang". The code below works like half the time.

Some time, I run the program, it reads the value, sometimes it just hang on the "execute".


I dont know what Im doing wrong.

 PlcDriverManager driver = new PlcDriverManager();
        try {
            //
            PlcConnection connection = driver.getConnection(
                    "ads:tcp://10.10.11.77?sourceAmsNetId=172.29.48.1.1.1&sourceAmsPort=36&targetAmsNetId=5.62.206.200.1.1&targetAmsPort=851");


            if (connection.isConnected()) {
                if (connection.getMetadata().canRead()) {
                    PlcReadRequest.Builder builder = connection.readRequestBuilder();
                    builder.addItem("value-1", "MAIN.Rand_1:DINT");

                    PlcReadRequest request = builder.build();

                    request.execute().whenComplete((response, exception) -> {
                        Integer x = response.getInteger("value-1");
                        System.out.println("READ DONE: " + x.toString());
                    });

                }
            }
        } catch (Exception e) {
            e.printStackTrace();
        }

    }



Dong the same in C# with the TwinCAT dll from beckhoff works flawlessly:

        int handle = tcClient.CreateVariableHandle("MAIN.Rand_1");

        for (int i = 0; i < 1000000; i++) {
          tcClient.Read(handle, dataStream);
          var v = binRead.ReadInt32().ToString();
          Console.WriteLine(v);
          dataStream.Position = 0;
        }



Patrick Boisclair
Analyste - Programmeur senior / Senior Analyst Programmer

[cid:image6bad0c.PNG@bf5c5b51.4996672f]<https://www.noovelia.com>


462, rue des Forges, Trois-Rivières (Québec) G9A 2H5 CANADA
noovelia.com<https://www.noovelia.com>

[cid:image6e7b3f.PNG@14a68cd8.4394dd12]

AW: Beckhoff with ADS protocol (0.0.8-SNAPSHOT)

Posted by Christofer Dutz <ch...@c-ware.de>.
Hi,

In the past I had seen this happen (Especially as I got my new laptop)
For ADS you have to setup an ADS-Route … When trying to connect to my Beckhoff PLC for the first time, it also was hanging as I didn’t have a route configured.

Could you please confirm you have your routes setup so you can reach
5.62.206.200.1.1 from 172.29.48.1.1.1?

And a WireShark dump would help a lot.

Chris

Von: Patrick Boisclair <pb...@noovelia.com>
Gesendet: Donnerstag, 17. Dezember 2020 20:19
An: dev@plc4x.apache.org
Betreff: RE: Beckhoff with ADS protocol (0.0.8-SNAPSHOT)


Ty Stephen !

It makes total sense. And you're right the beckhoff plc offers a couple of ports...

Ty you very much, really appreciated !



I was wondering, is there a "time frame" or plan to do  "Notification" on the ADS driver ?



That would be awesome :)


Patrick Boisclair
Analyste - Programmeur senior / Senior Analyst Programmer

[cid:image681a8f.PNG@cf496751.42a05c57]<https://www.noovelia.com/>


462, rue des Forges, Trois-Rivières (Québec) G9A 2H5 CANADA
noovelia.com<https://www.noovelia.com>

[cid:image11cbfb.PNG@e0559bc5.4288d7b4]
________________________________
De : Stephen Snow <s4...@gmail.com>>
Envoyé : 17 décembre 2020 13:36
À : dev@plc4x.apache.org<ma...@plc4x.apache.org>
Objet : RE: Beckhoff with ADS protocol (0.0.8-SNAPSHOT)

Patrick,
Since you are trying to communicate with the PLC from two different PC
apps on the same network, you will invariably have errors such as you
experienced. This is largely due to the deterministic requirements of
the PLC and the limited timeframe allotted for such communication. Also
worth noting is the precendence of which comes first, and this comes
forward even more when you have a programming (ie PLC programming
software) terminal connected since the proprietary PLC programming
software often takes ownership of the connection and will bump other
connections as it suits. It was one of the reasons most brands have
multiple communication ports available to use.

Regards,
Stephen

On Thu, Dec 17, 2020 at 17:59, Patrick Boisclair
<pb...@noovelia.com>> wrote:
> Sorry I was actually not clear.
>
> Im running the PLC4X program from IntelliJ .
>
>
> When I upload the TwinCAT program into the beckhoff PLC and it runs
> from itself, it works.
>
> When I have Visual Studio with the TwinCAT program running from my PC
> (Connected through TwinCAT developer mode), the PLC4X programs hangs
> (still running it from IntelliJ).
>
>
> It just its cool to see the TwinCAT variables "live" fron
> VisualStudio while developping the PLC4X program that connects to it.
>
>
> Does it make sense ?
>
>
>
>
>
> Patrick Boisclair
> Analyste - Programmeur senior / Senior Analyst Programmer
>
>  <https://www.noovelia.com/>
>
>
> 462, rue des Forges, Trois-Rivières (Québec) G9A 2H5 CANADA
> noovelia.com <https://www.noovelia.com/>
>
>
> *De :* Christofer Dutz <ch...@c-ware.de>>
> *Envoyé :* 17 décembre 2020 12:28
> *À :* dev@plc4x.apache.org<ma...@plc4x.apache.org>
> *Objet :* AW: Beckhoff with ADS protocol (0.0.8-SNAPSHOT)
>
> Hi Patrick,
>
>  so was the problem actually a VisualStudio problem or something we
> can improve?
>
>  If you say: „PLC program only in the PLC itself“ … you’re
> not running the PLC4X program on a PLC? So you mean if you run the
> program from the commandline, it works and in VS it hangs?
>
>
>  Chris
>
>
>  Von: Patrick Boisclair <pb...@noovelia.com>>
>  Gesendet: Donnerstag, 17. Dezember 2020 17:23
>  An: dev@plc4x.apache.org<ma...@plc4x.apache.org>
>  Betreff: RE: Beckhoff with ADS protocol (0.0.8-SNAPSHOT)
>
>
>  Ok I found out what the problem is.
>
>
>
>  For a reason when the PLC program is running from Visual Studio
> (TwinCAT), for a reason with PLC4X it sometimes hangs.
>
>  If I shut down Visual Studio and run the PLC program only in the PLC
> itself.. works fine.
>
>
>
>
>
>
>  Patrick Boisclair
>  Analyste - Programmeur senior / Senior Analyst Programmer
>
>  [cid:image37a0ee.PNG@c424a83b.43945ee2]<https://www.noovelia.com/>
>
>
>  462, rue des Forges, Trois-Rivières (Québec) G9A 2H5 CANADA
>  noovelia.com<https://www.noovelia.com <https://www.noovelia.com/>>
>
>  [cid:image138bb4.PNG@cf1129fc.4582dcdc]
>  ________________________________
>  De : Patrick Boisclair
> <pb...@noovelia.com>>>
>  Envoyé : 17 décembre 2020 09:59
>  À : dev@plc4x.apache.org<ma...@plc4x.apache.org>>
>  Objet : RE: Beckhoff with ADS protocol (0.0.8-SNAPSHOT)
>
>
>  Hi Chris,
>
>
>
>  I'll try to see what I can find with wireshark and send the info on
> the Jira issue.
>
>
>
>
>  Patrick Boisclair
>  Analyste - Programmeur senior / Senior Analyst Programmer
>
>  [cid:image4523eb.PNG@2f3aa02d.45a60828]<https://www.noovelia.com/>
>
>
>  462, rue des Forges, Trois-Rivières (Québec) G9A 2H5 CANADA
>  noovelia.com<https://www.noovelia.com <https://www.noovelia.com/>>
>
>  [cid:image18b9f2.PNG@d05602cd.489d2dd3]
>  ________________________________
>  De : Christofer Dutz
> <ch...@c-ware.de>>>
>  Envoyé : 17 décembre 2020 09:45
>  À : dev@plc4x.apache.org<ma...@plc4x.apache.org>>
>  Objet : AW: Beckhoff with ADS protocol (0.0.8-SNAPSHOT)
>
>  Hi Patrick,
>
>  welcome to our list.
>
>  There is one big difference (if you are calling the code you posted
> in a loop):
>  Internally the driver automatically does the translation from a
> symbolic address to a handle and to use that handle to read and to
> give back the handle when closing the connection.
>
>  Perhaps if you run your loop just around this part:
>
>  request.execute().whenComplete((response, exception) -> {
>
>                          Integer x = response.getInteger("value-1");
>
>                          System.out.println("READ DONE: " +
> x.toString());
>
>                      });
>
>
>  Then it would be a similar scenario.
>
>  If this isn’t solving the problem, could you possibly do a
> WireShark recording oft hat communication and attach that to a Jira
> issue on: https://issues.apache.org/jira/projects/PLC4X/
> <https://issues.apache.org/jira/projects/PLC4X/>
>  This would be the best way to help us find and possibly resolve the
> issue.
>
>
>  Hope that helps,
>
>       Chris
>
>
>  Von: Patrick Boisclair
> <pb...@noovelia.com>>>
>  Gesendet: Donnerstag, 17. Dezember 2020 15:34
>  An: dev@plc4x.apache.org<ma...@plc4x.apache.org>>
>  Betreff: Beckhoff with ADS protocol (0.0.8-SNAPSHOT)
>
>
>  Hello everyone,
>
>
>
>  Im' able to connect to my beckhoff PLC, read a value, but sometimes
> the read just "hang". The code below works like half the time.
>
>  Some time, I run the program, it reads the value, sometimes it just
> hang on the "execute".
>
>
>
>  I dont know what Im doing wrong.
>
>   PlcDriverManager driver = new PlcDriverManager();
>
>          try {
>
>              //
>
>              PlcConnection connection = driver.getConnection(
>
>
> "ads:tcp://10.10.11.77?sourceAmsNetId=172.29.48.1.1.1&sourceAmsPort=36&targetAmsNetId=5.62.206.200.1.1&targetAmsPort=851");
>
>
>
>
>
>              if (connection.isConnected()) {
>
>                  if (connection.getMetadata().canRead()) {
>
>                      PlcReadRequest.Builder builder =
> connection.readRequestBuilder();
>
>                      builder.addItem("value-1", "MAIN.Rand_1:DINT");
>
>
>
>                      PlcReadRequest request = builder.build();
>
>
>
>                      request.execute().whenComplete((response,
> exception) -> {
>
>                          Integer x = response.getInteger("value-1");
>
>                          System.out.println("READ DONE: " +
> x.toString());
>
>                      });
>
>
>
>                  }
>
>              }
>
>          } catch (Exception e) {
>
>              e.printStackTrace();
>
>          }
>
>
>
>      }
>
>
>
>
>
>  Dong the same in C# with the TwinCAT dll from beckhoff works
> flawlessly:
>
>          int handle = tcClient.CreateVariableHandle("MAIN.Rand_1");
>
>          for (int i = 0; i < 1000000; i++) {
>            tcClient.Read(handle, dataStream);
>            var v = binRead.ReadInt32().ToString();
>            Console.WriteLine(v);
>            dataStream.Position = 0;
>          }
>
>
>
>  Patrick Boisclair
>  Analyste - Programmeur senior / Senior Analyst Programmer
>
>  [cid:image6bad0c.PNG@bf5c5b51.4996672f]<https://www.noovelia.com/>
>
>
>  462, rue des Forges, Trois-Rivières (Québec) G9A 2H5 CANADA
>  noovelia.com<https://www.noovelia.com <https://www.noovelia.com/>>
>
>  [cid:image6e7b3f.PNG@14a68cd8.4394dd12]

RE: Beckhoff with ADS protocol (0.0.8-SNAPSHOT)

Posted by Patrick Boisclair <pb...@noovelia.com>.
Ty Stephen !

It makes total sense. And you're right the beckhoff plc offers a couple of ports...

Ty you very much, really appreciated !


I was wondering, is there a "time frame" or plan to do  "Notification" on the ADS driver ?


That would be awesome :)



Patrick Boisclair
Analyste - Programmeur senior / Senior Analyst Programmer

[cid:image681a8f.PNG@cf496751.42a05c57]<https://www.noovelia.com>


462, rue des Forges, Trois-Rivières (Québec) G9A 2H5 CANADA
noovelia.com<https://www.noovelia.com>

[cid:image11cbfb.PNG@e0559bc5.4288d7b4]
________________________________
De : Stephen Snow <s4...@gmail.com>
Envoyé : 17 décembre 2020 13:36
À : dev@plc4x.apache.org
Objet : RE: Beckhoff with ADS protocol (0.0.8-SNAPSHOT)

Patrick,
Since you are trying to communicate with the PLC from two different PC
apps on the same network, you will invariably have errors such as you
experienced. This is largely due to the deterministic requirements of
the PLC and the limited timeframe allotted for such communication. Also
worth noting is the precendence of which comes first, and this comes
forward even more when you have a programming (ie PLC programming
software) terminal connected since the proprietary PLC programming
software often takes ownership of the connection and will bump other
connections as it suits. It was one of the reasons most brands have
multiple communication ports available to use.

Regards,
Stephen

On Thu, Dec 17, 2020 at 17:59, Patrick Boisclair
<pb...@noovelia.com> wrote:
> Sorry I was actually not clear.
>
> Im running the PLC4X program from IntelliJ .
>
>
> When I upload the TwinCAT program into the beckhoff PLC and it runs
> from itself, it works.
>
> When I have Visual Studio with the TwinCAT program running from my PC
> (Connected through TwinCAT developer mode), the PLC4X programs hangs
> (still running it from IntelliJ).
>
>
> It just its cool to see the TwinCAT variables "live" fron
> VisualStudio while developping the PLC4X program that connects to it.
>
>
> Does it make sense ?
>
>
>
>
>
> Patrick Boisclair
> Analyste - Programmeur senior / Senior Analyst Programmer
>
>  <https://www.noovelia.com/>
>
>
> 462, rue des Forges, Trois-Rivières (Québec) G9A 2H5 CANADA
> noovelia.com <https://www.noovelia.com/>
>
>
> *De :* Christofer Dutz <ch...@c-ware.de>
> *Envoyé :* 17 décembre 2020 12:28
> *À :* dev@plc4x.apache.org
> *Objet :* AW: Beckhoff with ADS protocol (0.0.8-SNAPSHOT)
>
> Hi Patrick,
>
>  so was the problem actually a VisualStudio problem or something we
> can improve?
>
>  If you say: „PLC program only in the PLC itself“ … you’re
> not running the PLC4X program on a PLC? So you mean if you run the
> program from the commandline, it works and in VS it hangs?
>
>
>  Chris
>
>
>  Von: Patrick Boisclair <pb...@noovelia.com>
>  Gesendet: Donnerstag, 17. Dezember 2020 17:23
>  An: dev@plc4x.apache.org
>  Betreff: RE: Beckhoff with ADS protocol (0.0.8-SNAPSHOT)
>
>
>  Ok I found out what the problem is.
>
>
>
>  For a reason when the PLC program is running from Visual Studio
> (TwinCAT), for a reason with PLC4X it sometimes hangs.
>
>  If I shut down Visual Studio and run the PLC program only in the PLC
> itself.. works fine.
>
>
>
>
>
>
>  Patrick Boisclair
>  Analyste - Programmeur senior / Senior Analyst Programmer
>
>  [cid:image37a0ee.PNG@c424a83b.43945ee2]<https://www.noovelia.com/>
>
>
>  462, rue des Forges, Trois-Rivières (Québec) G9A 2H5 CANADA
>  noovelia.com<https://www.noovelia.com <https://www.noovelia.com/>>
>
>  [cid:image138bb4.PNG@cf1129fc.4582dcdc]
>  ________________________________
>  De : Patrick Boisclair
> <pb...@noovelia.com>>
>  Envoyé : 17 décembre 2020 09:59
>  À : dev@plc4x.apache.org<ma...@plc4x.apache.org>
>  Objet : RE: Beckhoff with ADS protocol (0.0.8-SNAPSHOT)
>
>
>  Hi Chris,
>
>
>
>  I'll try to see what I can find with wireshark and send the info on
> the Jira issue.
>
>
>
>
>  Patrick Boisclair
>  Analyste - Programmeur senior / Senior Analyst Programmer
>
>  [cid:image4523eb.PNG@2f3aa02d.45a60828]<https://www.noovelia.com/>
>
>
>  462, rue des Forges, Trois-Rivières (Québec) G9A 2H5 CANADA
>  noovelia.com<https://www.noovelia.com <https://www.noovelia.com/>>
>
>  [cid:image18b9f2.PNG@d05602cd.489d2dd3]
>  ________________________________
>  De : Christofer Dutz
> <ch...@c-ware.de>>
>  Envoyé : 17 décembre 2020 09:45
>  À : dev@plc4x.apache.org<ma...@plc4x.apache.org>
>  Objet : AW: Beckhoff with ADS protocol (0.0.8-SNAPSHOT)
>
>  Hi Patrick,
>
>  welcome to our list.
>
>  There is one big difference (if you are calling the code you posted
> in a loop):
>  Internally the driver automatically does the translation from a
> symbolic address to a handle and to use that handle to read and to
> give back the handle when closing the connection.
>
>  Perhaps if you run your loop just around this part:
>
>  request.execute().whenComplete((response, exception) -> {
>
>                          Integer x = response.getInteger("value-1");
>
>                          System.out.println("READ DONE: " +
> x.toString());
>
>                      });
>
>
>  Then it would be a similar scenario.
>
>  If this isn’t solving the problem, could you possibly do a
> WireShark recording oft hat communication and attach that to a Jira
> issue on: https://issues.apache.org/jira/projects/PLC4X/
> <https://issues.apache.org/jira/projects/PLC4X/>
>  This would be the best way to help us find and possibly resolve the
> issue.
>
>
>  Hope that helps,
>
>       Chris
>
>
>  Von: Patrick Boisclair
> <pb...@noovelia.com>>
>  Gesendet: Donnerstag, 17. Dezember 2020 15:34
>  An: dev@plc4x.apache.org<ma...@plc4x.apache.org>
>  Betreff: Beckhoff with ADS protocol (0.0.8-SNAPSHOT)
>
>
>  Hello everyone,
>
>
>
>  Im' able to connect to my beckhoff PLC, read a value, but sometimes
> the read just "hang". The code below works like half the time.
>
>  Some time, I run the program, it reads the value, sometimes it just
> hang on the "execute".
>
>
>
>  I dont know what Im doing wrong.
>
>   PlcDriverManager driver = new PlcDriverManager();
>
>          try {
>
>              //
>
>              PlcConnection connection = driver.getConnection(
>
>
> "ads:tcp://10.10.11.77?sourceAmsNetId=172.29.48.1.1.1&sourceAmsPort=36&targetAmsNetId=5.62.206.200.1.1&targetAmsPort=851");
>
>
>
>
>
>              if (connection.isConnected()) {
>
>                  if (connection.getMetadata().canRead()) {
>
>                      PlcReadRequest.Builder builder =
> connection.readRequestBuilder();
>
>                      builder.addItem("value-1", "MAIN.Rand_1:DINT");
>
>
>
>                      PlcReadRequest request = builder.build();
>
>
>
>                      request.execute().whenComplete((response,
> exception) -> {
>
>                          Integer x = response.getInteger("value-1");
>
>                          System.out.println("READ DONE: " +
> x.toString());
>
>                      });
>
>
>
>                  }
>
>              }
>
>          } catch (Exception e) {
>
>              e.printStackTrace();
>
>          }
>
>
>
>      }
>
>
>
>
>
>  Dong the same in C# with the TwinCAT dll from beckhoff works
> flawlessly:
>
>          int handle = tcClient.CreateVariableHandle("MAIN.Rand_1");
>
>          for (int i = 0; i < 1000000; i++) {
>            tcClient.Read(handle, dataStream);
>            var v = binRead.ReadInt32().ToString();
>            Console.WriteLine(v);
>            dataStream.Position = 0;
>          }
>
>
>
>  Patrick Boisclair
>  Analyste - Programmeur senior / Senior Analyst Programmer
>
>  [cid:image6bad0c.PNG@bf5c5b51.4996672f]<https://www.noovelia.com/>
>
>
>  462, rue des Forges, Trois-Rivières (Québec) G9A 2H5 CANADA
>  noovelia.com<https://www.noovelia.com <https://www.noovelia.com/>>
>
>  [cid:image6e7b3f.PNG@14a68cd8.4394dd12]


RE: Beckhoff with ADS protocol (0.0.8-SNAPSHOT)

Posted by Stephen Snow <s4...@gmail.com>.
Patrick,
Since you are trying to communicate with the PLC from two different PC 
apps on the same network, you will invariably have errors such as you 
experienced. This is largely due to the deterministic requirements of 
the PLC and the limited timeframe allotted for such communication. Also 
worth noting is the precendence of which comes first, and this comes 
forward even more when you have a programming (ie PLC programming 
software) terminal connected since the proprietary PLC programming 
software often takes ownership of the connection and will bump other 
connections as it suits. It was one of the reasons most brands have 
multiple communication ports available to use.

Regards,
Stephen

On Thu, Dec 17, 2020 at 17:59, Patrick Boisclair 
<pb...@noovelia.com> wrote:
> Sorry I was actually not clear.
> 
> Im running the PLC4X program from IntelliJ .
> 
> 
> When I upload the TwinCAT program into the beckhoff PLC and it runs 
> from itself, it works.
> 
> When I have Visual Studio with the TwinCAT program running from my PC 
> (Connected through TwinCAT developer mode), the PLC4X programs hangs 
> (still running it from IntelliJ).
> 
> 
> It just its cool to see the TwinCAT variables "live" fron 
> VisualStudio while developping the PLC4X program that connects to it.
> 
> 
> Does it make sense ?
> 
> 
> 
> 
> 
> Patrick Boisclair
> Analyste - Programmeur senior / Senior Analyst Programmer
> 
>  <https://www.noovelia.com/>
> 
> 
> 462, rue des Forges, Trois-Rivières (Québec) G9A 2H5 CANADA
> noovelia.com <https://www.noovelia.com/>
> 
> 
> *De :* Christofer Dutz <ch...@c-ware.de>
> *Envoyé :* 17 décembre 2020 12:28
> *À :* dev@plc4x.apache.org
> *Objet :* AW: Beckhoff with ADS protocol (0.0.8-SNAPSHOT)
> 
> Hi Patrick,
> 
>  so was the problem actually a VisualStudio problem or something we 
> can improve?
> 
>  If you say: „PLC program only in the PLC itself“ … you’re 
> not running the PLC4X program on a PLC? So you mean if you run the 
> program from the commandline, it works and in VS it hangs?
> 
> 
>  Chris
> 
> 
>  Von: Patrick Boisclair <pb...@noovelia.com>
>  Gesendet: Donnerstag, 17. Dezember 2020 17:23
>  An: dev@plc4x.apache.org
>  Betreff: RE: Beckhoff with ADS protocol (0.0.8-SNAPSHOT)
> 
> 
>  Ok I found out what the problem is.
> 
> 
> 
>  For a reason when the PLC program is running from Visual Studio 
> (TwinCAT), for a reason with PLC4X it sometimes hangs.
> 
>  If I shut down Visual Studio and run the PLC program only in the PLC 
> itself.. works fine.
> 
> 
> 
> 
> 
> 
>  Patrick Boisclair
>  Analyste - Programmeur senior / Senior Analyst Programmer
> 
>  [cid:image37a0ee.PNG@c424a83b.43945ee2]<https://www.noovelia.com/>
> 
> 
>  462, rue des Forges, Trois-Rivières (Québec) G9A 2H5 CANADA
>  noovelia.com<https://www.noovelia.com <https://www.noovelia.com/>>
> 
>  [cid:image138bb4.PNG@cf1129fc.4582dcdc]
>  ________________________________
>  De : Patrick Boisclair 
> <pb...@noovelia.com>>
>  Envoyé : 17 décembre 2020 09:59
>  À : dev@plc4x.apache.org<ma...@plc4x.apache.org>
>  Objet : RE: Beckhoff with ADS protocol (0.0.8-SNAPSHOT)
> 
> 
>  Hi Chris,
> 
> 
> 
>  I'll try to see what I can find with wireshark and send the info on 
> the Jira issue.
> 
> 
> 
> 
>  Patrick Boisclair
>  Analyste - Programmeur senior / Senior Analyst Programmer
> 
>  [cid:image4523eb.PNG@2f3aa02d.45a60828]<https://www.noovelia.com/>
> 
> 
>  462, rue des Forges, Trois-Rivières (Québec) G9A 2H5 CANADA
>  noovelia.com<https://www.noovelia.com <https://www.noovelia.com/>>
> 
>  [cid:image18b9f2.PNG@d05602cd.489d2dd3]
>  ________________________________
>  De : Christofer Dutz 
> <ch...@c-ware.de>>
>  Envoyé : 17 décembre 2020 09:45
>  À : dev@plc4x.apache.org<ma...@plc4x.apache.org>
>  Objet : AW: Beckhoff with ADS protocol (0.0.8-SNAPSHOT)
> 
>  Hi Patrick,
> 
>  welcome to our list.
> 
>  There is one big difference (if you are calling the code you posted 
> in a loop):
>  Internally the driver automatically does the translation from a 
> symbolic address to a handle and to use that handle to read and to 
> give back the handle when closing the connection.
> 
>  Perhaps if you run your loop just around this part:
> 
>  request.execute().whenComplete((response, exception) -> {
> 
>                          Integer x = response.getInteger("value-1");
> 
>                          System.out.println("READ DONE: " + 
> x.toString());
> 
>                      });
> 
> 
>  Then it would be a similar scenario.
> 
>  If this isn’t solving the problem, could you possibly do a 
> WireShark recording oft hat communication and attach that to a Jira 
> issue on: https://issues.apache.org/jira/projects/PLC4X/ 
> <https://issues.apache.org/jira/projects/PLC4X/>
>  This would be the best way to help us find and possibly resolve the 
> issue.
> 
> 
>  Hope that helps,
> 
>       Chris
> 
> 
>  Von: Patrick Boisclair 
> <pb...@noovelia.com>>
>  Gesendet: Donnerstag, 17. Dezember 2020 15:34
>  An: dev@plc4x.apache.org<ma...@plc4x.apache.org>
>  Betreff: Beckhoff with ADS protocol (0.0.8-SNAPSHOT)
> 
> 
>  Hello everyone,
> 
> 
> 
>  Im' able to connect to my beckhoff PLC, read a value, but sometimes 
> the read just "hang". The code below works like half the time.
> 
>  Some time, I run the program, it reads the value, sometimes it just 
> hang on the "execute".
> 
> 
> 
>  I dont know what Im doing wrong.
> 
>   PlcDriverManager driver = new PlcDriverManager();
> 
>          try {
> 
>              //
> 
>              PlcConnection connection = driver.getConnection(
> 
>                      
> "ads:tcp://10.10.11.77?sourceAmsNetId=172.29.48.1.1.1&sourceAmsPort=36&targetAmsNetId=5.62.206.200.1.1&targetAmsPort=851");
> 
> 
> 
> 
> 
>              if (connection.isConnected()) {
> 
>                  if (connection.getMetadata().canRead()) {
> 
>                      PlcReadRequest.Builder builder = 
> connection.readRequestBuilder();
> 
>                      builder.addItem("value-1", "MAIN.Rand_1:DINT");
> 
> 
> 
>                      PlcReadRequest request = builder.build();
> 
> 
> 
>                      request.execute().whenComplete((response, 
> exception) -> {
> 
>                          Integer x = response.getInteger("value-1");
> 
>                          System.out.println("READ DONE: " + 
> x.toString());
> 
>                      });
> 
> 
> 
>                  }
> 
>              }
> 
>          } catch (Exception e) {
> 
>              e.printStackTrace();
> 
>          }
> 
> 
> 
>      }
> 
> 
> 
> 
> 
>  Dong the same in C# with the TwinCAT dll from beckhoff works 
> flawlessly:
> 
>          int handle = tcClient.CreateVariableHandle("MAIN.Rand_1");
> 
>          for (int i = 0; i < 1000000; i++) {
>            tcClient.Read(handle, dataStream);
>            var v = binRead.ReadInt32().ToString();
>            Console.WriteLine(v);
>            dataStream.Position = 0;
>          }
> 
> 
> 
>  Patrick Boisclair
>  Analyste - Programmeur senior / Senior Analyst Programmer
> 
>  [cid:image6bad0c.PNG@bf5c5b51.4996672f]<https://www.noovelia.com/>
> 
> 
>  462, rue des Forges, Trois-Rivières (Québec) G9A 2H5 CANADA
>  noovelia.com<https://www.noovelia.com <https://www.noovelia.com/>>
> 
>  [cid:image6e7b3f.PNG@14a68cd8.4394dd12]


RE: Beckhoff with ADS protocol (0.0.8-SNAPSHOT)

Posted by Patrick Boisclair <pb...@noovelia.com>.
Sorry I was actually not clear.

Im running the PLC4X program from IntelliJ .


When I upload the TwinCAT program into the beckhoff PLC and it runs from itself, it works.

When I have Visual Studio with the TwinCAT program running from my PC (Connected through TwinCAT developer mode), the PLC4X programs hangs (still running it from IntelliJ).


It just its cool to see the TwinCAT variables "live" fron VisualStudio while developping the PLC4X program that connects to it.


Does it make sense ?




Patrick Boisclair
Analyste - Programmeur senior / Senior Analyst Programmer

[cid:image6a34c9.PNG@894db193.449d3786]<https://www.noovelia.com>


462, rue des Forges, Trois-Rivières (Québec) G9A 2H5 CANADA
noovelia.com<https://www.noovelia.com>

[cid:image2c58a0.PNG@d30213a1.4c880232]
________________________________
De : Christofer Dutz <ch...@c-ware.de>
Envoyé : 17 décembre 2020 12:28
À : dev@plc4x.apache.org
Objet : AW: Beckhoff with ADS protocol (0.0.8-SNAPSHOT)

Hi Patrick,

so was the problem actually a VisualStudio problem or something we can improve?

If you say: „PLC program only in the PLC itself“ … you’re not running the PLC4X program on a PLC? So you mean if you run the program from the commandline, it works and in VS it hangs?


Chris


Von: Patrick Boisclair <pb...@noovelia.com>
Gesendet: Donnerstag, 17. Dezember 2020 17:23
An: dev@plc4x.apache.org
Betreff: RE: Beckhoff with ADS protocol (0.0.8-SNAPSHOT)


Ok I found out what the problem is.



For a reason when the PLC program is running from Visual Studio (TwinCAT), for a reason with PLC4X it sometimes hangs.

If I shut down Visual Studio and run the PLC program only in the PLC itself.. works fine.






Patrick Boisclair
Analyste - Programmeur senior / Senior Analyst Programmer

[cid:image37a0ee.PNG@c424a83b.43945ee2]<https://www.noovelia.com/>


462, rue des Forges, Trois-Rivières (Québec) G9A 2H5 CANADA
noovelia.com<https://www.noovelia.com>

[cid:image138bb4.PNG@cf1129fc.4582dcdc]
________________________________
De : Patrick Boisclair <pb...@noovelia.com>>
Envoyé : 17 décembre 2020 09:59
À : dev@plc4x.apache.org<ma...@plc4x.apache.org>
Objet : RE: Beckhoff with ADS protocol (0.0.8-SNAPSHOT)


Hi Chris,



I'll try to see what I can find with wireshark and send the info on the Jira issue.




Patrick Boisclair
Analyste - Programmeur senior / Senior Analyst Programmer

[cid:image4523eb.PNG@2f3aa02d.45a60828]<https://www.noovelia.com/>


462, rue des Forges, Trois-Rivières (Québec) G9A 2H5 CANADA
noovelia.com<https://www.noovelia.com>

[cid:image18b9f2.PNG@d05602cd.489d2dd3]
________________________________
De : Christofer Dutz <ch...@c-ware.de>>
Envoyé : 17 décembre 2020 09:45
À : dev@plc4x.apache.org<ma...@plc4x.apache.org>
Objet : AW: Beckhoff with ADS protocol (0.0.8-SNAPSHOT)

Hi Patrick,

welcome to our list.

There is one big difference (if you are calling the code you posted in a loop):
Internally the driver automatically does the translation from a symbolic address to a handle and to use that handle to read and to give back the handle when closing the connection.

Perhaps if you run your loop just around this part:

request.execute().whenComplete((response, exception) -> {

                        Integer x = response.getInteger("value-1");

                        System.out.println("READ DONE: " + x.toString());

                    });


Then it would be a similar scenario.

If this isn’t solving the problem, could you possibly do a WireShark recording oft hat communication and attach that to a Jira issue on: https://issues.apache.org/jira/projects/PLC4X/
This would be the best way to help us find and possibly resolve the issue.


Hope that helps,

     Chris


Von: Patrick Boisclair <pb...@noovelia.com>>
Gesendet: Donnerstag, 17. Dezember 2020 15:34
An: dev@plc4x.apache.org<ma...@plc4x.apache.org>
Betreff: Beckhoff with ADS protocol (0.0.8-SNAPSHOT)


Hello everyone,



Im' able to connect to my beckhoff PLC, read a value, but sometimes the read just "hang". The code below works like half the time.

Some time, I run the program, it reads the value, sometimes it just hang on the "execute".



I dont know what Im doing wrong.

 PlcDriverManager driver = new PlcDriverManager();

        try {

            //

            PlcConnection connection = driver.getConnection(

                    "ads:tcp://10.10.11.77?sourceAmsNetId=172.29.48.1.1.1&sourceAmsPort=36&targetAmsNetId=5.62.206.200.1.1&targetAmsPort=851");





            if (connection.isConnected()) {

                if (connection.getMetadata().canRead()) {

                    PlcReadRequest.Builder builder = connection.readRequestBuilder();

                    builder.addItem("value-1", "MAIN.Rand_1:DINT");



                    PlcReadRequest request = builder.build();



                    request.execute().whenComplete((response, exception) -> {

                        Integer x = response.getInteger("value-1");

                        System.out.println("READ DONE: " + x.toString());

                    });



                }

            }

        } catch (Exception e) {

            e.printStackTrace();

        }



    }





Dong the same in C# with the TwinCAT dll from beckhoff works flawlessly:

        int handle = tcClient.CreateVariableHandle("MAIN.Rand_1");

        for (int i = 0; i < 1000000; i++) {
          tcClient.Read(handle, dataStream);
          var v = binRead.ReadInt32().ToString();
          Console.WriteLine(v);
          dataStream.Position = 0;
        }



Patrick Boisclair
Analyste - Programmeur senior / Senior Analyst Programmer

[cid:image6bad0c.PNG@bf5c5b51.4996672f]<https://www.noovelia.com/>


462, rue des Forges, Trois-Rivières (Québec) G9A 2H5 CANADA
noovelia.com<https://www.noovelia.com>

[cid:image6e7b3f.PNG@14a68cd8.4394dd12]

AW: Beckhoff with ADS protocol (0.0.8-SNAPSHOT)

Posted by Christofer Dutz <ch...@c-ware.de>.
Hi Patrick,

so was the problem actually a VisualStudio problem or something we can improve?

If you say: „PLC program only in the PLC itself“ … you’re not running the PLC4X program on a PLC? So you mean if you run the program from the commandline, it works and in VS it hangs?


Chris


Von: Patrick Boisclair <pb...@noovelia.com>
Gesendet: Donnerstag, 17. Dezember 2020 17:23
An: dev@plc4x.apache.org
Betreff: RE: Beckhoff with ADS protocol (0.0.8-SNAPSHOT)


Ok I found out what the problem is.



For a reason when the PLC program is running from Visual Studio (TwinCAT), for a reason with PLC4X it sometimes hangs.

If I shut down Visual Studio and run the PLC program only in the PLC itself.. works fine.






Patrick Boisclair
Analyste - Programmeur senior / Senior Analyst Programmer

[cid:image37a0ee.PNG@c424a83b.43945ee2]<https://www.noovelia.com/>


462, rue des Forges, Trois-Rivières (Québec) G9A 2H5 CANADA
noovelia.com<https://www.noovelia.com>

[cid:image138bb4.PNG@cf1129fc.4582dcdc]
________________________________
De : Patrick Boisclair <pb...@noovelia.com>>
Envoyé : 17 décembre 2020 09:59
À : dev@plc4x.apache.org<ma...@plc4x.apache.org>
Objet : RE: Beckhoff with ADS protocol (0.0.8-SNAPSHOT)


Hi Chris,



I'll try to see what I can find with wireshark and send the info on the Jira issue.




Patrick Boisclair
Analyste - Programmeur senior / Senior Analyst Programmer

[cid:image4523eb.PNG@2f3aa02d.45a60828]<https://www.noovelia.com/>


462, rue des Forges, Trois-Rivières (Québec) G9A 2H5 CANADA
noovelia.com<https://www.noovelia.com>

[cid:image18b9f2.PNG@d05602cd.489d2dd3]
________________________________
De : Christofer Dutz <ch...@c-ware.de>>
Envoyé : 17 décembre 2020 09:45
À : dev@plc4x.apache.org<ma...@plc4x.apache.org>
Objet : AW: Beckhoff with ADS protocol (0.0.8-SNAPSHOT)

Hi Patrick,

welcome to our list.

There is one big difference (if you are calling the code you posted in a loop):
Internally the driver automatically does the translation from a symbolic address to a handle and to use that handle to read and to give back the handle when closing the connection.

Perhaps if you run your loop just around this part:

request.execute().whenComplete((response, exception) -> {

                        Integer x = response.getInteger("value-1");

                        System.out.println("READ DONE: " + x.toString());

                    });


Then it would be a similar scenario.

If this isn’t solving the problem, could you possibly do a WireShark recording oft hat communication and attach that to a Jira issue on: https://issues.apache.org/jira/projects/PLC4X/
This would be the best way to help us find and possibly resolve the issue.


Hope that helps,

     Chris


Von: Patrick Boisclair <pb...@noovelia.com>>
Gesendet: Donnerstag, 17. Dezember 2020 15:34
An: dev@plc4x.apache.org<ma...@plc4x.apache.org>
Betreff: Beckhoff with ADS protocol (0.0.8-SNAPSHOT)


Hello everyone,



Im' able to connect to my beckhoff PLC, read a value, but sometimes the read just "hang". The code below works like half the time.

Some time, I run the program, it reads the value, sometimes it just hang on the "execute".



I dont know what Im doing wrong.

 PlcDriverManager driver = new PlcDriverManager();

        try {

            //

            PlcConnection connection = driver.getConnection(

                    "ads:tcp://10.10.11.77?sourceAmsNetId=172.29.48.1.1.1&sourceAmsPort=36&targetAmsNetId=5.62.206.200.1.1&targetAmsPort=851");





            if (connection.isConnected()) {

                if (connection.getMetadata().canRead()) {

                    PlcReadRequest.Builder builder = connection.readRequestBuilder();

                    builder.addItem("value-1", "MAIN.Rand_1:DINT");



                    PlcReadRequest request = builder.build();



                    request.execute().whenComplete((response, exception) -> {

                        Integer x = response.getInteger("value-1");

                        System.out.println("READ DONE: " + x.toString());

                    });



                }

            }

        } catch (Exception e) {

            e.printStackTrace();

        }



    }





Dong the same in C# with the TwinCAT dll from beckhoff works flawlessly:

        int handle = tcClient.CreateVariableHandle("MAIN.Rand_1");

        for (int i = 0; i < 1000000; i++) {
          tcClient.Read(handle, dataStream);
          var v = binRead.ReadInt32().ToString();
          Console.WriteLine(v);
          dataStream.Position = 0;
        }



Patrick Boisclair
Analyste - Programmeur senior / Senior Analyst Programmer

[cid:image6bad0c.PNG@bf5c5b51.4996672f]<https://www.noovelia.com/>


462, rue des Forges, Trois-Rivières (Québec) G9A 2H5 CANADA
noovelia.com<https://www.noovelia.com>

[cid:image6e7b3f.PNG@14a68cd8.4394dd12]

RE: Beckhoff with ADS protocol (0.0.8-SNAPSHOT)

Posted by Patrick Boisclair <pb...@noovelia.com>.
Ok I found out what the problem is.


For a reason when the PLC program is running from Visual Studio (TwinCAT), for a reason with PLC4X it sometimes hangs.

If I shut down Visual Studio and run the PLC program only in the PLC itself.. works fine.




Patrick Boisclair
Analyste - Programmeur senior / Senior Analyst Programmer

[cid:image37a0ee.PNG@c424a83b.43945ee2]<https://www.noovelia.com>


462, rue des Forges, Trois-Rivières (Québec) G9A 2H5 CANADA
noovelia.com<https://www.noovelia.com>

[cid:image138bb4.PNG@cf1129fc.4582dcdc]
________________________________
De : Patrick Boisclair <pb...@noovelia.com>
Envoyé : 17 décembre 2020 09:59
À : dev@plc4x.apache.org
Objet : RE: Beckhoff with ADS protocol (0.0.8-SNAPSHOT)


Hi Chris,


I'll try to see what I can find with wireshark and send the info on the Jira issue.




Patrick Boisclair
Analyste - Programmeur senior / Senior Analyst Programmer

[cid:image4523eb.PNG@2f3aa02d.45a60828]<https://www.noovelia.com>


462, rue des Forges, Trois-Rivières (Québec) G9A 2H5 CANADA
noovelia.com<https://www.noovelia.com>

[cid:image18b9f2.PNG@d05602cd.489d2dd3]
________________________________
De : Christofer Dutz <ch...@c-ware.de>
Envoyé : 17 décembre 2020 09:45
À : dev@plc4x.apache.org
Objet : AW: Beckhoff with ADS protocol (0.0.8-SNAPSHOT)

Hi Patrick,

welcome to our list.

There is one big difference (if you are calling the code you posted in a loop):
Internally the driver automatically does the translation from a symbolic address to a handle and to use that handle to read and to give back the handle when closing the connection.

Perhaps if you run your loop just around this part:

request.execute().whenComplete((response, exception) -> {

                        Integer x = response.getInteger("value-1");

                        System.out.println("READ DONE: " + x.toString());

                    });


Then it would be a similar scenario.

If this isn’t solving the problem, could you possibly do a WireShark recording oft hat communication and attach that to a Jira issue on: https://issues.apache.org/jira/projects/PLC4X/
This would be the best way to help us find and possibly resolve the issue.


Hope that helps,

     Chris


Von: Patrick Boisclair <pb...@noovelia.com>
Gesendet: Donnerstag, 17. Dezember 2020 15:34
An: dev@plc4x.apache.org
Betreff: Beckhoff with ADS protocol (0.0.8-SNAPSHOT)


Hello everyone,



Im' able to connect to my beckhoff PLC, read a value, but sometimes the read just "hang". The code below works like half the time.

Some time, I run the program, it reads the value, sometimes it just hang on the "execute".



I dont know what Im doing wrong.

 PlcDriverManager driver = new PlcDriverManager();

        try {

            //

            PlcConnection connection = driver.getConnection(

                    "ads:tcp://10.10.11.77?sourceAmsNetId=172.29.48.1.1.1&sourceAmsPort=36&targetAmsNetId=5.62.206.200.1.1&targetAmsPort=851");





            if (connection.isConnected()) {

                if (connection.getMetadata().canRead()) {

                    PlcReadRequest.Builder builder = connection.readRequestBuilder();

                    builder.addItem("value-1", "MAIN.Rand_1:DINT");



                    PlcReadRequest request = builder.build();



                    request.execute().whenComplete((response, exception) -> {

                        Integer x = response.getInteger("value-1");

                        System.out.println("READ DONE: " + x.toString());

                    });



                }

            }

        } catch (Exception e) {

            e.printStackTrace();

        }



    }





Dong the same in C# with the TwinCAT dll from beckhoff works flawlessly:

        int handle = tcClient.CreateVariableHandle("MAIN.Rand_1");

        for (int i = 0; i < 1000000; i++) {
          tcClient.Read(handle, dataStream);
          var v = binRead.ReadInt32().ToString();
          Console.WriteLine(v);
          dataStream.Position = 0;
        }



Patrick Boisclair
Analyste - Programmeur senior / Senior Analyst Programmer

[cid:image6bad0c.PNG@bf5c5b51.4996672f]<https://www.noovelia.com/>


462, rue des Forges, Trois-Rivières (Québec) G9A 2H5 CANADA
noovelia.com<https://www.noovelia.com>

[cid:image6e7b3f.PNG@14a68cd8.4394dd12]

RE: Beckhoff with ADS protocol (0.0.8-SNAPSHOT)

Posted by Patrick Boisclair <pb...@noovelia.com>.
Hi Chris,


I'll try to see what I can find with wireshark and send the info on the Jira issue.




Patrick Boisclair
Analyste - Programmeur senior / Senior Analyst Programmer

[cid:image4523eb.PNG@2f3aa02d.45a60828]<https://www.noovelia.com>


462, rue des Forges, Trois-Rivières (Québec) G9A 2H5 CANADA
noovelia.com<https://www.noovelia.com>

[cid:image18b9f2.PNG@d05602cd.489d2dd3]
________________________________
De : Christofer Dutz <ch...@c-ware.de>
Envoyé : 17 décembre 2020 09:45
À : dev@plc4x.apache.org
Objet : AW: Beckhoff with ADS protocol (0.0.8-SNAPSHOT)

Hi Patrick,

welcome to our list.

There is one big difference (if you are calling the code you posted in a loop):
Internally the driver automatically does the translation from a symbolic address to a handle and to use that handle to read and to give back the handle when closing the connection.

Perhaps if you run your loop just around this part:

request.execute().whenComplete((response, exception) -> {

                        Integer x = response.getInteger("value-1");

                        System.out.println("READ DONE: " + x.toString());

                    });


Then it would be a similar scenario.

If this isn’t solving the problem, could you possibly do a WireShark recording oft hat communication and attach that to a Jira issue on: https://issues.apache.org/jira/projects/PLC4X/
This would be the best way to help us find and possibly resolve the issue.


Hope that helps,

     Chris


Von: Patrick Boisclair <pb...@noovelia.com>
Gesendet: Donnerstag, 17. Dezember 2020 15:34
An: dev@plc4x.apache.org
Betreff: Beckhoff with ADS protocol (0.0.8-SNAPSHOT)


Hello everyone,



Im' able to connect to my beckhoff PLC, read a value, but sometimes the read just "hang". The code below works like half the time.

Some time, I run the program, it reads the value, sometimes it just hang on the "execute".



I dont know what Im doing wrong.

 PlcDriverManager driver = new PlcDriverManager();

        try {

            //

            PlcConnection connection = driver.getConnection(

                    "ads:tcp://10.10.11.77?sourceAmsNetId=172.29.48.1.1.1&sourceAmsPort=36&targetAmsNetId=5.62.206.200.1.1&targetAmsPort=851");





            if (connection.isConnected()) {

                if (connection.getMetadata().canRead()) {

                    PlcReadRequest.Builder builder = connection.readRequestBuilder();

                    builder.addItem("value-1", "MAIN.Rand_1:DINT");



                    PlcReadRequest request = builder.build();



                    request.execute().whenComplete((response, exception) -> {

                        Integer x = response.getInteger("value-1");

                        System.out.println("READ DONE: " + x.toString());

                    });



                }

            }

        } catch (Exception e) {

            e.printStackTrace();

        }



    }





Dong the same in C# with the TwinCAT dll from beckhoff works flawlessly:

        int handle = tcClient.CreateVariableHandle("MAIN.Rand_1");

        for (int i = 0; i < 1000000; i++) {
          tcClient.Read(handle, dataStream);
          var v = binRead.ReadInt32().ToString();
          Console.WriteLine(v);
          dataStream.Position = 0;
        }



Patrick Boisclair
Analyste - Programmeur senior / Senior Analyst Programmer

[cid:image6bad0c.PNG@bf5c5b51.4996672f]<https://www.noovelia.com/>


462, rue des Forges, Trois-Rivières (Québec) G9A 2H5 CANADA
noovelia.com<https://www.noovelia.com>

[cid:image6e7b3f.PNG@14a68cd8.4394dd12]

RE: Beckhoff with ADS protocol (0.0.8-SNAPSHOT)

Posted by Patrick Boisclair <pb...@noovelia.com>.
Its not even in a loop in the JAVA code.

Just start the program., hangs half the time.


Trying to figure out what im doing wrong.


I tried the loop like this:


            for (int u = 0; u < 10; u++) {
                        request.execute().whenComplete((response, exception) -> {
                            Integer x = response.getInteger("value-1");
                            System.out.println("READ DONE: " + x.toString());
                        });
                    }


It never goes to 10 reads before hanging. (sometimes 0 read, sometimes 2, sometimes 7...)


Patrick Boisclair
Analyste - Programmeur senior / Senior Analyst Programmer

[cid:image1d58dc.PNG@aae18095.468754d4]<https://www.noovelia.com>


462, rue des Forges, Trois-Rivières (Québec) G9A 2H5 CANADA
noovelia.com<https://www.noovelia.com>

[cid:image533811.PNG@d7ab3225.49b7ef6e]
________________________________
De : Christofer Dutz <ch...@c-ware.de>
Envoyé : 17 décembre 2020 09:45
À : dev@plc4x.apache.org
Objet : AW: Beckhoff with ADS protocol (0.0.8-SNAPSHOT)

Hi Patrick,

welcome to our list.

There is one big difference (if you are calling the code you posted in a loop):
Internally the driver automatically does the translation from a symbolic address to a handle and to use that handle to read and to give back the handle when closing the connection.

Perhaps if you run your loop just around this part:

request.execute().whenComplete((response, exception) -> {

                        Integer x = response.getInteger("value-1");

                        System.out.println("READ DONE: " + x.toString());

                    });


Then it would be a similar scenario.

If this isn’t solving the problem, could you possibly do a WireShark recording oft hat communication and attach that to a Jira issue on: https://issues.apache.org/jira/projects/PLC4X/
This would be the best way to help us find and possibly resolve the issue.


Hope that helps,

     Chris


Von: Patrick Boisclair <pb...@noovelia.com>
Gesendet: Donnerstag, 17. Dezember 2020 15:34
An: dev@plc4x.apache.org
Betreff: Beckhoff with ADS protocol (0.0.8-SNAPSHOT)


Hello everyone,



Im' able to connect to my beckhoff PLC, read a value, but sometimes the read just "hang". The code below works like half the time.

Some time, I run the program, it reads the value, sometimes it just hang on the "execute".



I dont know what Im doing wrong.

 PlcDriverManager driver = new PlcDriverManager();

        try {

            //

            PlcConnection connection = driver.getConnection(

                    "ads:tcp://10.10.11.77?sourceAmsNetId=172.29.48.1.1.1&sourceAmsPort=36&targetAmsNetId=5.62.206.200.1.1&targetAmsPort=851");





            if (connection.isConnected()) {

                if (connection.getMetadata().canRead()) {

                    PlcReadRequest.Builder builder = connection.readRequestBuilder();

                    builder.addItem("value-1", "MAIN.Rand_1:DINT");



                    PlcReadRequest request = builder.build();



                    request.execute().whenComplete((response, exception) -> {

                        Integer x = response.getInteger("value-1");

                        System.out.println("READ DONE: " + x.toString());

                    });



                }

            }

        } catch (Exception e) {

            e.printStackTrace();

        }



    }





Dong the same in C# with the TwinCAT dll from beckhoff works flawlessly:

        int handle = tcClient.CreateVariableHandle("MAIN.Rand_1");

        for (int i = 0; i < 1000000; i++) {
          tcClient.Read(handle, dataStream);
          var v = binRead.ReadInt32().ToString();
          Console.WriteLine(v);
          dataStream.Position = 0;
        }



Patrick Boisclair
Analyste - Programmeur senior / Senior Analyst Programmer

[cid:image6bad0c.PNG@bf5c5b51.4996672f]<https://www.noovelia.com/>


462, rue des Forges, Trois-Rivières (Québec) G9A 2H5 CANADA
noovelia.com<https://www.noovelia.com>

[cid:image6e7b3f.PNG@14a68cd8.4394dd12]

AW: Beckhoff with ADS protocol (0.0.8-SNAPSHOT)

Posted by Christofer Dutz <ch...@c-ware.de>.
Hi Patrick,

welcome to our list.

There is one big difference (if you are calling the code you posted in a loop):
Internally the driver automatically does the translation from a symbolic address to a handle and to use that handle to read and to give back the handle when closing the connection.

Perhaps if you run your loop just around this part:

request.execute().whenComplete((response, exception) -> {

                        Integer x = response.getInteger("value-1");

                        System.out.println("READ DONE: " + x.toString());

                    });


Then it would be a similar scenario.

If this isn’t solving the problem, could you possibly do a WireShark recording oft hat communication and attach that to a Jira issue on: https://issues.apache.org/jira/projects/PLC4X/
This would be the best way to help us find and possibly resolve the issue.


Hope that helps,

     Chris


Von: Patrick Boisclair <pb...@noovelia.com>
Gesendet: Donnerstag, 17. Dezember 2020 15:34
An: dev@plc4x.apache.org
Betreff: Beckhoff with ADS protocol (0.0.8-SNAPSHOT)


Hello everyone,



Im' able to connect to my beckhoff PLC, read a value, but sometimes the read just "hang". The code below works like half the time.

Some time, I run the program, it reads the value, sometimes it just hang on the "execute".



I dont know what Im doing wrong.

 PlcDriverManager driver = new PlcDriverManager();

        try {

            //

            PlcConnection connection = driver.getConnection(

                    "ads:tcp://10.10.11.77?sourceAmsNetId=172.29.48.1.1.1&sourceAmsPort=36&targetAmsNetId=5.62.206.200.1.1&targetAmsPort=851");





            if (connection.isConnected()) {

                if (connection.getMetadata().canRead()) {

                    PlcReadRequest.Builder builder = connection.readRequestBuilder();

                    builder.addItem("value-1", "MAIN.Rand_1:DINT");



                    PlcReadRequest request = builder.build();



                    request.execute().whenComplete((response, exception) -> {

                        Integer x = response.getInteger("value-1");

                        System.out.println("READ DONE: " + x.toString());

                    });



                }

            }

        } catch (Exception e) {

            e.printStackTrace();

        }



    }





Dong the same in C# with the TwinCAT dll from beckhoff works flawlessly:

        int handle = tcClient.CreateVariableHandle("MAIN.Rand_1");

        for (int i = 0; i < 1000000; i++) {
          tcClient.Read(handle, dataStream);
          var v = binRead.ReadInt32().ToString();
          Console.WriteLine(v);
          dataStream.Position = 0;
        }



Patrick Boisclair
Analyste - Programmeur senior / Senior Analyst Programmer

[cid:image6bad0c.PNG@bf5c5b51.4996672f]<https://www.noovelia.com/>


462, rue des Forges, Trois-Rivières (Québec) G9A 2H5 CANADA
noovelia.com<https://www.noovelia.com>

[cid:image6e7b3f.PNG@14a68cd8.4394dd12]