diff options
author | Anton Tananaev <anton.tananaev@gmail.com> | 2017-06-13 04:43:11 +1200 |
---|---|---|
committer | Anton Tananaev <anton.tananaev@gmail.com> | 2017-06-13 04:43:11 +1200 |
commit | 1df59fb0916ec36604a7771a40f887caebd0e228 (patch) | |
tree | 3460c7498dc18339a32909cce74f884dfeb883f6 | |
parent | 2c82232375a16c1b3f5a62e2e5561d37a482dff9 (diff) | |
download | traccar-server-1df59fb0916ec36604a7771a40f887caebd0e228.tar.gz traccar-server-1df59fb0916ec36604a7771a40f887caebd0e228.tar.bz2 traccar-server-1df59fb0916ec36604a7771a40f887caebd0e228.zip |
Fix GPS103 OBD message decoding
-rw-r--r-- | src/org/traccar/protocol/Gps103ProtocolDecoder.java | 8 | ||||
-rw-r--r-- | test/org/traccar/protocol/Gps103ProtocolDecoderTest.java | 6 |
2 files changed, 10 insertions, 4 deletions
diff --git a/src/org/traccar/protocol/Gps103ProtocolDecoder.java b/src/org/traccar/protocol/Gps103ProtocolDecoder.java index b0113e0be..2b546bb26 100644 --- a/src/org/traccar/protocol/Gps103ProtocolDecoder.java +++ b/src/org/traccar/protocol/Gps103ProtocolDecoder.java @@ -90,10 +90,10 @@ public class Gps103ProtocolDecoder extends BaseProtocolDecoder { .number("(d+),") // odometer .number("(d+.d+)?,") // fuel instant .number("(d+.d+)?,") // fuel average - .number("(d+),") // hours + .number("(d+)?,") // hours .number("(d+),") // speed .number("d+.?d*%,") // power load - .number("(d+),") // temperature + .number("(?:([-+]?d+)|[-+]?),") // temperature .number("(d+.?d*%),") // throttle .number("(d+),") // rpm .number("(d+.d+),") // battery @@ -209,9 +209,9 @@ public class Gps103ProtocolDecoder extends BaseProtocolDecoder { position.set(Position.KEY_ODOMETER, parser.nextInt(0)); parser.nextDouble(0); // instant fuel consumption position.set(Position.KEY_FUEL_CONSUMPTION, parser.nextDouble(0)); - position.set(Position.KEY_HOURS, parser.nextInt(0)); + position.set(Position.KEY_HOURS, parser.nextInt()); position.set(Position.KEY_OBD_SPEED, parser.nextInt(0)); - position.set(Position.PREFIX_TEMP + 1, parser.nextInt(0)); + position.set(Position.PREFIX_TEMP + 1, parser.nextInt()); position.set(Position.KEY_THROTTLE, parser.next()); position.set(Position.KEY_RPM, parser.nextInt(0)); position.set(Position.KEY_BATTERY, parser.nextDouble(0)); diff --git a/test/org/traccar/protocol/Gps103ProtocolDecoderTest.java b/test/org/traccar/protocol/Gps103ProtocolDecoderTest.java index c1f29add6..345a89ad9 100644 --- a/test/org/traccar/protocol/Gps103ProtocolDecoderTest.java +++ b/test/org/traccar/protocol/Gps103ProtocolDecoderTest.java @@ -10,6 +10,12 @@ public class Gps103ProtocolDecoderTest extends ProtocolTest { Gps103ProtocolDecoder decoder = new Gps103ProtocolDecoder(new Gps103Protocol()); + verifyAttributes(decoder, text( + "imei:862106025092216,OBD,170612165656,196043,,145803.9,,000,0.0%,+,0.0%,00000,12.6,,,,;")); + + verifyAttributes(decoder, text( + "imei:862106025092216,OBD,170605095949,195874,,370.8,808,066,30.0%,+87,13.0%,02444,14.3,,,,;")); + verifyPosition(decoder, text( "imei:353451044508750,DTC,0809231929,,F,055403.000,A,2233.1870,N,11354.3067,E,0.00,30.1,,1,0,10.5%,P0021,;")); |