aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAnton Tananaev <anton.tananaev@gmail.com>2020-09-18 00:02:08 -0700
committerAnton Tananaev <anton.tananaev@gmail.com>2020-09-18 00:02:08 -0700
commit34feb9862f03ad0b10ce6425943a9b43a7d5c71f (patch)
tree87904b6b1228fc07c4a1b66eb4e24b0eb879f4e0
parentbe296c9342c69b2ccb0136abccb2167f395e9e95 (diff)
downloadtraccar-server-34feb9862f03ad0b10ce6425943a9b43a7d5c71f.tar.gz
traccar-server-34feb9862f03ad0b10ce6425943a9b43a7d5c71f.tar.bz2
traccar-server-34feb9862f03ad0b10ce6425943a9b43a7d5c71f.zip
Decode odometer value
-rw-r--r--src/main/java/org/traccar/protocol/ItsProtocolDecoder.java8
-rw-r--r--src/test/java/org/traccar/protocol/ItsProtocolDecoderTest.java4
2 files changed, 12 insertions, 0 deletions
diff --git a/src/main/java/org/traccar/protocol/ItsProtocolDecoder.java b/src/main/java/org/traccar/protocol/ItsProtocolDecoder.java
index f66669a98..94c9a3038 100644
--- a/src/main/java/org/traccar/protocol/ItsProtocolDecoder.java
+++ b/src/main/java/org/traccar/protocol/ItsProtocolDecoder.java
@@ -90,6 +90,10 @@ public class ItsProtocolDecoder extends BaseProtocolDecoder {
.number("(-?d+),") // tilt x
.or()
.number("d+,") // index
+ .number("(d+.?d*),") // odometer
+ .number("x+,") // checksum
+ .or()
+ .number("d+,") // index
.number("(d+.?d*),") // adc1
.number("(d+.?d*),") // adc2
.groupEnd("?")
@@ -244,6 +248,10 @@ public class ItsProtocolDecoder extends BaseProtocolDecoder {
position.set("tiltX", parser.nextInt());
}
+ if (parser.hasNext()) {
+ position.set(Position.KEY_ODOMETER, parser.nextDouble() * 1000);
+ }
+
if (parser.hasNext(2)) {
position.set(Position.PREFIX_ADC + 1, parser.nextDouble());
position.set(Position.PREFIX_ADC + 2, parser.nextDouble());
diff --git a/src/test/java/org/traccar/protocol/ItsProtocolDecoderTest.java b/src/test/java/org/traccar/protocol/ItsProtocolDecoderTest.java
index 4f5a63188..69abfd837 100644
--- a/src/test/java/org/traccar/protocol/ItsProtocolDecoderTest.java
+++ b/src/test/java/org/traccar/protocol/ItsProtocolDecoderTest.java
@@ -14,6 +14,10 @@ public class ItsProtocolDecoderTest extends ProtocolTest {
verifyNull(decoder, text(
"$LGN,,869867037009679,3.2AIH,9.99546000,N,76.35886167,E"));
+ verifyAttribute(decoder, text(
+ "$,C,CTPL,4.0.0,NR,01,L,869247045166383,NA00000000,1,12032020,144453,30.452524,N,077.610351,E,1.4,34.8,14,384.19,1.8,0.8,IDEA P,1,1,14.2,4.17,0,C,22,404,82,0FB1,3B26,516B,0FB1,18,3B25,0FB1,15,5169,0FB1,14,3B27,0FB1,13,0000,00,8083,194.9,0B,*,IP=106.67.5.173"),
+ Position.KEY_ODOMETER, 194900.0);
+
verifyPosition(decoder, text(
"$,EPB,SEM,868997031721531,NM,14072020112020,A,28.359959,N,076.927566,E,260.93,0.1,0.0,G,NA00000000,N.A0000000,*"));