plc4x: [Bug]: [PLC4J] [EtherNet/IP] All values read are null for Allen-Bradley PLC with EtherNet/IP or Logix
What happened?
I wrote two programs according to the documentation on the official website of PLC4X to read Allen Bradley PLC, model Logix5571, but all the values read were null.
Here is the code. The result is that all four tag values in asPlcValue are null.
code for EtherNet/IP protocol:
String connectionString = "eip://192.168.0.2:44818?slot=0&bigEndian=false";
try (PlcConnection plcConnection = PlcDriverManager.getDefault().getConnectionManager().getConnection(connectionString)) {
final PlcReadRequest.Builder readrequest = plcConnection.readRequestBuilder();
//(3.1)
readrequest.addTagAddress("tag1", "%A:DINT");
readrequest.addTagAddress("tag2", "%B:INT");
readrequest.addTagAddress("tag3", "%C:SINT");
readrequest.addTagAddress("tag4", "%D:REAL");
//(3.2)
final PlcReadRequest rr = readrequest.build();
//(3.3)
final PlcReadResponse szlresponse = rr.execute().get();
PlcValue asPlcValue = szlresponse.getAsPlcValue();
} catch (PlcConnectionException e) {
throw new RuntimeException(e);
} catch (Exception e) {
throw new RuntimeException(e);
}
code for Logix protocol:
String connectionString = "logix://192.168.0.2:44818?slot=0&bigEndian=false";
try (PlcConnection plcConnection = PlcDriverManager.getDefault().getConnectionManager().getConnection(connectionString)) {
PlcConnectionMetadata metadata = plcConnection.getMetadata();
final PlcReadRequest.Builder readrequest = plcConnection.readRequestBuilder();
//(3.1)
readrequest.addTagAddress("tag1", "A:DINT");
readrequest.addTagAddress("tag2", "B:INT");
readrequest.addTagAddress("tag3", "C:SINT");
readrequest.addTagAddress("tag4", "D:REAL");
//(3.2)
final PlcReadRequest rr = readrequest.build();
//(3.3)
final PlcReadResponse szlresponse = rr.execute().get();
//(3.4)
PlcValue asPlcValue = szlresponse.getAsPlcValue();
log.info("Tags: " + asPlcValue);
} catch (PlcConnectionException e) {
throw new RuntimeException(e);
} catch (Exception e) {
throw new RuntimeException(e);
}`
here is the tags:
Version
v0.12.0
Programming Languages
- plc4j
- plc4go
- plc4c
- plc4net
Protocols
- AB-Ethernet
- ADS /AMS
- BACnet/IP
- CANopen
- DeltaV
- DF1
- EtherNet/IP
- Firmata
- KNXnet/IP
- Modbus
- OPC-UA
- S7
About this issue
- Original URL
- State: closed
- Created 2 years ago
- Comments: 52 (26 by maintainers)
Commits related to this issue
- fix: Worked on adding unit tests for my hardware in order to be able to debug issues with the logix driver. #1646 — committed to apache/plc4x by chrisdutz 2 years ago
I found that using version 0.11.0 to read data is slow, and the duration of returning data increases with the number of points. Then, I found the problem in issue #1373, so I rewrote the method. Now, reading values is relatively normal.
So if I look at your code, omit the “%” and the datatypes. Just “A”, “B”, “C”, or “D” should be enough.