apache / plc4x

PLC4X The Industrial IoT adapter
https://plc4x.apache.org/
Apache License 2.0
1.27k stars 403 forks source link

[Bug]: [PLC4J] [EtherNet/IP] All values read are null for Allen-Bradley PLC with EtherNet/IP or Logix #1646

Closed meichf closed 2 months ago

meichf commented 5 months ago

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:

tags

Version

v0.12.0

Programming Languages

Protocols

chrisdutz commented 3 months ago

Yeah... If you only need only one instance that option might be cheaper. For a completely rewritten driver With auto discovery, browse and udt support, I would be expecting more something like 4k€ min for me to donate it. If you contact me directly via email, I might have another option for you.

chrisdutz commented 2 months ago

User seems to have chosen to use an alternative solution