aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAnton Tananaev <anton.tananaev@gmail.com>2018-11-09 20:35:34 +1300
committerAnton Tananaev <anton.tananaev@gmail.com>2018-11-09 20:35:34 +1300
commit76f85aee7141d1e7e75f59c46d7325fe35d08c19 (patch)
treee7dc95486ed09c0a302950152fab9b1f378d190a
parent806584d5d19f224eb26cade7096926af9cc0e4c2 (diff)
downloadtraccar-server-76f85aee7141d1e7e75f59c46d7325fe35d08c19.tar.gz
traccar-server-76f85aee7141d1e7e75f59c46d7325fe35d08c19.tar.bz2
traccar-server-76f85aee7141d1e7e75f59c46d7325fe35d08c19.zip
Improve GV500 GTFRI decoding
-rw-r--r--src/org/traccar/protocol/Gl200TextProtocolDecoder.java16
-rw-r--r--test/org/traccar/protocol/Gl200TextProtocolDecoderTest.java3
2 files changed, 11 insertions, 8 deletions
diff --git a/src/org/traccar/protocol/Gl200TextProtocolDecoder.java b/src/org/traccar/protocol/Gl200TextProtocolDecoder.java
index 45b80f0a6..0d600e240 100644
--- a/src/org/traccar/protocol/Gl200TextProtocolDecoder.java
+++ b/src/org/traccar/protocol/Gl200TextProtocolDecoder.java
@@ -190,9 +190,6 @@ public class Gl200TextProtocolDecoder extends BaseProtocolDecoder {
.expression(PATTERN_LOCATION.pattern())
.expression(")+)")
.groupBegin()
- .number("(d{1,7}.d)?,").optional() // odometer
- .number("(d{1,3})?,") // battery
- .or()
.number("(d{1,7}.d)?,") // odometer
.number("(d{5}:dd:dd)?,") // hour meter
.number("(x+)?,") // adc 1
@@ -202,6 +199,9 @@ public class Gl200TextProtocolDecoder extends BaseProtocolDecoder {
.number("(d+)?,") // rpm
.number("(?:d+.?d*|Inf|NaN)?,") // fuel consumption
.number("(d+)?,") // fuel level
+ .or()
+ .number("(d{1,7}.d)?,").optional() // odometer
+ .number("(d{1,3})?,") // battery
.groupEnd()
.any()
.number("(dddd)(dd)(dd)") // date (yyyymmdd)
@@ -743,11 +743,6 @@ public class Gl200TextProtocolDecoder extends BaseProtocolDecoder {
if (parser.hasNext()) {
position.set(Position.KEY_ODOMETER, parser.nextDouble() * 1000);
}
- position.set(Position.KEY_BATTERY_LEVEL, parser.nextInt());
-
- if (parser.hasNext()) {
- position.set(Position.KEY_ODOMETER, parser.nextDouble() * 1000);
- }
position.set(Position.KEY_HOURS, parseHours(parser.next()));
position.set(Position.PREFIX_ADC + 1, parser.next());
position.set(Position.PREFIX_ADC + 2, parser.next());
@@ -758,6 +753,11 @@ public class Gl200TextProtocolDecoder extends BaseProtocolDecoder {
position.set(Position.KEY_RPM, parser.nextInt());
position.set(Position.KEY_FUEL_LEVEL, parser.nextInt());
+ if (parser.hasNext()) {
+ position.set(Position.KEY_ODOMETER, parser.nextDouble() * 1000);
+ }
+ position.set(Position.KEY_BATTERY_LEVEL, parser.nextInt());
+
decodeDeviceTime(position, parser);
if (ignoreFixTime) {
positions.clear();
diff --git a/test/org/traccar/protocol/Gl200TextProtocolDecoderTest.java b/test/org/traccar/protocol/Gl200TextProtocolDecoderTest.java
index 75edb367c..cc5ef63d4 100644
--- a/test/org/traccar/protocol/Gl200TextProtocolDecoderTest.java
+++ b/test/org/traccar/protocol/Gl200TextProtocolDecoderTest.java
@@ -10,6 +10,9 @@ public class Gl200TextProtocolDecoderTest extends ProtocolTest {
Gl200TextProtocolDecoder decoder = new Gl200TextProtocolDecoder(null);
+ verifyPositions(decoder, buffer(
+ "+RESP:GTFRI,1F0301,862193022001432,WF0GXXGBBGBM26503,,14900,41,1,1,11.6,74,356.0,14.120023,50.167894,20181104080703,0230,0003,9B14,5891,00,74.1,,,,83,220000,799,7.3,,20181104080703,099B$"));
+
verifyPosition(decoder, buffer(
"+RESP:GTCAN,4B0201,867995030001575,,10,0,C03FFFFF,,0,H0,,,,,,,,,,0.00,0.03,,,,0,,0,,,0,10.0,310,404.3,14.096743,50.143363,20181102110535,0230,0003,9B14,5066,00,20181102112101,03E0$"));