diff options
author | Anton Tananaev <anton.tananaev@gmail.com> | 2013-12-01 20:13:51 +1300 |
---|---|---|
committer | Anton Tananaev <anton.tananaev@gmail.com> | 2013-12-01 20:13:51 +1300 |
commit | 1644fb040d087a570afab3030dba5260075d64a6 (patch) | |
tree | ee22c432c6343bb3bf5b1698c567f7c5cc96d1c2 | |
parent | da39a23c3811c139b124f708fb097772b63b5c3d (diff) | |
download | traccar-server-1644fb040d087a570afab3030dba5260075d64a6.tar.gz traccar-server-1644fb040d087a570afab3030dba5260075d64a6.tar.bz2 traccar-server-1644fb040d087a570afab3030dba5260075d64a6.zip |
Fix meiligao decoder (fix #463)
-rw-r--r-- | src/org/traccar/protocol/MeiligaoProtocolDecoder.java | 11 | ||||
-rw-r--r-- | test/org/traccar/protocol/MeiligaoProtocolDecoderTest.java | 3 |
2 files changed, 11 insertions, 3 deletions
diff --git a/src/org/traccar/protocol/MeiligaoProtocolDecoder.java b/src/org/traccar/protocol/MeiligaoProtocolDecoder.java index b79e6505c..b28b38dc8 100644 --- a/src/org/traccar/protocol/MeiligaoProtocolDecoder.java +++ b/src/org/traccar/protocol/MeiligaoProtocolDecoder.java @@ -45,7 +45,7 @@ public class MeiligaoProtocolDecoder extends BaseProtocolDecoder { "([NS])," + "(\\d+)(\\d{2}\\.\\d+)," + // Longitude (DDDMM.MMMM) "([EW])," + - "(\\d+.\\d+)," + // Speed + "(\\d+\\.?\\d*)?," + // Speed "(\\d+\\.?\\d*)?," + // Course "(\\d{2})(\\d{2})(\\d{2})" + // Date (DDMMYY) "(?:[^\\|]*\\|(\\d+\\.\\d+)\\|" + // Dilution of precision @@ -164,7 +164,7 @@ public class MeiligaoProtocolDecoder extends BaseProtocolDecoder { } // Validity - position.setValid(parser.group(index++).compareTo("A") == 0 ? true : false); + position.setValid(parser.group(index++).compareTo("A") == 0); // Latitude Double latitude = Double.valueOf(parser.group(index++)); @@ -179,7 +179,12 @@ public class MeiligaoProtocolDecoder extends BaseProtocolDecoder { position.setLongitude(longitude); // Speed - position.setSpeed(Double.valueOf(parser.group(index++))); + String speed = parser.group(index++); + if (speed != null) { + position.setSpeed(Double.valueOf(speed)); + } else { + position.setSpeed(0.0); + } // Course String course = parser.group(index++); diff --git a/test/org/traccar/protocol/MeiligaoProtocolDecoderTest.java b/test/org/traccar/protocol/MeiligaoProtocolDecoderTest.java index 80da07a14..0580b998d 100644 --- a/test/org/traccar/protocol/MeiligaoProtocolDecoderTest.java +++ b/test/org/traccar/protocol/MeiligaoProtocolDecoderTest.java @@ -53,6 +53,9 @@ public class MeiligaoProtocolDecoderTest { int[] buf12 = {0x67,0x62,0x20,0x10,0x05,0x35,0x62,0xaa,0x00,0x00,0x01,0x00,0x01,0xae,0x4f,0x00,0x00,0x00,0x07,0x80,0x00,0x00,0x00,0x30,0x39,0x35,0x31,0x35,0x36,0x2e,0x30,0x30,0x30,0x2c,0x41,0x2c,0x32,0x36,0x32,0x33,0x2e,0x38,0x39,0x36,0x36,0x2c,0x4e,0x2c,0x30,0x35,0x30,0x30,0x35,0x2e,0x30,0x36,0x38,0x30,0x2c,0x45,0x2c,0x32,0x34,0x2e,0x35,0x2c,0x32,0x34,0x31,0x2e,0x30,0x2c,0x32,0x32,0x31,0x30,0x31,0x33,0x59,0x9c,0x0d,0x0a}; assertNull(decoder.decode(null, null, ChannelBuffers.wrappedBuffer(ChannelBufferTools.convertArray(buf12)))); + + int[] buf13 = {0x10,0x07,0xff,0xff,0xff,0xff,0xff,0x99,0x55,0x31,0x36,0x32,0x33,0x30,0x39,0x2e,0x30,0x35,0x34,0x2c,0x56,0x2c,0x30,0x39,0x33,0x31,0x2e,0x39,0x31,0x36,0x33,0x2c,0x4e,0x2c,0x30,0x36,0x39,0x31,0x31,0x2e,0x38,0x32,0x33,0x33,0x2c,0x57,0x2c,0x2c,0x2c,0x32,0x35,0x31,0x31,0x31,0x33,0x2c,0x2c,0x2c,0x4e,0x2a,0x36,0x43,0x7c,0x7c,0x31,0x35,0x38,0x7c,0x30,0x30,0x30,0x30,0x9c,0xc6,0x0d,0x0a}; + verify(decoder.decode(null, null, ChannelBuffers.wrappedBuffer(ChannelBufferTools.convertArray(buf13)))); } |