diff options
author | Anton Tananaev <anton.tananaev@gmail.com> | 2015-08-07 11:40:12 +1200 |
---|---|---|
committer | Anton Tananaev <anton.tananaev@gmail.com> | 2015-08-07 11:40:12 +1200 |
commit | 74f54436bc43b9d2ed9d3d06760c7aaae9464b4b (patch) | |
tree | 2c3f0f6083e40be4a1eaefc86b7648495cc9122c | |
parent | 9a40169b25e52fe15008eca61867dd1f81a31fba (diff) | |
download | trackermap-server-74f54436bc43b9d2ed9d3d06760c7aaae9464b4b.tar.gz trackermap-server-74f54436bc43b9d2ed9d3d06760c7aaae9464b4b.tar.bz2 trackermap-server-74f54436bc43b9d2ed9d3d06760c7aaae9464b4b.zip |
Fix Totem regex parser
-rw-r--r-- | src/org/traccar/protocol/TotemProtocolDecoder.java | 11 | ||||
-rw-r--r-- | test/org/traccar/protocol/TotemProtocolDecoderTest.java | 3 |
2 files changed, 10 insertions, 4 deletions
diff --git a/src/org/traccar/protocol/TotemProtocolDecoder.java b/src/org/traccar/protocol/TotemProtocolDecoder.java index ef4c6e5eb..a22bbf71e 100644 --- a/src/org/traccar/protocol/TotemProtocolDecoder.java +++ b/src/org/traccar/protocol/TotemProtocolDecoder.java @@ -64,8 +64,9 @@ public class TotemProtocolDecoder extends BaseProtocolDecoder { "(\\d+.\\d+)\\|" + // Odometer "\\d+\\|" + // Serial Number ".*\\|?" + - "\\p{XDigit}{4}"); // Checksum - + "\\p{XDigit}{4}" + // Checksum + "\r?\n?"); + private static final Pattern patternSecond = Pattern.compile( "\\$\\$" + // Header "\\p{XDigit}{2}" + // Length @@ -90,7 +91,8 @@ public class TotemProtocolDecoder extends BaseProtocolDecoder { "(\\d+)\\|" + // Temperature "(\\d+.\\d+)\\|" + // Odometer "\\d+\\|" + // Serial Number - "\\p{XDigit}{4}"); // Checksum + "\\p{XDigit}{4}" + // Checksum + "\r?\n?"); private static final Pattern patternThird = Pattern.compile( "\\$\\$" + // Header @@ -119,7 +121,8 @@ public class TotemProtocolDecoder extends BaseProtocolDecoder { "(\\d{3})(\\d{2}\\.\\d{4})" + // Longitude (DDDMM.MMMM) "([EW])" + "\\d{4}" + // Serial Number - "\\p{XDigit}{4}"); // Checksum + "\\p{XDigit}{4}" + // Checksum + "\r?\n?"); private enum MessageFormat { first, diff --git a/test/org/traccar/protocol/TotemProtocolDecoderTest.java b/test/org/traccar/protocol/TotemProtocolDecoderTest.java index c845d12a6..cdb6be355 100644 --- a/test/org/traccar/protocol/TotemProtocolDecoderTest.java +++ b/test/org/traccar/protocol/TotemProtocolDecoderTest.java @@ -15,6 +15,9 @@ public class TotemProtocolDecoderTest extends ProtocolDecoderTest { verify(decoder.decode(null, null, "$$AE860990002922822|AA$GPRMC,051002.00,A,0439.26245,N,10108.94448,E,0.023,,140315,,,A*71|02.98|01.95|02.26|000000000000|20150314051003|13841157|105A3B1C|0000|0.0000|0005|5324")); + verify(decoder.decode(null, null, + "$$AE860990002922822|AA$GPRMC,051002.00,A,0439.26245,N,10108.94448,E,0.023,,140315,,,A*71|02.98|01.95|02.26|000000000000|20150314051003|13841157|105A3B1C|0000|0.0000|0005|5324\r")); + assertNull(decoder.decode(null, null, "$$BB862170017856731|AA$GPRMC,000000.00,V,0000.0000,N,00000.0000,E,000.0,000.0,000000,,,A*73|00.0|00.0|00.0|000000001000|20000000000000|13790000|00000000|00000000|00000000|0.0000|0007|8C23")); |