Hello everyone,
Im getting this error from a connection with a Beckhoff connection (ADS).
org.apache.plc4x.java.api.exceptions.PlcRuntimeException:
java.util.concurrent.TimeoutException
at
org.apache.plc4x.java.ads.connection.AdsAbstractPlcConnection.getFromFuture(AdsAbstractPlcConnection.java:236)
at
org.apache.plc4x.java.ads.connection.AdsAbstractPlcConnection.lambda$mapFields$3(AdsAbstractPlcConnection.java:180)
at
java.base/java.util.concurrent.ConcurrentHashMap.computeIfAbsent(ConcurrentHashMap.java:1705)
at
org.apache.plc4x.java.ads.connection.AdsAbstractPlcConnection.mapFields(AdsAbstractPlcConnection.java:163)
Here is the Java code:
public class App {
public static void main(String[] args) throws PlcConnectionException {
PlcDriverManager driver = new PlcDriverManager();
try {
PlcConnection connection =
driver.getConnection("ads:tcp://10.10.11.77/5.62.206.200.1.1:851");
if (connection.isConnected()) {
System.out.println("CONNECTED");
if (connection.getMetadata().canRead()) {
System.out.println("CAN READ");
PlcReadRequest.Builder builder =
connection.readRequestBuilder();
builder.addItem("value-1", "MAIN.Rand_1:DINT");
PlcReadRequest request = builder.build();
PlcReadResponse response = request.execute().get();
}
}
} catch (Exception e) {
e.printStackTrace();
}
}
}
I tried with C# and the TwinCatAds.dll from beckhoff and it works.
public void Open()
{
try
{
tcClient.Connect("5.62.206.200.1.1", 851);
if (tcClient.IsConnected)
{
Console.WriteLine("CONNECTED");
BinRead = new BinaryReader(DataStream, Encoding.ASCII);
PlcVariables[0] = tcClient.AddDeviceNotification("MAIN.Rand_1",
DataStream, 0, 1, AdsTransMode.OnChange, 100, 0, null);
tcClient.AdsNotification += new
AdsNotificationEventHandler(OnNotification);
}
}
catch (Exception ex)
{
Console.WriteLine(ex.ToString());
}
}
private void OnNotification(object sender, AdsNotificationEventArgs e)
{
string strValue = string.Empty;
e.DataStream.Position = e.Offset;
if (e.NotificationHandle == PlcVariables[0])
{
strValue = BinRead.ReadInt16().ToString();
}
Console.WriteLine(strValue);
}
Im new with PLC4x and the Java world also [☹]
Can anyone points me what I miss or doing wrong ?
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]]
"Veuillez noter ma nouvelle adresse courriel. / Please note my new email
address."