aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAnton Tananaev <anton.tananaev@gmail.com>2012-12-07 17:52:58 +1300
committerAnton Tananaev <anton.tananaev@gmail.com>2012-12-07 17:52:58 +1300
commit9cfee9cc32c5074dba6e8bd888db196bcbb91b87 (patch)
treedb7780d417e8e8baf0f89bbfb763ae060364fde8
parentb444e789127951b902d557517a520d44c59f15d2 (diff)
downloadtrackermap-server-9cfee9cc32c5074dba6e8bd888db196bcbb91b87.tar.gz
trackermap-server-9cfee9cc32c5074dba6e8bd888db196bcbb91b87.tar.bz2
trackermap-server-9cfee9cc32c5074dba6e8bd888db196bcbb91b87.zip
Fixed meiligao parser (fix #104)
-rw-r--r--src/org/traccar/protocol/MeiligaoProtocolDecoder.java3
-rw-r--r--test/org/traccar/protocol/MeiligaoProtocolDecoderTest.java5
2 files changed, 6 insertions, 2 deletions
diff --git a/src/org/traccar/protocol/MeiligaoProtocolDecoder.java b/src/org/traccar/protocol/MeiligaoProtocolDecoder.java
index d5658b9a2..4696343d6 100644
--- a/src/org/traccar/protocol/MeiligaoProtocolDecoder.java
+++ b/src/org/traccar/protocol/MeiligaoProtocolDecoder.java
@@ -46,6 +46,7 @@ public class MeiligaoProtocolDecoder extends GenericProtocolDecoder {
/**
* Regular expressions pattern
*/
+ //"155422.000,V,2230.7623,N,11403.4218,E,0.00,0,060211,,*1A|0.0|26|0000|0000,0000|0000000000000000|63|00000000"
static private Pattern pattern = Pattern.compile(
"(\\d{2})(\\d{2})(\\d{2})\\.(\\d{3})," + // Time (HHMMSS.SSS)
"([AV])," + // Validity
@@ -54,7 +55,7 @@ public class MeiligaoProtocolDecoder extends GenericProtocolDecoder {
"(\\d{3})(\\d{2}\\.\\d{4})," + // Longitude (DDDMM.MMMM)
"([EW])," +
"(\\d+.\\d+)," + // Speed
- "(\\d+\\.?\\d+)?," + // Course
+ "(\\d+\\.?\\d*)?," + // Course
"(\\d{2})(\\d{2})(\\d{2})," + // Date (DDMMYY)
"[^\\|]+\\|(\\d+\\.\\d)\\|" + // Dilution of precision
"(\\d+)\\|" + // Altitude
diff --git a/test/org/traccar/protocol/MeiligaoProtocolDecoderTest.java b/test/org/traccar/protocol/MeiligaoProtocolDecoderTest.java
index d1cd5ff8b..06feff07d 100644
--- a/test/org/traccar/protocol/MeiligaoProtocolDecoderTest.java
+++ b/test/org/traccar/protocol/MeiligaoProtocolDecoderTest.java
@@ -13,7 +13,7 @@ public class MeiligaoProtocolDecoderTest {
MeiligaoProtocolDecoder decoder = new MeiligaoProtocolDecoder(new TestDataManager());
ChannelBufferFactory factory = new HeapChannelBufferFactory();
-
+
byte[] buf1 = {0x12,0x34,0x56,(byte)0xFF,(byte)0xFF,(byte)0xFF,(byte)0xFF,0x50,0x00,(byte)0x8B,(byte)0x9B,0x0D,0x0A};
assertNull(decoder.decode(null, null, factory.getBuffer(buf1, 0, buf1.length)));
@@ -26,6 +26,9 @@ public class MeiligaoProtocolDecoderTest {
byte[] buf4 = {0x16,(byte)0x91,0x00,0x04,(byte)0x84,0x12,0x4F,(byte)0x99,0x55,0x31,0x34,0x30,0x36,0x30,0x33,0x2E,0x30,0x30,0x30,0x2C,0x41,0x2C,0x30,0x39,0x33,0x34,0x2E,0x32,0x35,0x35,0x34,0x2C,0x4E,0x2C,0x30,0x36,0x39,0x31,0x33,0x2E,0x30,0x39,0x36,0x36,0x2C,0x57,0x2C,0x30,0x2E,0x30,0x30,0x2C,0x2C,0x33,0x30,0x31,0x30,0x31,0x32,0x2C,0x2C,0x2A,0x30,0x32,0x7C,0x30,0x2E,0x38,0x7C,0x32,0x30,0x37,0x7C,0x30,0x30,0x30,0x30,(byte)0xFA,0x42,0x0D,0x0A};
assertNotNull(decoder.decode(null, null, factory.getBuffer(buf4, 0, buf4.length)));
+ byte[] buf5 = {0x45,0x12,0x42,0x20,0x30,0x6F,(byte)0xFF,(byte)0x99,(byte)0x99,0x14,0x31,0x35,0x35,0x34,0x32,0x32,0x2E,0x30,0x30,0x30,0x2C,0x56,0x2C,0x32,0x32,0x33,0x30,0x2E,0x37,0x36,0x32,0x33,0x2C,0x4E,0x2C,0x31,0x31,0x34,0x30,0x33,0x2E,0x34,0x32,0x31,0x38,0x2C,0x45,0x2C,0x30,0x2E,0x30,0x30,0x2C,0x30,0x2C,0x30,0x36,0x30,0x32,0x31,0x31,0x2C,0x2C,0x2A,0x31,0x41,0x7C,0x30,0x2E,0x30,0x7C,0x32,0x36,0x7C,0x30,0x30,0x30,0x30,0x7C,0x30,0x30,0x30,0x30,0x2C,0x30,0x30,0x30,0x30,0x7C,0x30,0x30,0x30,0x30,0x30,0x30,0x30,0x30,0x30,0x30,0x30,0x30,0x30,0x30,0x30,0x30,0x7C,0x36,0x33,0x7C,0x30,0x30,0x30,0x30,0x30,0x30,0x30,0x30,(byte)0xBA,(byte)0xC1,0x0D,0x0A};
+ assertNotNull(decoder.decode(null, null, factory.getBuffer(buf5, 0, buf5.length)));
+
}
}