New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
PLC4X-57 Bugfix #25
PLC4X-57 Bugfix #25
Conversation
e03d6e9
to
a05a956
Compare
Sorry, the rebase did not work and I had to do it in a second commit. |
switch (field.getDataType()) { | ||
// ----------------------------------------- | ||
// Bit | ||
// ----------------------------------------- | ||
case BOOL: { | ||
byte byteValue = data.readByte(); | ||
fieldItem = new S7BooleanFieldItem(field.getDataType(),byteValue != 0x00); | ||
Boolean[] booleans = readAllValues(field, i -> data.readByte() != 0x00).toArray(new Boolean[field.getNumElements()]); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
actually sonar finds a presized array as a bug: see here https://stackoverflow.com/a/29444594/850036
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
review...
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm about to fix it... didn't know that
Also fixed Output from HelloPlc4x.java. Fixed some small bugs. Added TODO for returning arrays on bit streams and chars / strings. Fixed Presized Arrays.
d02b88e
to
a4100ed
Compare
BitSet bitSet = BitSet.valueOf(new byte[]{data.readByte()}); | ||
Boolean[] booleanValues = new Boolean[8]; | ||
for(int i = 0; i < 8; i++) { | ||
Byte[] bytes = readAllValues(field, i -> data.readByte()).toArray(new Byte[field.getNumElements()]); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
maybe we should check data
if we can read this amount of bytes. This could maybe be done generic if we pass the data variable and the method reference: data::readByte
or something like that.
switch (field.getDataType()) { | ||
// ----------------------------------------- | ||
// Bit | ||
// ----------------------------------------- | ||
case BOOL: { | ||
byte byteValue = data.readByte(); | ||
fieldItem = new S7BooleanFieldItem(field.getDataType(),byteValue != 0x00); | ||
Boolean[] booleans = readAllValues(field, i -> data.readByte() != 0x00).toArray(new Boolean[field.getNumElements()]); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
review...
Used more of sebastians generics magic to remove ".toArray(...)".
By the way ... looking good ... just had a few minutes after lunch and checked out your changes. |
Fixed PLC4X-57.
Also fixed Output from HelloPlc4x.java.
Fixed some small bugs.
Added TODO for returning arrays on bit streams and chars / strings.