aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAnton Tananaev <anton.tananaev@gmail.com>2013-06-18 22:28:13 +1200
committerAnton Tananaev <anton.tananaev@gmail.com>2013-06-18 22:28:13 +1200
commit2f3c5cac45601f54fa0dd46a23cbd593b5779cc1 (patch)
treee4775c720bb03e8be5e26e8dd5766e9ccac0b2cb
parent62379352b9f8f76ea4d72124af89d64c2e809a1c (diff)
downloadtraccar-server-2f3c5cac45601f54fa0dd46a23cbd593b5779cc1.tar.gz
traccar-server-2f3c5cac45601f54fa0dd46a23cbd593b5779cc1.tar.bz2
traccar-server-2f3c5cac45601f54fa0dd46a23cbd593b5779cc1.zip
Fix V680 decoder (fix #311)
-rw-r--r--src/org/traccar/protocol/V680ProtocolDecoder.java9
-rw-r--r--test/org/traccar/protocol/V680ProtocolDecoderTest.java3
2 files changed, 10 insertions, 2 deletions
diff --git a/src/org/traccar/protocol/V680ProtocolDecoder.java b/src/org/traccar/protocol/V680ProtocolDecoder.java
index e3388576e..53843c23d 100644
--- a/src/org/traccar/protocol/V680ProtocolDecoder.java
+++ b/src/org/traccar/protocol/V680ProtocolDecoder.java
@@ -49,7 +49,7 @@ public class V680ProtocolDecoder extends BaseProtocolDecoder {
"(\\d{2})(\\d{2}\\.\\d+)," + // Latitude (DDMM.MMMM)
"([NS])," +
"(\\d+\\.\\d+)," + // Speed
- "(\\d+\\.?\\d*)#" + // Course
+ "(\\d+\\.?\\d*)?#" + // Course
"(\\d{2})(\\d{2})(\\d{2})#" + // Date (DDMMYY)
"(\\d{2})(\\d{2})(\\d{2})" + // Time (HHMMSS)
".*");
@@ -129,7 +129,12 @@ public class V680ProtocolDecoder extends BaseProtocolDecoder {
// Speed and Course
position.setSpeed(Double.valueOf(parser.group(index++)));
- position.setCourse(Double.valueOf(parser.group(index++)));
+ String course = parser.group(index++);
+ if (course != null) {
+ position.setCourse(Double.valueOf(course));
+ } else {
+ position.setCourse(0.0);
+ }
// Date
Calendar time = Calendar.getInstance(TimeZone.getTimeZone("UTC"));
diff --git a/test/org/traccar/protocol/V680ProtocolDecoderTest.java b/test/org/traccar/protocol/V680ProtocolDecoderTest.java
index 1d1a74878..815a828a7 100644
--- a/test/org/traccar/protocol/V680ProtocolDecoderTest.java
+++ b/test/org/traccar/protocol/V680ProtocolDecoderTest.java
@@ -35,6 +35,9 @@ public class V680ProtocolDecoderTest {
assertNotNull(decoder.decode(null, null,
"#356823031236214##0#0000#AUT#1#V#01904.5491,E,6941.0085,N,000.09,248#170513#160140"));
+
+ assertNotNull(decoder.decode(null, null,
+ "#353588550032869##1#0000#AUT#01#72400401cd01a5#00000.0000,E,0000.0000,N,0.00,#000000#000000.000"));
}