Skip to content

Commit

Permalink
feat(plc4j/eip): Updated java CIP write dataSize to match read dataSi…
Browse files Browse the repository at this point in the history
…ze (#384) [PLC4X-341]

* EIP adding read/write for STRINGS and LINT

Jira PLC4X-341

* Removed unneeded output.

* Updated writes to set dataLength like reads.

Co-authored-by: Andy Grebe <andyg@designedconveyor.com>
  • Loading branch information
AndyGrebe and Andy Grebe committed Jun 21, 2022
1 parent 644d5c9 commit 0489ec6
Showing 1 changed file with 8 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -447,12 +447,19 @@ public CompletableFuture<PlcWriteResponse> write(PlcWriteRequest writeRequest) {
//We need the size of the request in words (0x91, tagLength, ... tag + possible pad)
// Taking half to get word size
boolean isArray = false;
boolean isStruct = false;
String tagIsolated = tag;
if (tag.contains("[")) {
isArray = true;
tagIsolated = tag.substring(0, tag.indexOf("["));
}
int dataLength = (tagIsolated.length() + 2 + (tagIsolated.length() % 2) + (isArray ? 2 : 0));

if (tag.contains(".")) {
isStruct = true;
tagIsolated = tagIsolated.replace(".", "");
}

int dataLength = (tagIsolated.length() + 2 + ((tagIsolated.length() % 2) * 2) + (isArray ? 2 : 0) + (isStruct ? 2 : 0));
byte requestPathSize = (byte) (dataLength / 2);
byte[] data = encodeValue(value, field.getType(), (short) elements);
CipWriteRequest writeReq = new CipWriteRequest(requestPathSize, toAnsi(tag), field.getType(), elements, data, -1);
Expand Down

0 comments on commit 0489ec6

Please sign in to comment.