aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAnton Tananaev <anton.tananaev@gmail.com>2018-11-15 11:19:37 +1300
committerAnton Tananaev <anton.tananaev@gmail.com>2018-11-15 11:19:37 +1300
commit7de7d81c59eef4a134e313615012a2694a8ca572 (patch)
treecd84384a76dda1541d5963df9307a4ade7e5d0e8
parent3f44240490ccb0cfc0da59cb5ecf101bf622ae1d (diff)
downloadtraccar-server-7de7d81c59eef4a134e313615012a2694a8ca572.tar.gz
traccar-server-7de7d81c59eef4a134e313615012a2694a8ca572.tar.bz2
traccar-server-7de7d81c59eef4a134e313615012a2694a8ca572.zip
Fix ITS speed decoding
-rw-r--r--src/org/traccar/protocol/ItsProtocolDecoder.java21
-rw-r--r--test/org/traccar/protocol/ItsProtocolDecoderTest.java3
2 files changed, 21 insertions, 3 deletions
diff --git a/src/org/traccar/protocol/ItsProtocolDecoder.java b/src/org/traccar/protocol/ItsProtocolDecoder.java
index 226c27cd8..d3cdb14c3 100644
--- a/src/org/traccar/protocol/ItsProtocolDecoder.java
+++ b/src/org/traccar/protocol/ItsProtocolDecoder.java
@@ -57,8 +57,14 @@ public class ItsProtocolDecoder extends BaseProtocolDecoder {
.expression("([AV]),").optional() // valid
.number("(d+.d+),([NS]),") // latitude
.number("(d+.d+),([EW]),") // longitude
- .number("(-?d+.d+),").optional() // altitude
+ .groupBegin()
+ .number("(d+.d+),") // speed
+ .number("(d+.d+),") // course
+ .number("(d+),") // satellites
+ .or()
+ .number("(-?d+.d+),") // altitude
.number("(d+.d+),") // speed
+ .groupEnd()
.any()
.compile();
@@ -88,8 +94,17 @@ public class ItsProtocolDecoder extends BaseProtocolDecoder {
}
position.setLatitude(parser.nextCoordinate(Parser.CoordinateFormat.DEG_HEM));
position.setLongitude(parser.nextCoordinate(Parser.CoordinateFormat.DEG_HEM));
- position.setAltitude(parser.nextDouble(0));
- position.setSpeed(UnitsConverter.knotsFromKph(parser.nextDouble()));
+
+ if (parser.hasNext(3)) {
+ position.setSpeed(UnitsConverter.knotsFromKph(parser.nextDouble()));
+ position.setCourse(parser.nextDouble());
+ position.set(Position.KEY_SATELLITES, parser.nextInt());
+ }
+
+ if (parser.hasNext()) {
+ position.setAltitude(parser.nextDouble(0));
+ position.setSpeed(UnitsConverter.knotsFromKph(parser.nextDouble()));
+ }
return position;
}
diff --git a/test/org/traccar/protocol/ItsProtocolDecoderTest.java b/test/org/traccar/protocol/ItsProtocolDecoderTest.java
index 7aeb66b7b..0abddc662 100644
--- a/test/org/traccar/protocol/ItsProtocolDecoderTest.java
+++ b/test/org/traccar/protocol/ItsProtocolDecoderTest.java
@@ -11,6 +11,9 @@ public class ItsProtocolDecoderTest extends ProtocolTest {
ItsProtocolDecoder decoder = new ItsProtocolDecoder(null);
verifyPosition(decoder, text(
+ "$,04,XYZ123,0.0.1,TA,16,L,861359034100626,MH12AB1234,1,12,11,2018,08,53,08,018.489645,N,073.855972,E,000.0,220.04,12,593.0,01.13,00.75,AIRTEL,1,1,00.0,4.1,1,C,18,404,90,0c23,781a,5169,0c23,-093,0000,0000,0000,0000,0000,0000,0000,0000,0000,1000,01,000006,f906c65c,"));
+
+ verifyPosition(decoder, text(
"$,A,MFR,7.0,NR,01,L,869026034780985,PJ09BU1234,1,12112018,121953,12.756974,N,077.800025,E,000.0,318.03,15,794.0,001.3,000.7,TAMIL NAD,0,1,13.08,04.13,0,O,22,404,80,0919,71C1,0919,7168,19,0919,71c3,17,0919,71c2,11,0919,7167,09,0011,00,000173,D8,000000.00,,,"));
verifyPosition(decoder, text(