aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/org/traccar/protocol/NavisProtocolDecoder.java10
1 files changed, 8 insertions, 2 deletions
diff --git a/src/org/traccar/protocol/NavisProtocolDecoder.java b/src/org/traccar/protocol/NavisProtocolDecoder.java
index 8eda868b1..65c425053 100644
--- a/src/org/traccar/protocol/NavisProtocolDecoder.java
+++ b/src/org/traccar/protocol/NavisProtocolDecoder.java
@@ -317,6 +317,12 @@ public class NavisProtocolDecoder extends BaseProtocolDecoder {
return positions;
}
+ private boolean checkFlexBitfield(int index) {
+ int byteIndex = Math.floorDiv(index, 8);
+ int bitIndex = Math.floorMod(index, 8);
+ return BitUtil.check(flexBitfield[byteIndex], 7 - bitIndex);
+ }
+
private void skipFlexField(int index, ByteBuf buf) {
if (index < FLEX_FIELDS_SIZES.length) {
buf.skipBytes(FLEX_FIELDS_SIZES[index]);
@@ -335,7 +341,7 @@ public class NavisProtocolDecoder extends BaseProtocolDecoder {
short output = 0;
for (int i = 0; i < flexBitfieldDataSize; i++) {
- if ((flexBitfield[(int) (i / 8)] & (0x80 >> i % 8)) == 0) {
+ if (!checkFlexBitfield(i)) {
// Skip FLEX field
continue;
}
@@ -597,7 +603,7 @@ public class NavisProtocolDecoder extends BaseProtocolDecoder {
flexDataSize = 0;
for (int i = 0; i < flexBitfieldDataSize; i++) {
- if ((flexBitfield[(int) (i / 8)] & (0x80 >> i % 8)) != 0) {
+ if (checkFlexBitfield(i)) {
flexDataSize += FLEX_FIELDS_SIZES[i];
}
}