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:[email protected]]<https://www.noovelia.com> 462, rue des Forges, Trois-Rivières (Québec) G9A 2H5 CANADA noovelia.com<https://www.noovelia.com> [cid:[email protected]] ________________________________ De : Patrick Boisclair <[email protected]> Envoyé : 17 décembre 2020 09:59 À : [email protected] 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:[email protected]]<https://www.noovelia.com> 462, rue des Forges, Trois-Rivières (Québec) G9A 2H5 CANADA noovelia.com<https://www.noovelia.com> [cid:[email protected]] ________________________________ De : Christofer Dutz <[email protected]> Envoyé : 17 décembre 2020 09:45 À : [email protected] 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 <[email protected]> Gesendet: Donnerstag, 17. Dezember 2020 15:34 An: [email protected] 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:[email protected]]<https://www.noovelia.com/> 462, rue des Forges, Trois-Rivières (Québec) G9A 2H5 CANADA noovelia.com<https://www.noovelia.com> [cid:[email protected]]
