diff options
author | Anton Tananaev <anton@traccar.org> | 2023-11-23 14:06:02 -0800 |
---|---|---|
committer | Anton Tananaev <anton@traccar.org> | 2023-11-23 14:06:02 -0800 |
commit | 41b5577dd8574309104c880191a35ba3bca600d4 (patch) | |
tree | aad91ebbd3f85cbb05c0599e807dbce2f5b3aa25 /src | |
parent | c4d2cf73f5a66759f7940ba4c11ec63976c05367 (diff) | |
download | trackermap-server-41b5577dd8574309104c880191a35ba3bca600d4.tar.gz trackermap-server-41b5577dd8574309104c880191a35ba3bca600d4.tar.bz2 trackermap-server-41b5577dd8574309104c880191a35ba3bca600d4.zip |
Fix RST ignition value
Diffstat (limited to 'src')
-rw-r--r-- | src/main/java/org/traccar/protocol/RstProtocolDecoder.java | 23 | ||||
-rw-r--r-- | src/test/java/org/traccar/protocol/RstProtocolDecoderTest.java | 4 |
2 files changed, 17 insertions, 10 deletions
diff --git a/src/main/java/org/traccar/protocol/RstProtocolDecoder.java b/src/main/java/org/traccar/protocol/RstProtocolDecoder.java index fcc96fbf1..d53675b7f 100644 --- a/src/main/java/org/traccar/protocol/RstProtocolDecoder.java +++ b/src/main/java/org/traccar/protocol/RstProtocolDecoder.java @@ -1,5 +1,5 @@ /* - * Copyright 2019 - 2021 Anton Tananaev (anton@traccar.org) + * Copyright 2019 - 2023 Anton Tananaev (anton@traccar.org) * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -42,7 +42,7 @@ public class RstProtocolDecoder extends BaseProtocolDecoder { .expression("(.{5});") // firmware .number("(d{9});") // serial number .number("(d+);") // index - .number("(d+);") // type + .number("d+;") // type .groupBegin() .number("(dd)-(dd)-(dddd) ") // event date .number("(dd):(dd):(dd);") // event time @@ -87,7 +87,6 @@ public class RstProtocolDecoder extends BaseProtocolDecoder { String firmware = parser.next(); String serial = parser.next(); int index = parser.nextInt(); - int type = parser.nextInt(); if (channel != null) { String response = "RST;A;" + model + ";" + firmware + ";" + serial + ";" + index + ";6;FIM;"; @@ -115,9 +114,16 @@ public class RstProtocolDecoder extends BaseProtocolDecoder { position.set(Position.KEY_SATELLITES, parser.nextInt()); position.set(Position.KEY_HDOP, parser.nextInt()); - position.set(Position.PREFIX_IN + 1, parser.nextHexInt()); - position.set(Position.PREFIX_IN + 2, parser.nextHexInt()); - position.set(Position.PREFIX_IN + 3, parser.nextHexInt()); + + int inputs1 = parser.nextHexInt(); + int inputs2 = parser.nextHexInt(); + int inputs3 = parser.nextHexInt(); + position.set(Position.PREFIX_IN + 1, inputs1); + position.set(Position.PREFIX_IN + 2, inputs2); + position.set(Position.PREFIX_IN + 3, inputs3); + + position.set(Position.KEY_IGNITION, BitUtil.check(inputs2, 7)); + position.set(Position.PREFIX_OUT + 1, parser.nextHexInt()); position.set(Position.PREFIX_OUT + 2, parser.nextHexInt()); position.set(Position.KEY_POWER, parser.nextDouble()); @@ -125,10 +131,7 @@ public class RstProtocolDecoder extends BaseProtocolDecoder { position.set(Position.KEY_ODOMETER, parser.nextInt()); position.set(Position.KEY_RSSI, parser.nextInt()); position.set(Position.PREFIX_TEMP + 1, (int) parser.nextHexInt().byteValue()); - - int status = (parser.nextHexInt() << 8) + parser.nextHexInt(); - position.set(Position.KEY_IGNITION, BitUtil.check(status, 7)); - position.set(Position.KEY_STATUS, status); + position.set(Position.KEY_STATUS, (parser.nextHexInt() << 8) + parser.nextHexInt()); return position; diff --git a/src/test/java/org/traccar/protocol/RstProtocolDecoderTest.java b/src/test/java/org/traccar/protocol/RstProtocolDecoderTest.java index 13095765b..0e8aefe51 100644 --- a/src/test/java/org/traccar/protocol/RstProtocolDecoderTest.java +++ b/src/test/java/org/traccar/protocol/RstProtocolDecoderTest.java @@ -14,6 +14,10 @@ public class RstProtocolDecoderTest extends ProtocolTest { verifyNull(decoder, text( "RST;A;RST-MINIv2;V7.04;008051261;124;29;04-04-2021 17:27:26;04-04-2021 17:27:26;-1.280811;-47.931755;7353;79;1;14;7315;26;10;0;1855;0;0;0;0;5;5;-1.280821;-47.931747;04-04-2021 17:52:23;6;-1.280863;-47.931770;04-04-2021 18:12:19;5;-1.280844;-47.931763;04-04-2021 17:28:02;5;-1.280900;-47.931770;04-04-2021 19:04:27;4;-1.280843;-47.931747;04-04-2021 18:21:45;04-04-2021 19:29:59;04-04-2021 19:29:59;-1.280770;-47.931595;1;15;0;0;0;0;FIM;")); + verifyAttribute(decoder, text( + "RST;A;RST-MINI-4Gv3;V9.10;009521405;13;1;21-11-2023 20:04:18;21-11-2023 20:04:18;-12.923627;-38.388287;1;165;29;1;5;2;00;B0;00;1A;02;11.89;3.90;73;31;FE;0000;01;40;00800061;0;184;2;4;4;6;434.0000;2;0;-49;1815;37391;724;255;263;00000000;FIM;"), + Position.KEY_IGNITION, true); + verifyPosition(decoder, text( "RST;L;RST-MINIv2;V7.02;008068078;61;1;27-01-2020 21:36:33;27-01-2020 21:36:33;-16.696159;-49.284275;0;67;786;1;15;0;00;B0;00;19;06;12.42;4.16;79;20;FE;0000;01;E0;00800020;0;467;FIM;")); |