You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@plc4x.apache.org by GitBox <gi...@apache.org> on 2022/11/09 10:21:53 UTC
[GitHub] [plc4x] ottlukas opened a new issue, #637: PLC4J GIP/CIP Read STRING tag returns null w/error
ottlukas opened a new issue, #637:
URL: https://github.com/apache/plc4x/issues/637
STRING tag reads in plc4j using eip are not returning the string. The error returned is:
java.lang.NullPointerException: Cannot invoke "org.apache.plc4x.java.api.value.PlcValue.getString()" because the return value of "org.apache.plc4x.java.api.messages.PlcReadResponse.getPlcValue(String)" is null
It looks like plc4j is considering it a structure or array. If I read with
```
%MyString[{index}]:STRING:1
```
I can get the individual characters in the string by placing the actual index in \{index}. So it knows where to start reading the data from.
When running a wireshark cap, I can see the returned string in the response from the PLC. Attached is a pcap of the transaction.
Code Snippet:
```
try (PlcConnection plcConnection = new PlcDriverManager().getConnection("eip://127.0.0.1")) {
if (!plcConnection.getMetadata().canRead()) {
logger.error("PLC connection doesn't support
reading.");
return;
}
logger.info("PLC connector connected"); // Create a new
read request:
PlcReadRequest.Builder builder = plcConnection.readRequestBuilder();
logger.info("Created
Builder");
builder.addItem("value-1", "%MyString:STRING:1");
PlcReadRequest readRequest =
builder.build(); // Register a callback executed as soon as a response arrives.
logger.info("Make
sync request for PLC data");
PlcReadResponse readResponse = readRequest.execute().get(5000, TimeUnit.MILLISECONDS);
if (readResponse != null) {
printPlcResponse(readResponse);
} else {
logger.error("An
error reading PLC, response is NULL");
}
for (String field : readResponse.getFieldNames()){
rtnArray.add(new PlcReadResponseData(field,
readResponse.getPlcValue(field).getString())
); // Exception is thrown here
}
} catch (PlcConnectionException e) {
e.printStackTrace();
}
```
Imported from Jira [PLC4X-341](https://issues.apache.org/jira/browse/PLC4X-341). Original Jira may contain additional context.
Reported by: AndyGPLC.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: issues-unsubscribe@plc4x.apache.org.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [I] PLC4J GIP/CIP Read STRING tag returns null w/error
Posted by "chrisdutz (via GitHub)" <gi...@apache.org>.
chrisdutz commented on issue #637:
URL: https://github.com/apache/plc4x/issues/637#issuecomment-2225586856
I have seen the driver read strings, so I'm closing this.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: issues-unsubscribe@plc4x.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [I] PLC4J GIP/CIP Read STRING tag returns null w/error
Posted by "chrisdutz (via GitHub)" <gi...@apache.org>.
chrisdutz closed issue #637: PLC4J GIP/CIP Read STRING tag returns null w/error
URL: https://github.com/apache/plc4x/issues/637
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: issues-unsubscribe@plc4x.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [I] PLC4J GIP/CIP Read STRING tag returns null w/error
Posted by "chrisdutz (via GitHub)" <gi...@apache.org>.
chrisdutz commented on issue #637:
URL: https://github.com/apache/plc4x/issues/637#issuecomment-1929210389
@hutcheb Can this issue be closed?
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: dev-unsubscribe@plc4x.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org