From f325f30ab8d9097eec01a39f5e7ac02c11d608c3 Mon Sep 17 00:00:00 2001 From: Anton Tananaev Date: Sun, 7 Feb 2016 07:45:44 +1000 Subject: Handle new line in Xexun messages --- src/org/traccar/protocol/XexunProtocolDecoder.java | 5 +++-- test/org/traccar/protocol/XexunProtocolDecoderTest.java | 3 +++ 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/src/org/traccar/protocol/XexunProtocolDecoder.java b/src/org/traccar/protocol/XexunProtocolDecoder.java index f9369b463..0929ee99b 100644 --- a/src/org/traccar/protocol/XexunProtocolDecoder.java +++ b/src/org/traccar/protocol/XexunProtocolDecoder.java @@ -44,8 +44,9 @@ public class XexunProtocolDecoder extends BaseProtocolDecoder { .number("(d+.?d*)?,") // course .number("(dd)(dd)(dd),") // date .expression("[^*]*").text("*") - .number("xx,") // checksum - .expression("([FL]),") // signal + .number("xx") // checksum + .expression("\\r\\n").optional() + .expression(",([FL]),") // signal .expression("([^,]*),").optional() // alarm .any() .number("imei:(d+),") // imei diff --git a/test/org/traccar/protocol/XexunProtocolDecoderTest.java b/test/org/traccar/protocol/XexunProtocolDecoderTest.java index 27574ddce..76c516caf 100644 --- a/test/org/traccar/protocol/XexunProtocolDecoderTest.java +++ b/test/org/traccar/protocol/XexunProtocolDecoderTest.java @@ -11,6 +11,9 @@ public class XexunProtocolDecoderTest extends ProtocolTest { XexunProtocolDecoder decoder = new XexunProtocolDecoder(new XexunProtocol(), false); + verifyPosition(decoder, text( + "GPRMC,121535.000,A,5417.2666,N,04822.1264,E,1.452,30.42,031014,0.0,A*4D\r\n,L,imei:355227042011730,")); + verifyPosition(decoder, text( "GPRMC,150120.000,A,3346.4463,S,15057.3083,E,0.0,117.4,010911,,,A*76,F,imei:351525010943661,"), position("2011-09-01 15:01:20.000", true, -33.77411, 150.95514)); -- cgit v1.2.3