Skip to content

Commit

Permalink
refactor(plc4j/code-gen): Refactored the way Encoding is handled and …
Browse files Browse the repository at this point in the history
…added "nullBytesHex" attribute support.

- Changed the string-handling to not use an explicit "encoding" method attribute and moved that to using "WithEncoding" options.
- Added support for a new "nullByteHex" attribute for optional fields
- Added an accessor to the readBuffer instance for DataReaders
- Added an accessor to the writeBuffer instance for DataWriters
- Bumped plc4x-code-generation version to 1.7.0-SNAPSHOT
  • Loading branch information
chrisdutz committed Jan 25, 2023
1 parent bcb14d3 commit 102c041
Showing 1 changed file with 3 additions and 2 deletions.
Expand Up @@ -31,6 +31,7 @@
import org.apache.plc4x.java.s7.readwrite.DataTransportErrorCode;
import org.apache.plc4x.java.s7.readwrite.ModeTransitionType;
import org.apache.plc4x.java.s7.utils.S7DiagnosticEventId;
import org.apache.plc4x.java.spi.codegen.WithOption;
import org.apache.plc4x.java.spi.generation.ParseException;
import org.apache.plc4x.java.spi.generation.ReadBuffer;
import org.apache.plc4x.java.spi.generation.SerializationException;
Expand Down Expand Up @@ -1932,9 +1933,9 @@ public static void serializeTiaDateTime(WriteBuffer io, PlcValue value) {

public static String parseS7Char(ReadBuffer io, String encoding) throws ParseException {
if ("UTF-8".equalsIgnoreCase(encoding)) {
return io.readString(8, encoding);
return io.readString(8, WithOption.WithEncoding(encoding));
} else if ("UTF-16".equalsIgnoreCase(encoding)) {
return io.readString(16, encoding);
return io.readString(16, WithOption.WithEncoding(encoding));
} else {
throw new PlcRuntimeException("Unsupported encoding");
}
Expand Down

0 comments on commit 102c041

Please sign in to comment.