Hi,
I’m trying to read a value from an Siemens S7-1200 PLC). This is my first
project using the S7 protocol and plc4x. When I try to read a value the read
request is not being executed (I also do not receive an error message or
timeout). Would this be the normal behaviour when the field address is wrong?
I’m out of ideas how to trace this down. Any hints would be highly appreciated.
This is the simple program I created:
String url =
"s7://172.3.4.5:102?local-rack=0&local-slot=1&remote-rack=0&remote-slot=1&controller-type=S7_1200
<s7://172.3.4.5:102?local-rack=0&local-slot=1&remote-rack=0&remote-slot=1&controller-type=S7_1200>";
PlcDriverManager manager = new PlcDriverManager();
PlcConnection connection = manager.getConnection(url);
boolean isConnected = connection.isConnected();
boolean canRead = connection.getMetadata().canRead();
System.out.println(isConnected); // prints true
System.out.println(canRead); // prints true
String field = "%DB20:DBX05.0:BOOL";
PlcReadRequest request = connection
.readRequestBuilder()
.addItem("value-1", field)
.build();
PlcReadResponse response = request.execute().get(); // here is hangs forever
System.out.println(response.getFieldNames());
connection.close();
Thanks a lot in advance!
Best regards,
Sebastian