diff options
author | Yuriy Piskarev <yuriy.piskarev@gmail.com> | 2023-09-26 23:33:21 +0300 |
---|---|---|
committer | Yuriy Piskarev <yuriy.piskarev@gmail.com> | 2023-09-26 23:33:21 +0300 |
commit | 2e52618a0b122f226646dc48436ca7dc6ec8cc39 (patch) | |
tree | a3d2fe2557650bd85a80d7d394ee9dc7c48d7c6a /src/main/java/org | |
parent | 8638bc8ab98fa5ee6199ecaa28754972dee15e5e (diff) | |
download | trackermap-server-2e52618a0b122f226646dc48436ca7dc6ec8cc39.tar.gz trackermap-server-2e52618a0b122f226646dc48436ca7dc6ec8cc39.tar.bz2 trackermap-server-2e52618a0b122f226646dc48436ca7dc6ec8cc39.zip |
fix PR #4839:
- before "case 5" delete blank line;
- field 15 conversion to meters;
- fields 53, 66 (check 15 bit, value 0-14 bits);
- field 54 check negative, conversion to liters;
- field 57 conversion to meters;
- fields 207-255 fix field num check (I didn't compare the index correctly)
Diffstat (limited to 'src/main/java/org')
-rw-r--r-- | src/main/java/org/traccar/protocol/NavtelecomProtocolDecoder.java | 33 |
1 files changed, 17 insertions, 16 deletions
diff --git a/src/main/java/org/traccar/protocol/NavtelecomProtocolDecoder.java b/src/main/java/org/traccar/protocol/NavtelecomProtocolDecoder.java index 2e857b212..9272b9e0b 100644 --- a/src/main/java/org/traccar/protocol/NavtelecomProtocolDecoder.java +++ b/src/main/java/org/traccar/protocol/NavtelecomProtocolDecoder.java @@ -196,9 +196,10 @@ public class NavtelecomProtocolDecoder extends BaseProtocolDecoder { for (int j = 0; j < bits.length(); j++) { if (bits.get(j)) { + int bitNum = j + 1; int value; - switch (j + 1) { + switch (bitNum) { case 1: position.set(Position.KEY_INDEX, buf.readUnsignedIntLE()); break; @@ -216,7 +217,6 @@ public class NavtelecomProtocolDecoder extends BaseProtocolDecoder { int guardMode = BitUtil.between(value, 3, 4); position.set(Position.KEY_ARMED, (0 < guardMode) && (guardMode < 3)); break; - case 5: value = buf.readUnsignedByte(); position.set(Position.KEY_ROAMING, BitUtil.check(value, 6) ? true : null); @@ -245,7 +245,7 @@ public class NavtelecomProtocolDecoder extends BaseProtocolDecoder { position.setCourse(buf.readUnsignedShortLE()); break; case 15: - position.set(Position.KEY_ODOMETER, buf.readFloatLE()); + position.set(Position.KEY_ODOMETER, buf.readFloatLE() * 1000); break; case 19: position.set(Position.KEY_POWER, buf.readShortLE() * 0.001); @@ -313,15 +313,16 @@ public class NavtelecomProtocolDecoder extends BaseProtocolDecoder { case 53: value = buf.readUnsignedShortLE(); if (value != 0x7FFF) { - if (BitUtil.check(value, 7)) { - position.set("obdFuelLevel", BitUtil.to(value, 6)); + if (BitUtil.check(value, 15)) { + position.set("obdFuelLevel", BitUtil.to(value, 14)); } else { - position.set("obdFuel", BitUtil.to(value, 6) / 10); + position.set("obdFuel", BitUtil.to(value, 14) / 10); } } break; case 54: - position.set(Position.KEY_FUEL_USED, buf.readFloatLE()); + double dValue = buf.readFloatLE() * 0.5; + position.set(Position.KEY_FUEL_USED, (dValue >= 0) ? (dValue * 0.5) : null); break; case 55: value = buf.readUnsignedShortLE(); @@ -332,7 +333,7 @@ public class NavtelecomProtocolDecoder extends BaseProtocolDecoder { position.set(Position.KEY_COOLANT_TEMP, (value != (byte) 0x80) ? value : null); break; case 57: - position.set(Position.KEY_OBD_ODOMETER, buf.readFloatLE()); + position.set(Position.KEY_OBD_ODOMETER, buf.readFloatLE() * 1000); break; case 58: case 59: @@ -357,10 +358,10 @@ public class NavtelecomProtocolDecoder extends BaseProtocolDecoder { case 66: value = buf.readUnsignedShortLE(); if (value != 0x7FFF) { - if (BitUtil.check(value, 7)) { - position.set("obdAdBlueLevel", BitUtil.to(value, 6)); + if (BitUtil.check(value, 15)) { + position.set("obdAdBlueLevel", BitUtil.to(value, 14)); } else { - position.set("obdAdBlue", BitUtil.to(value, 6) / 10); + position.set("obdAdBlue", BitUtil.to(value, 14) / 10); } } break; @@ -407,16 +408,16 @@ public class NavtelecomProtocolDecoder extends BaseProtocolDecoder { position.set("diagnostic", buf.readUnsignedIntLE()); break; default: - if ((207 <= j) && (j <= 222)) { + if ((207 <= bitNum) && (bitNum <= 222)) { position.set("user1Byte" + (j + 2 - 207), buf.readUnsignedByte()); - } else if ((223 <= j) && (j <= 237)) { + } else if ((223 <= bitNum) && (bitNum <= 237)) { position.set("user2Byte" + (j + 2 - 223), buf.readUnsignedShortLE()); - } else if ((238 <= j) && (j <= 252)) { + } else if ((238 <= bitNum) && (bitNum <= 252)) { position.set("user4Byte" + (j + 2 - 238), buf.readUnsignedIntLE()); - } else if ((253 <= j) && (j <= 255)) { + } else if ((253 <= bitNum) && (bitNum <= 255)) { position.set("user8Byte" + (j + 2 - 253), buf.readLongLE()); } else { - buf.skipBytes(getItemLength(j + 1)); + buf.skipBytes(getItemLength(bitNum)); } break; } |