From 78a6d42d3ddc1755d3754c148996f7804d076ccf Mon Sep 17 00:00:00 2001 From: Matjaž Črnko Date: Wed, 20 Oct 2021 20:13:52 +0200 Subject: fix: Totem - More accurate/generic Vehicle Status decoding so it does not show wrong values for AT07 --- .../org/traccar/protocol/TotemProtocolDecoder.java | 30 ++++++++++++++++------ 1 file changed, 22 insertions(+), 8 deletions(-) diff --git a/src/main/java/org/traccar/protocol/TotemProtocolDecoder.java b/src/main/java/org/traccar/protocol/TotemProtocolDecoder.java index f7d0ffde7..758f7f9ba 100644 --- a/src/main/java/org/traccar/protocol/TotemProtocolDecoder.java +++ b/src/main/java/org/traccar/protocol/TotemProtocolDecoder.java @@ -372,17 +372,31 @@ public class TotemProtocolDecoder extends BaseProtocolDecoder { position.set(Position.KEY_ALARM, BitUtil.check(status, 32 - 5) ? Position.ALARM_GEOFENCE_EXIT : null); position.set(Position.KEY_ALARM, BitUtil.check(status, 32 - 6) ? Position.ALARM_GEOFENCE_ENTER : null); position.set(Position.KEY_ALARM, BitUtil.check(status, 32 - 7) ? Position.ALARM_GPS_ANTENNA_CUT : null); + position.set(Position.PREFIX_IO + 8, BitUtil.check(status, 32 - 8)); // GPS Module Error position.set(Position.PREFIX_OUT + 1, BitUtil.check(status, 32 - 9)); position.set(Position.PREFIX_OUT + 2, BitUtil.check(status, 32 - 10)); position.set(Position.PREFIX_OUT + 3, BitUtil.check(status, 32 - 11)); - position.set(Position.PREFIX_OUT + 4, BitUtil.check(status, 32 - 12)); - position.set(Position.PREFIX_IN + 2, BitUtil.check(status, 32 - 13)); - position.set(Position.PREFIX_IN + 3, BitUtil.check(status, 32 - 14)); - position.set(Position.PREFIX_IN + 4, BitUtil.check(status, 32 - 15)); - position.set(Position.KEY_ALARM, BitUtil.check(status, 32 - 16) ? Position.ALARM_SHOCK : null); - position.set(Position.KEY_ALARM, BitUtil.check(status, 32 - 17) ? Position.ALARM_IDLE : null); - position.set(Position.KEY_ALARM, BitUtil.check(status, 32 - 18) ? Position.ALARM_LOW_BATTERY : null); - position.set(Position.KEY_ALARM, BitUtil.check(status, 32 - 22) ? Position.ALARM_JAMMING : null); + + /** + * Different Devices have different meaning for bits 12-22 + * But unfortunately we cannot reliably detect this, so we use generic IO notation + * + * | AT05 | AT07 | AT09 + * 12 | Reserved | IN2 | OUT4 + * 13 | IN2 | IN4 | IN2 + * 14 | IN3 | Shock | IN3 + * 15 | IN4 | Idle | IN4 + * 16 | Shock | Low Batt. | Shock + * 17 | Idle | Drv. Auth. | Idle + * 18 | Low Batt. | GPS Status | Low Batt. + * 19 | Drv. Auth. | Batt. chrg.| Drv. Auth. + * 20 | GPS Status | GSM Jamming| GPS Status + * 21 | Batt. chrg.| Reserved | Batt. chrg. + * 22 | Reserved | Reserved | GSM Jamming + */ + for (int i = 12; i < 23; i++) { + position.set(Position.PREFIX_IO + i, BitUtil.check(status, 32 - i)); + } position.setTime(parser.nextDateTime()); -- cgit v1.2.3 From 3c52988d6549dfd271693096bbf86ed17e532737 Mon Sep 17 00:00:00 2001 From: Matjaž Črnko Date: Wed, 20 Oct 2021 20:26:13 +0200 Subject: fix: Build/style warning --- src/main/java/org/traccar/protocol/TotemProtocolDecoder.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/java/org/traccar/protocol/TotemProtocolDecoder.java b/src/main/java/org/traccar/protocol/TotemProtocolDecoder.java index 758f7f9ba..1d4100932 100644 --- a/src/main/java/org/traccar/protocol/TotemProtocolDecoder.java +++ b/src/main/java/org/traccar/protocol/TotemProtocolDecoder.java @@ -395,7 +395,7 @@ public class TotemProtocolDecoder extends BaseProtocolDecoder { * 22 | Reserved | Reserved | GSM Jamming */ for (int i = 12; i < 23; i++) { - position.set(Position.PREFIX_IO + i, BitUtil.check(status, 32 - i)); + position.set(Position.PREFIX_IO + i, BitUtil.check(status, 32 - i)); } position.setTime(parser.nextDateTime()); -- cgit v1.2.3 From b4de72d4a0bf73998224d08a3bd2ba8310d83f8d Mon Sep 17 00:00:00 2001 From: Matjaž Črnko Date: Wed, 20 Oct 2021 20:39:16 +0200 Subject: fix: Totem - remove individual bit decoding and store the whole status in KEY_STATUS --- .../org/traccar/protocol/TotemProtocolDecoder.java | 21 +++------------------ 1 file changed, 3 insertions(+), 18 deletions(-) diff --git a/src/main/java/org/traccar/protocol/TotemProtocolDecoder.java b/src/main/java/org/traccar/protocol/TotemProtocolDecoder.java index 1d4100932..81948f16d 100644 --- a/src/main/java/org/traccar/protocol/TotemProtocolDecoder.java +++ b/src/main/java/org/traccar/protocol/TotemProtocolDecoder.java @@ -372,31 +372,16 @@ public class TotemProtocolDecoder extends BaseProtocolDecoder { position.set(Position.KEY_ALARM, BitUtil.check(status, 32 - 5) ? Position.ALARM_GEOFENCE_EXIT : null); position.set(Position.KEY_ALARM, BitUtil.check(status, 32 - 6) ? Position.ALARM_GEOFENCE_ENTER : null); position.set(Position.KEY_ALARM, BitUtil.check(status, 32 - 7) ? Position.ALARM_GPS_ANTENNA_CUT : null); - position.set(Position.PREFIX_IO + 8, BitUtil.check(status, 32 - 8)); // GPS Module Error position.set(Position.PREFIX_OUT + 1, BitUtil.check(status, 32 - 9)); position.set(Position.PREFIX_OUT + 2, BitUtil.check(status, 32 - 10)); position.set(Position.PREFIX_OUT + 3, BitUtil.check(status, 32 - 11)); /** * Different Devices have different meaning for bits 12-22 - * But unfortunately we cannot reliably detect this, so we use generic IO notation - * - * | AT05 | AT07 | AT09 - * 12 | Reserved | IN2 | OUT4 - * 13 | IN2 | IN4 | IN2 - * 14 | IN3 | Shock | IN3 - * 15 | IN4 | Idle | IN4 - * 16 | Shock | Low Batt. | Shock - * 17 | Idle | Drv. Auth. | Idle - * 18 | Low Batt. | GPS Status | Low Batt. - * 19 | Drv. Auth. | Batt. chrg.| Drv. Auth. - * 20 | GPS Status | GSM Jamming| GPS Status - * 21 | Batt. chrg.| Reserved | Batt. chrg. - * 22 | Reserved | Reserved | GSM Jamming + * But unfortunately we cannot reliably detect this, so we store the whole status in KEY_STATUS + * See: https://github.com/traccar/traccar/pull/4762 */ - for (int i = 12; i < 23; i++) { - position.set(Position.PREFIX_IO + i, BitUtil.check(status, 32 - i)); - } + position.set(Position.KEY_STATUS, status); position.setTime(parser.nextDateTime()); -- cgit v1.2.3 From 72ada0ce78ee824b2d54cc4d37311ddd7cd216ee Mon Sep 17 00:00:00 2001 From: Matjaž Črnko Date: Wed, 20 Oct 2021 20:42:20 +0200 Subject: Update src/main/java/org/traccar/protocol/TotemProtocolDecoder.java Co-authored-by: Anton Tananaev --- src/main/java/org/traccar/protocol/TotemProtocolDecoder.java | 8 +------- 1 file changed, 1 insertion(+), 7 deletions(-) diff --git a/src/main/java/org/traccar/protocol/TotemProtocolDecoder.java b/src/main/java/org/traccar/protocol/TotemProtocolDecoder.java index 81948f16d..dc4347f00 100644 --- a/src/main/java/org/traccar/protocol/TotemProtocolDecoder.java +++ b/src/main/java/org/traccar/protocol/TotemProtocolDecoder.java @@ -375,13 +375,7 @@ public class TotemProtocolDecoder extends BaseProtocolDecoder { position.set(Position.PREFIX_OUT + 1, BitUtil.check(status, 32 - 9)); position.set(Position.PREFIX_OUT + 2, BitUtil.check(status, 32 - 10)); position.set(Position.PREFIX_OUT + 3, BitUtil.check(status, 32 - 11)); - - /** - * Different Devices have different meaning for bits 12-22 - * But unfortunately we cannot reliably detect this, so we store the whole status in KEY_STATUS - * See: https://github.com/traccar/traccar/pull/4762 - */ - position.set(Position.KEY_STATUS, status); + position.set(Position.KEY_STATUS, status); // see https://github.com/traccar/traccar/pull/4762 position.setTime(parser.nextDateTime()); -- cgit v1.2.3