aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAnton Tananaev <anton.tananaev@gmail.com>2015-09-12 21:45:59 +1200
committerAnton Tananaev <anton.tananaev@gmail.com>2015-09-12 21:45:59 +1200
commit9cc4cb27a5de80794f11a2e659ecde0e44bbb7b6 (patch)
tree75862e3d902e50fd132f3e6b5311bddfa1fde0f1
parent1a43a20487bf187c6c759eedce273b38159ea140 (diff)
downloadtrackermap-server-9cc4cb27a5de80794f11a2e659ecde0e44bbb7b6.tar.gz
trackermap-server-9cc4cb27a5de80794f11a2e659ecde0e44bbb7b6.tar.bz2
trackermap-server-9cc4cb27a5de80794f11a2e659ecde0e44bbb7b6.zip
Improve PT502 decoder pattern
-rw-r--r--src/org/traccar/protocol/Pt502ProtocolDecoder.java7
-rw-r--r--test/org/traccar/protocol/Pt502ProtocolDecoderTest.java6
2 files changed, 6 insertions, 7 deletions
diff --git a/src/org/traccar/protocol/Pt502ProtocolDecoder.java b/src/org/traccar/protocol/Pt502ProtocolDecoder.java
index 310c345b0..d2436302d 100644
--- a/src/org/traccar/protocol/Pt502ProtocolDecoder.java
+++ b/src/org/traccar/protocol/Pt502ProtocolDecoder.java
@@ -16,15 +16,12 @@
*/
package org.traccar.protocol;
-import java.net.SocketAddress;
+import java.net.SocketAddress;
import java.util.Calendar;
import java.util.TimeZone;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
-
import org.jboss.netty.channel.Channel;
-import org.jboss.netty.channel.ChannelHandlerContext;
-
import org.traccar.BaseProtocolDecoder;
import org.traccar.model.Event;
import org.traccar.model.Position;
@@ -51,7 +48,7 @@ public class Pt502ProtocolDecoder extends BaseProtocolDecoder {
"./" +
"([01])+," + // Input
"([01])+/" + // Output
- "([^/]+)/" + // ADC
+ "([^/]+)?/" + // ADC
"(\\d+)" + // Odometer
"(?:/([^/]+)?/" + // RFID
"(\\p{XDigit}{3}))?" + // State
diff --git a/test/org/traccar/protocol/Pt502ProtocolDecoderTest.java b/test/org/traccar/protocol/Pt502ProtocolDecoderTest.java
index f012c8e8a..06740a271 100644
--- a/test/org/traccar/protocol/Pt502ProtocolDecoderTest.java
+++ b/test/org/traccar/protocol/Pt502ProtocolDecoderTest.java
@@ -1,8 +1,7 @@
package org.traccar.protocol;
-import org.traccar.helper.TestIdentityManager;
-import static org.traccar.helper.DecoderVerifier.verify;
import org.junit.Test;
+import static org.traccar.helper.DecoderVerifier.verify;
public class Pt502ProtocolDecoderTest extends ProtocolDecoderTest {
@@ -10,6 +9,9 @@ public class Pt502ProtocolDecoderTest extends ProtocolDecoderTest {
public void testDecode() throws Exception {
Pt502ProtocolDecoder decoder = new Pt502ProtocolDecoder(new Pt502Protocol());
+
+ verify(decoder.decode(null, null,
+ "$POS,216769295715,163237.000,A,3258.1738,S,02755.4350,E,0.00,215.88,100915,,,A/0000,0//232300//5b3/"));
verify(decoder.decode(null, null,
"$POS,11023456,033731.000,A,0335.2617,N,09841.1587,E,0.00,88.12,210615,,,A/0000,0/1f8/388900//f33//"));