From 2fcf8ea7ed086175658d05e536d4ce071cf17dda Mon Sep 17 00:00:00 2001 From: Yuriy Date: Tue, 22 Mar 2022 11:36:01 +0300 Subject: Decode additional Navtelecom info --- .../protocol/NavtelecomProtocolDecoder.java | 162 ++++++++++++++++++++- 1 file changed, 161 insertions(+), 1 deletion(-) (limited to 'src/main/java/org/traccar') diff --git a/src/main/java/org/traccar/protocol/NavtelecomProtocolDecoder.java b/src/main/java/org/traccar/protocol/NavtelecomProtocolDecoder.java index 5d3a81f2a..72a74a534 100644 --- a/src/main/java/org/traccar/protocol/NavtelecomProtocolDecoder.java +++ b/src/main/java/org/traccar/protocol/NavtelecomProtocolDecoder.java @@ -195,6 +195,9 @@ public class NavtelecomProtocolDecoder extends BaseProtocolDecoder { for (int j = 0; j < bits.length(); j++) { if (bits.get(j)) { + + int tmp = 0; // To parse a value by multiple conditions + switch (j + 1) { case 1: position.set(Position.KEY_INDEX, buf.readUnsignedIntLE()); @@ -205,8 +208,12 @@ public class NavtelecomProtocolDecoder extends BaseProtocolDecoder { case 3: position.setDeviceTime(new Date(buf.readUnsignedIntLE() * 1000)); break; + case 8: + tmp = buf.readUnsignedByte(); + position.setValid((tmp & 0b00000010) == 0b00000010); + position.set(Position.KEY_SATELLITES, ((tmp & 0b11111100) >> 2)); + break; case 9: - position.setValid(true); position.setFixTime(new Date(buf.readUnsignedIntLE() * 1000)); break; case 10: @@ -221,6 +228,159 @@ public class NavtelecomProtocolDecoder extends BaseProtocolDecoder { case 13: position.setSpeed(UnitsConverter.knotsFromKph(buf.readFloatLE())); break; + case 14: + position.setCourse(buf.readUnsignedShortLE()); + break; + case 15: + position.set(Position.KEY_ODOMETER,buf.readFloatLE()); + break; + case 19: + position.set(Position.KEY_POWER,buf.readShortLE() * 0.001); + break; + case 20: + position.set(Position.KEY_BATTERY,buf.readShortLE() * 0.001); + break; + case 21: + position.set(Position.PREFIX_ADC + 1,buf.readUnsignedShortLE() * 0.001); + break; + case 22: + position.set(Position.PREFIX_ADC + 2,buf.readUnsignedShortLE() * 0.001); + break; + case 23: + position.set(Position.PREFIX_ADC + 3,buf.readUnsignedShortLE() * 0.001); + break; + case 24: + position.set(Position.PREFIX_ADC + 4,buf.readUnsignedShortLE() * 0.001); + break; + case 25: + position.set(Position.PREFIX_ADC + 5,buf.readUnsignedShortLE() * 0.001); + break; + case 26: + position.set(Position.PREFIX_ADC + 6,buf.readUnsignedShortLE() * 0.001); + break; + case 29: + tmp = buf.readUnsignedByte(); + position.set(Position.PREFIX_IN + 1, (tmp & 0b00000001) == 0b00000001); + position.set(Position.PREFIX_IN + 2, (tmp & 0b00000010) == 0b00000010); + position.set(Position.PREFIX_IN + 3, (tmp & 0b00000100) == 0b00000100); + position.set(Position.PREFIX_IN + 4, (tmp & 0b00001000) == 0b00001000); + position.set(Position.PREFIX_IN + 5, (tmp & 0b00010000) == 0b00010000); + position.set(Position.PREFIX_IN + 6, (tmp & 0b00100000) == 0b00100000); + position.set(Position.PREFIX_IN + 7, (tmp & 0b01000000) == 0b01000000); + position.set(Position.PREFIX_IN + 8, (tmp & 0b10000000) == 0b10000000); + break; + case 31: + tmp = buf.readUnsignedByte(); + position.set(Position.PREFIX_OUT + 1, (tmp & 0b00000001) == 0b00000001); + position.set(Position.PREFIX_OUT + 2, (tmp & 0b00000010) == 0b00000010); + position.set(Position.PREFIX_OUT + 3, (tmp & 0b00000100) == 0b00000100); + position.set(Position.PREFIX_OUT + 4, (tmp & 0b00001000) == 0b00001000); + break; + case 33: + position.set(Position.PREFIX_COUNT + 1,buf.readUnsignedIntLE()); + break; + case 34: + position.set(Position.PREFIX_COUNT + 2,buf.readUnsignedIntLE()); + break; + case 35: + position.set("freq" + 1,buf.readUnsignedShortLE()); + break; + case 36: + position.set("freq" + 2,buf.readUnsignedShortLE()); + break; + case 37: + position.set("engine_hours",buf.readUnsignedIntLE()); + break; + case 38: + tmp = buf.readUnsignedShortLE(); + if (tmp < 65500) { // Do not write error codes + position.set("rs485fuel_level" + 1,tmp); + } + break; + case 39: + tmp = buf.readUnsignedShortLE(); + if (tmp < 65500) { // Do not write error codes + position.set("rs485fuel_level" + 2,tmp); + } + break; + case 40: + tmp = buf.readUnsignedShortLE(); + if (tmp < 65500) { // Do not write error codes + position.set("rs485fuel_level" + 3,tmp); + } + break; + case 41: + tmp = buf.readUnsignedShortLE(); + if (tmp < 65500) { // Do not write error codes + position.set("rs485fuel_level" + 4,tmp); + } + break; + case 42: + tmp = buf.readUnsignedShortLE(); + if (tmp < 65500) { // Do not write error codes + position.set("rs485fuel_level" + 5,tmp); + } + break; + case 43: + tmp = buf.readUnsignedShortLE(); + if (tmp < 65500) { // Do not write error codes + position.set("rs485fuel_level" + 6,tmp); + } + break; + case 44: + tmp = buf.readUnsignedShortLE(); + if (tmp < 65500) { // Do not write error codes + position.set("rs232fuel_level",tmp); + } + break; + case 45: + tmp = buf.readByte(); + if (tmp != 0x80) { // Do not write error codes + position.set(Position.PREFIX_TEMP + 1,tmp); + } + break; + case 46: + tmp = buf.readByte(); + if (tmp != 0x80) { // Do not write error codes + position.set(Position.PREFIX_TEMP + 2,tmp); + } + break; + case 47: + tmp = buf.readByte(); + if (tmp != 0x80) { // Do not write error codes + position.set(Position.PREFIX_TEMP + 3,tmp); + } + break; + case 48: + tmp = buf.readByte(); + if (tmp != 0x80) { // Do not write error codes + position.set(Position.PREFIX_TEMP + 4,tmp); + } + break; + case 49: + tmp = buf.readByte(); + if (tmp != 0x80) { // Do not write error codes + position.set(Position.PREFIX_TEMP + 5,tmp); + } + break; + case 50: + tmp = buf.readByte(); + if (tmp != 0x80) { // Do not write error codes + position.set(Position.PREFIX_TEMP + 6,tmp); + } + break; + case 51: + tmp = buf.readByte(); + if (tmp != 0x80) { // Do not write error codes + position.set(Position.PREFIX_TEMP + 7,tmp); + } + break; + case 52: + tmp = buf.readByte(); + if (tmp != 0x80) { // Do not write error codes + position.set(Position.PREFIX_TEMP + 8,tmp); + } + break; default: buf.skipBytes(getItemLength(j + 1)); break; -- cgit v1.2.3 From 93e9d449d187bc3947ca76a1f3bdd4f02b37752c Mon Sep 17 00:00:00 2001 From: Yuriy Piskarev Date: Wed, 23 Mar 2022 15:46:37 +0300 Subject: - fixed warnings from checkstyle; - rename tmp variable; - added use of BitUtil; - redesigned parameter checking; --- .../protocol/NavtelecomProtocolDecoder.java | 148 ++++++++------------- 1 file changed, 56 insertions(+), 92 deletions(-) (limited to 'src/main/java/org/traccar') diff --git a/src/main/java/org/traccar/protocol/NavtelecomProtocolDecoder.java b/src/main/java/org/traccar/protocol/NavtelecomProtocolDecoder.java index 72a74a534..d4026353d 100644 --- a/src/main/java/org/traccar/protocol/NavtelecomProtocolDecoder.java +++ b/src/main/java/org/traccar/protocol/NavtelecomProtocolDecoder.java @@ -196,7 +196,7 @@ public class NavtelecomProtocolDecoder extends BaseProtocolDecoder { for (int j = 0; j < bits.length(); j++) { if (bits.get(j)) { - int tmp = 0; // To parse a value by multiple conditions + int value = 0; switch (j + 1) { case 1: @@ -209,9 +209,9 @@ public class NavtelecomProtocolDecoder extends BaseProtocolDecoder { position.setDeviceTime(new Date(buf.readUnsignedIntLE() * 1000)); break; case 8: - tmp = buf.readUnsignedByte(); - position.setValid((tmp & 0b00000010) == 0b00000010); - position.set(Position.KEY_SATELLITES, ((tmp & 0b11111100) >> 2)); + value = buf.readUnsignedByte(); + position.setValid(BitUtil.check(value, 1)); + position.set(Position.KEY_SATELLITES, ((value & 0b11111100) >> 2)); break; case 9: position.setFixTime(new Date(buf.readUnsignedIntLE() * 1000)); @@ -232,154 +232,118 @@ 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()); break; case 19: - position.set(Position.KEY_POWER,buf.readShortLE() * 0.001); + position.set(Position.KEY_POWER, buf.readShortLE() * 0.001); break; case 20: - position.set(Position.KEY_BATTERY,buf.readShortLE() * 0.001); + position.set(Position.KEY_BATTERY, buf.readShortLE() * 0.001); break; case 21: - position.set(Position.PREFIX_ADC + 1,buf.readUnsignedShortLE() * 0.001); + position.set(Position.PREFIX_ADC + 1, buf.readUnsignedShortLE() * 0.001); break; case 22: - position.set(Position.PREFIX_ADC + 2,buf.readUnsignedShortLE() * 0.001); + position.set(Position.PREFIX_ADC + 2, buf.readUnsignedShortLE() * 0.001); break; case 23: - position.set(Position.PREFIX_ADC + 3,buf.readUnsignedShortLE() * 0.001); + position.set(Position.PREFIX_ADC + 3, buf.readUnsignedShortLE() * 0.001); break; case 24: - position.set(Position.PREFIX_ADC + 4,buf.readUnsignedShortLE() * 0.001); + position.set(Position.PREFIX_ADC + 4, buf.readUnsignedShortLE() * 0.001); break; case 25: - position.set(Position.PREFIX_ADC + 5,buf.readUnsignedShortLE() * 0.001); + position.set(Position.PREFIX_ADC + 5, buf.readUnsignedShortLE() * 0.001); break; case 26: - position.set(Position.PREFIX_ADC + 6,buf.readUnsignedShortLE() * 0.001); + position.set(Position.PREFIX_ADC + 6, buf.readUnsignedShortLE() * 0.001); break; case 29: - tmp = buf.readUnsignedByte(); - position.set(Position.PREFIX_IN + 1, (tmp & 0b00000001) == 0b00000001); - position.set(Position.PREFIX_IN + 2, (tmp & 0b00000010) == 0b00000010); - position.set(Position.PREFIX_IN + 3, (tmp & 0b00000100) == 0b00000100); - position.set(Position.PREFIX_IN + 4, (tmp & 0b00001000) == 0b00001000); - position.set(Position.PREFIX_IN + 5, (tmp & 0b00010000) == 0b00010000); - position.set(Position.PREFIX_IN + 6, (tmp & 0b00100000) == 0b00100000); - position.set(Position.PREFIX_IN + 7, (tmp & 0b01000000) == 0b01000000); - position.set(Position.PREFIX_IN + 8, (tmp & 0b10000000) == 0b10000000); + value = buf.readUnsignedByte(); + for (int k = 0; k <= 7; k++) { + position.set(Position.PREFIX_IN + (k + 1), BitUtil.check(value, k) ? 1 : 0); + } break; case 31: - tmp = buf.readUnsignedByte(); - position.set(Position.PREFIX_OUT + 1, (tmp & 0b00000001) == 0b00000001); - position.set(Position.PREFIX_OUT + 2, (tmp & 0b00000010) == 0b00000010); - position.set(Position.PREFIX_OUT + 3, (tmp & 0b00000100) == 0b00000100); - position.set(Position.PREFIX_OUT + 4, (tmp & 0b00001000) == 0b00001000); + value = buf.readUnsignedByte(); + for (int k = 0; k <= 3; k++) { + position.set(Position.PREFIX_OUT + (k + 1), BitUtil.check(value, k) ? 1 : 0); + } break; case 33: - position.set(Position.PREFIX_COUNT + 1,buf.readUnsignedIntLE()); + position.set(Position.PREFIX_COUNT + 1, buf.readUnsignedIntLE()); break; case 34: - position.set(Position.PREFIX_COUNT + 2,buf.readUnsignedIntLE()); + position.set(Position.PREFIX_COUNT + 2, buf.readUnsignedIntLE()); break; case 35: - position.set("freq" + 1,buf.readUnsignedShortLE()); + position.set("freq" + 1, buf.readUnsignedShortLE()); break; case 36: - position.set("freq" + 2,buf.readUnsignedShortLE()); + position.set("freq" + 2, buf.readUnsignedShortLE()); break; case 37: - position.set("engine_hours",buf.readUnsignedIntLE()); + position.set("engine_hours", buf.readUnsignedIntLE()); break; case 38: - tmp = buf.readUnsignedShortLE(); - if (tmp < 65500) { // Do not write error codes - position.set("rs485fuel_level" + 1,tmp); - } + value = buf.readUnsignedShortLE(); + position.set("rs485fuel_level" + 1, (value < 65500) ? value : null); break; case 39: - tmp = buf.readUnsignedShortLE(); - if (tmp < 65500) { // Do not write error codes - position.set("rs485fuel_level" + 2,tmp); - } + value = buf.readUnsignedShortLE(); + position.set("rs485fuel_level" + 2, (value < 65500) ? value : null); break; case 40: - tmp = buf.readUnsignedShortLE(); - if (tmp < 65500) { // Do not write error codes - position.set("rs485fuel_level" + 3,tmp); - } + value = buf.readUnsignedShortLE(); + position.set("rs485fuel_level" + 3, (value < 65500) ? value : null); break; case 41: - tmp = buf.readUnsignedShortLE(); - if (tmp < 65500) { // Do not write error codes - position.set("rs485fuel_level" + 4,tmp); - } + value = buf.readUnsignedShortLE(); + position.set("rs485fuel_level" + 4, (value < 65500) ? value : null); break; case 42: - tmp = buf.readUnsignedShortLE(); - if (tmp < 65500) { // Do not write error codes - position.set("rs485fuel_level" + 5,tmp); - } + value = buf.readUnsignedShortLE(); + position.set("rs485fuel_level" + 5, (value < 65500) ? value : null); break; case 43: - tmp = buf.readUnsignedShortLE(); - if (tmp < 65500) { // Do not write error codes - position.set("rs485fuel_level" + 6,tmp); - } + value = buf.readUnsignedShortLE(); + position.set("rs485fuel_level" + 6, (value < 65500) ? value : null); break; case 44: - tmp = buf.readUnsignedShortLE(); - if (tmp < 65500) { // Do not write error codes - position.set("rs232fuel_level",tmp); - } + value = buf.readUnsignedShortLE(); + position.set("rs232fuel_level", (value < 65500) ? value : null); break; case 45: - tmp = buf.readByte(); - if (tmp != 0x80) { // Do not write error codes - position.set(Position.PREFIX_TEMP + 1,tmp); - } + value = buf.readByte(); + position.set(Position.PREFIX_TEMP + 1, (value != 0x80) ? value : null); break; case 46: - tmp = buf.readByte(); - if (tmp != 0x80) { // Do not write error codes - position.set(Position.PREFIX_TEMP + 2,tmp); - } + value = buf.readByte(); + position.set(Position.PREFIX_TEMP + 2, (value != 0x80) ? value : null); break; case 47: - tmp = buf.readByte(); - if (tmp != 0x80) { // Do not write error codes - position.set(Position.PREFIX_TEMP + 3,tmp); - } + value = buf.readByte(); + position.set(Position.PREFIX_TEMP + 3, (value != 0x80) ? value : null); break; case 48: - tmp = buf.readByte(); - if (tmp != 0x80) { // Do not write error codes - position.set(Position.PREFIX_TEMP + 4,tmp); - } + value = buf.readByte(); + position.set(Position.PREFIX_TEMP + 4, (value != 0x80) ? value : null); break; case 49: - tmp = buf.readByte(); - if (tmp != 0x80) { // Do not write error codes - position.set(Position.PREFIX_TEMP + 5,tmp); - } + value = buf.readByte(); + position.set(Position.PREFIX_TEMP + 5, (value != 0x80) ? value : null); break; case 50: - tmp = buf.readByte(); - if (tmp != 0x80) { // Do not write error codes - position.set(Position.PREFIX_TEMP + 6,tmp); - } + value = buf.readByte(); + position.set(Position.PREFIX_TEMP + 6, (value != 0x80) ? value : null); break; case 51: - tmp = buf.readByte(); - if (tmp != 0x80) { // Do not write error codes - position.set(Position.PREFIX_TEMP + 7,tmp); - } + value = buf.readByte(); + position.set(Position.PREFIX_TEMP + 7, (value != 0x80) ? value : null); break; case 52: - tmp = buf.readByte(); - if (tmp != 0x80) { // Do not write error codes - position.set(Position.PREFIX_TEMP + 8,tmp); - } + value = buf.readByte(); + position.set(Position.PREFIX_TEMP + 8, (value != 0x80) ? value : null); break; default: buf.skipBytes(getItemLength(j + 1)); -- cgit v1.2.3 From 43c35020d55f552157f53a28bfd3bec765e387ab Mon Sep 17 00:00:00 2001 From: Yuriy Piskarev Date: Thu, 24 Mar 2022 13:25:50 +0300 Subject: - rename fuel key; --- .../org/traccar/protocol/NavtelecomProtocolDecoder.java | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) (limited to 'src/main/java/org/traccar') diff --git a/src/main/java/org/traccar/protocol/NavtelecomProtocolDecoder.java b/src/main/java/org/traccar/protocol/NavtelecomProtocolDecoder.java index d4026353d..ff6f12dde 100644 --- a/src/main/java/org/traccar/protocol/NavtelecomProtocolDecoder.java +++ b/src/main/java/org/traccar/protocol/NavtelecomProtocolDecoder.java @@ -287,31 +287,31 @@ public class NavtelecomProtocolDecoder extends BaseProtocolDecoder { break; case 38: value = buf.readUnsignedShortLE(); - position.set("rs485fuel_level" + 1, (value < 65500) ? value : null); + position.set("rs485Fuel" + 1, (value < 65500) ? value : null); break; case 39: value = buf.readUnsignedShortLE(); - position.set("rs485fuel_level" + 2, (value < 65500) ? value : null); + position.set("rs485Fuel" + 2, (value < 65500) ? value : null); break; case 40: value = buf.readUnsignedShortLE(); - position.set("rs485fuel_level" + 3, (value < 65500) ? value : null); + position.set("rs485Fuel" + 3, (value < 65500) ? value : null); break; case 41: value = buf.readUnsignedShortLE(); - position.set("rs485fuel_level" + 4, (value < 65500) ? value : null); + position.set("rs485Fuel" + 4, (value < 65500) ? value : null); break; case 42: value = buf.readUnsignedShortLE(); - position.set("rs485fuel_level" + 5, (value < 65500) ? value : null); + position.set("rs485Fuel" + 5, (value < 65500) ? value : null); break; case 43: value = buf.readUnsignedShortLE(); - position.set("rs485fuel_level" + 6, (value < 65500) ? value : null); + position.set("rs485Fuel" + 6, (value < 65500) ? value : null); break; case 44: value = buf.readUnsignedShortLE(); - position.set("rs232fuel_level", (value < 65500) ? value : null); + position.set("rs232Fuel", (value < 65500) ? value : null); break; case 45: value = buf.readByte(); -- cgit v1.2.3 From 56f7a4eab1b4ccc3801a24d7e2ede33d0ab9339c Mon Sep 17 00:00:00 2001 From: Yuriy Piskarev Date: Fri, 25 Mar 2022 11:12:32 +0300 Subject: - optimized parsing of similar protocol fields; --- .../protocol/NavtelecomProtocolDecoder.java | 62 +++------------------- 1 file changed, 6 insertions(+), 56 deletions(-) (limited to 'src/main/java/org/traccar') diff --git a/src/main/java/org/traccar/protocol/NavtelecomProtocolDecoder.java b/src/main/java/org/traccar/protocol/NavtelecomProtocolDecoder.java index ff6f12dde..60f1091bb 100644 --- a/src/main/java/org/traccar/protocol/NavtelecomProtocolDecoder.java +++ b/src/main/java/org/traccar/protocol/NavtelecomProtocolDecoder.java @@ -193,7 +193,7 @@ public class NavtelecomProtocolDecoder extends BaseProtocolDecoder { Position position = new Position(getProtocolName()); position.setDeviceId(deviceSession.getDeviceId()); - for (int j = 0; j < bits.length(); j++) { + for (int j = 0, l = 2; j < bits.length(); j++, l++) { if (bits.get(j)) { int value = 0; @@ -241,22 +241,12 @@ public class NavtelecomProtocolDecoder extends BaseProtocolDecoder { position.set(Position.KEY_BATTERY, buf.readShortLE() * 0.001); break; case 21: - position.set(Position.PREFIX_ADC + 1, buf.readUnsignedShortLE() * 0.001); - break; case 22: - position.set(Position.PREFIX_ADC + 2, buf.readUnsignedShortLE() * 0.001); - break; case 23: - position.set(Position.PREFIX_ADC + 3, buf.readUnsignedShortLE() * 0.001); - break; case 24: - position.set(Position.PREFIX_ADC + 4, buf.readUnsignedShortLE() * 0.001); - break; case 25: - position.set(Position.PREFIX_ADC + 5, buf.readUnsignedShortLE() * 0.001); - break; case 26: - position.set(Position.PREFIX_ADC + 6, buf.readUnsignedShortLE() * 0.001); + position.set(Position.PREFIX_ADC + (l - 21), buf.readUnsignedShortLE() * 0.001); break; case 29: value = buf.readUnsignedByte(); @@ -271,79 +261,39 @@ public class NavtelecomProtocolDecoder extends BaseProtocolDecoder { } break; case 33: - position.set(Position.PREFIX_COUNT + 1, buf.readUnsignedIntLE()); - break; case 34: - position.set(Position.PREFIX_COUNT + 2, buf.readUnsignedIntLE()); + position.set(Position.PREFIX_COUNT + (l - 33), buf.readUnsignedIntLE()); break; case 35: - position.set("freq" + 1, buf.readUnsignedShortLE()); - break; case 36: - position.set("freq" + 2, buf.readUnsignedShortLE()); + position.set("freq" + (l - 35), buf.readUnsignedShortLE()); break; case 37: position.set("engine_hours", buf.readUnsignedIntLE()); break; case 38: - value = buf.readUnsignedShortLE(); - position.set("rs485Fuel" + 1, (value < 65500) ? value : null); - break; case 39: - value = buf.readUnsignedShortLE(); - position.set("rs485Fuel" + 2, (value < 65500) ? value : null); - break; case 40: - value = buf.readUnsignedShortLE(); - position.set("rs485Fuel" + 3, (value < 65500) ? value : null); - break; case 41: - value = buf.readUnsignedShortLE(); - position.set("rs485Fuel" + 4, (value < 65500) ? value : null); - break; case 42: - value = buf.readUnsignedShortLE(); - position.set("rs485Fuel" + 5, (value < 65500) ? value : null); - break; case 43: value = buf.readUnsignedShortLE(); - position.set("rs485Fuel" + 6, (value < 65500) ? value : null); + position.set("rs485Fuel" + (l - 38), (value < 65500) ? value : null); break; case 44: value = buf.readUnsignedShortLE(); position.set("rs232Fuel", (value < 65500) ? value : null); break; case 45: - value = buf.readByte(); - position.set(Position.PREFIX_TEMP + 1, (value != 0x80) ? value : null); - break; case 46: - value = buf.readByte(); - position.set(Position.PREFIX_TEMP + 2, (value != 0x80) ? value : null); - break; case 47: - value = buf.readByte(); - position.set(Position.PREFIX_TEMP + 3, (value != 0x80) ? value : null); - break; case 48: - value = buf.readByte(); - position.set(Position.PREFIX_TEMP + 4, (value != 0x80) ? value : null); - break; case 49: - value = buf.readByte(); - position.set(Position.PREFIX_TEMP + 5, (value != 0x80) ? value : null); - break; case 50: - value = buf.readByte(); - position.set(Position.PREFIX_TEMP + 6, (value != 0x80) ? value : null); - break; case 51: - value = buf.readByte(); - position.set(Position.PREFIX_TEMP + 7, (value != 0x80) ? value : null); - break; case 52: value = buf.readByte(); - position.set(Position.PREFIX_TEMP + 8, (value != 0x80) ? value : null); + position.set(Position.PREFIX_TEMP + (l - 45), (value != 0x80) ? value : null); break; default: buf.skipBytes(getItemLength(j + 1)); -- cgit v1.2.3 From c14413c5bf0d2989109b4369fdb95a49f128c169 Mon Sep 17 00:00:00 2001 From: Yuriy Piskarev Date: Mon, 28 Mar 2022 20:12:57 +0300 Subject: - delete variable 'l'; --- .../java/org/traccar/protocol/NavtelecomProtocolDecoder.java | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) (limited to 'src/main/java/org/traccar') diff --git a/src/main/java/org/traccar/protocol/NavtelecomProtocolDecoder.java b/src/main/java/org/traccar/protocol/NavtelecomProtocolDecoder.java index 60f1091bb..df53d7c3d 100644 --- a/src/main/java/org/traccar/protocol/NavtelecomProtocolDecoder.java +++ b/src/main/java/org/traccar/protocol/NavtelecomProtocolDecoder.java @@ -193,7 +193,7 @@ public class NavtelecomProtocolDecoder extends BaseProtocolDecoder { Position position = new Position(getProtocolName()); position.setDeviceId(deviceSession.getDeviceId()); - for (int j = 0, l = 2; j < bits.length(); j++, l++) { + for (int j = 0; j < bits.length(); j++) { if (bits.get(j)) { int value = 0; @@ -246,7 +246,7 @@ public class NavtelecomProtocolDecoder extends BaseProtocolDecoder { case 24: case 25: case 26: - position.set(Position.PREFIX_ADC + (l - 21), buf.readUnsignedShortLE() * 0.001); + position.set(Position.PREFIX_ADC + (j + 2 - 21), buf.readUnsignedShortLE() * 0.001); break; case 29: value = buf.readUnsignedByte(); @@ -262,11 +262,11 @@ public class NavtelecomProtocolDecoder extends BaseProtocolDecoder { break; case 33: case 34: - position.set(Position.PREFIX_COUNT + (l - 33), buf.readUnsignedIntLE()); + position.set(Position.PREFIX_COUNT + (j + 2 - 33), buf.readUnsignedIntLE()); break; case 35: case 36: - position.set("freq" + (l - 35), buf.readUnsignedShortLE()); + position.set("freq" + (j + 2 - 35), buf.readUnsignedShortLE()); break; case 37: position.set("engine_hours", buf.readUnsignedIntLE()); @@ -278,7 +278,7 @@ public class NavtelecomProtocolDecoder extends BaseProtocolDecoder { case 42: case 43: value = buf.readUnsignedShortLE(); - position.set("rs485Fuel" + (l - 38), (value < 65500) ? value : null); + position.set("rs485Fuel" + (j + 2 - 38), (value < 65500) ? value : null); break; case 44: value = buf.readUnsignedShortLE(); @@ -293,7 +293,7 @@ public class NavtelecomProtocolDecoder extends BaseProtocolDecoder { case 51: case 52: value = buf.readByte(); - position.set(Position.PREFIX_TEMP + (l - 45), (value != 0x80) ? value : null); + position.set(Position.PREFIX_TEMP + (j + 2 - 45), (value != 0x80) ? value : null); break; default: buf.skipBytes(getItemLength(j + 1)); -- cgit v1.2.3 From 3a4757af42f4a7382b1b70cf4768023152238b32 Mon Sep 17 00:00:00 2001 From: Yuriy Piskarev Date: Mon, 28 Mar 2022 21:21:21 +0300 Subject: - replacing expression with BitUtil; --- src/main/java/org/traccar/protocol/NavtelecomProtocolDecoder.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/main/java/org/traccar') diff --git a/src/main/java/org/traccar/protocol/NavtelecomProtocolDecoder.java b/src/main/java/org/traccar/protocol/NavtelecomProtocolDecoder.java index df53d7c3d..37729236e 100644 --- a/src/main/java/org/traccar/protocol/NavtelecomProtocolDecoder.java +++ b/src/main/java/org/traccar/protocol/NavtelecomProtocolDecoder.java @@ -211,7 +211,7 @@ public class NavtelecomProtocolDecoder extends BaseProtocolDecoder { case 8: value = buf.readUnsignedByte(); position.setValid(BitUtil.check(value, 1)); - position.set(Position.KEY_SATELLITES, ((value & 0b11111100) >> 2)); + position.set(Position.KEY_SATELLITES, BitUtil.from(value, 2)); break; case 9: position.setFixTime(new Date(buf.readUnsignedIntLE() * 1000)); -- cgit v1.2.3 From c4f36004c11306130f17be2f271d8e95ddf87ffc Mon Sep 17 00:00:00 2001 From: Yuriy Piskarev Date: Mon, 28 Mar 2022 22:00:23 +0300 Subject: - use key KEY_HOURS; --- src/main/java/org/traccar/protocol/NavtelecomProtocolDecoder.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/main/java/org/traccar') diff --git a/src/main/java/org/traccar/protocol/NavtelecomProtocolDecoder.java b/src/main/java/org/traccar/protocol/NavtelecomProtocolDecoder.java index 37729236e..7d6991a2f 100644 --- a/src/main/java/org/traccar/protocol/NavtelecomProtocolDecoder.java +++ b/src/main/java/org/traccar/protocol/NavtelecomProtocolDecoder.java @@ -269,7 +269,7 @@ public class NavtelecomProtocolDecoder extends BaseProtocolDecoder { position.set("freq" + (j + 2 - 35), buf.readUnsignedShortLE()); break; case 37: - position.set("engine_hours", buf.readUnsignedIntLE()); + position.set(Position.KEY_HOURS, buf.readUnsignedIntLE()); break; case 38: case 39: -- cgit v1.2.3