From 36d06c790494d35951a416643b9e8aa8853f573e Mon Sep 17 00:00:00 2001 From: Anton Tananaev Date: Tue, 31 Jul 2018 01:26:27 +1200 Subject: [PATCH] Adjust Alematics regex pattern --- src/org/traccar/protocol/AlematicsProtocolDecoder.java | 4 +++- test/org/traccar/protocol/AlematicsProtocolDecoderTest.java | 6 ++++++ 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/src/org/traccar/protocol/AlematicsProtocolDecoder.java b/src/org/traccar/protocol/AlematicsProtocolDecoder.java index 794588f5fdf..8909b8d5b3a 100644 --- a/src/org/traccar/protocol/AlematicsProtocolDecoder.java +++ b/src/org/traccar/protocol/AlematicsProtocolDecoder.java @@ -60,6 +60,8 @@ public AlematicsProtocolDecoder(AlematicsProtocol protocol) { .or() .number("(d+),") // extra mask .expression("(.*)") // extra data + .or() + .any() .groupEnd() .compile(); @@ -144,7 +146,7 @@ protected Object decode( if (parser.hasNext()) { position.set("text", parser.next()); - } else { + } else if (parser.hasNext()) { decodeExtras(position, parser); } diff --git a/test/org/traccar/protocol/AlematicsProtocolDecoderTest.java b/test/org/traccar/protocol/AlematicsProtocolDecoderTest.java index 448a48101dd..094e5b56e30 100644 --- a/test/org/traccar/protocol/AlematicsProtocolDecoderTest.java +++ b/test/org/traccar/protocol/AlematicsProtocolDecoderTest.java @@ -10,6 +10,12 @@ public void testDecode() throws Exception { AlematicsProtocolDecoder decoder = new AlematicsProtocolDecoder(new AlematicsProtocol()); + verifyPosition(decoder, text( + "$T,2,64,866050035975497,20180726103446,20180726103514,23.033305,72.558032,0,0,41,5.4,4,0,0,0.000,12.960,0,")); + + verifyPosition(decoder, text( + "$T,2,65,866050035975497,20180726103646,20180726103736,23.033305,72.558032,0,0,41,5.4,4,0,0,0.000,12.976,0,0")); + verifyPosition(decoder, text( "$T,2,552,868259020159698,20170515060949,20170515060949,25.035277,121.561986,0,202,78,1.0,8,1,0,0.000,12.768,1629,38,12770,4109,9"));