diff options
author | Anton Tananaev <anton.tananaev@gmail.com> | 2017-05-06 09:44:27 +1200 |
---|---|---|
committer | Anton Tananaev <anton.tananaev@gmail.com> | 2017-05-06 09:44:27 +1200 |
commit | f35567956593f78f3f9630add815710b9df47634 (patch) | |
tree | bbb54ce1f7933dbc05341348f375b82be2a6a9c0 | |
parent | 841965ba439654f76dcd7fc63efd70647f23f29f (diff) | |
download | trackermap-server-f35567956593f78f3f9630add815710b9df47634.tar.gz trackermap-server-f35567956593f78f3f9630add815710b9df47634.tar.bz2 trackermap-server-f35567956593f78f3f9630add815710b9df47634.zip |
Fix PT502 coordinates decoding
-rw-r--r-- | src/org/traccar/protocol/Pt502ProtocolDecoder.java | 10 | ||||
-rw-r--r-- | test/org/traccar/protocol/Pt502ProtocolDecoderTest.java | 6 |
2 files changed, 10 insertions, 6 deletions
diff --git a/src/org/traccar/protocol/Pt502ProtocolDecoder.java b/src/org/traccar/protocol/Pt502ProtocolDecoder.java index eb86f01ff..b1851f8ca 100644 --- a/src/org/traccar/protocol/Pt502ProtocolDecoder.java +++ b/src/org/traccar/protocol/Pt502ProtocolDecoder.java @@ -1,5 +1,5 @@ /*
- * Copyright 2012 - 2016 Anton Tananaev (anton@traccar.org)
+ * Copyright 2012 - 2017 Anton Tananaev (anton@traccar.org)
* Copyright 2012 Luis Parada (luis.parada@gmail.com)
*
* Licensed under the Apache License, Version 2.0 (the "License");
@@ -43,9 +43,9 @@ public class Pt502ProtocolDecoder extends BaseProtocolDecoder { .number("(d+),") // id
.number("(dd)(dd)(dd).(ddd),") // time (hhmmss.sss)
.expression("([AV]),") // validity
- .number("(dd)(dd.dddd),") // latitude
+ .number("(d+)(dd.dddd),") // latitude
.expression("([NS]),")
- .number("(ddd)(dd.dddd),") // longitude
+ .number("(d+)(dd.dddd),") // longitude
.expression("([EW]),")
.number("(d+.d+)?,") // speed
.number("(d+.d+)?,") // course
@@ -83,9 +83,7 @@ public class Pt502ProtocolDecoder extends BaseProtocolDecoder { protected Object decode(
Channel channel, SocketAddress remoteAddress, Object msg) throws Exception {
- String sentence = (String) msg;
-
- Parser parser = new Parser(PATTERN, sentence);
+ Parser parser = new Parser(PATTERN, (String) msg);
if (!parser.matches()) {
return null;
}
diff --git a/test/org/traccar/protocol/Pt502ProtocolDecoderTest.java b/test/org/traccar/protocol/Pt502ProtocolDecoderTest.java index 8b1dd5ad6..62b3bbdaa 100644 --- a/test/org/traccar/protocol/Pt502ProtocolDecoderTest.java +++ b/test/org/traccar/protocol/Pt502ProtocolDecoderTest.java @@ -11,6 +11,12 @@ public class Pt502ProtocolDecoderTest extends ProtocolTest { Pt502ProtocolDecoder decoder = new Pt502ProtocolDecoder(new Pt502Protocol()); verifyPosition(decoder, text( + "$POS,865328026243864,151105.000,A,1332.7096,N,204.6787,E,0.0,10.00,050517,,,A/00000,10/1,0/234//FD9/")); + + verifyNull(decoder, text( + "$FUS865328026243864,510-V1.12,A11-V3.0")); + + verifyPosition(decoder, text( "$HDA,20007,134657.000,A,0626.1607,N,00330.2245,E,33.38,81.79,041016,,,A/00010,00000/270,0,0,0/19948900//fa4//")); verifyPosition(decoder, text( |