aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAnton Tananaev <anton.tananaev@gmail.com>2018-03-01 15:31:05 +1300
committerAnton Tananaev <anton.tananaev@gmail.com>2018-03-01 15:31:31 +1300
commita79386202fcf1feb86b7770cbbbcfe65fa4a95ca (patch)
tree8f68a84c8d3915d150974b587e843a271ac6bd1c
parent4a4d58092cc26635f59a0b9b2067c2ce43c68d0e (diff)
downloadtrackermap-server-a79386202fcf1feb86b7770cbbbcfe65fa4a95ca.tar.gz
trackermap-server-a79386202fcf1feb86b7770cbbbcfe65fa4a95ca.tar.bz2
trackermap-server-a79386202fcf1feb86b7770cbbbcfe65fa4a95ca.zip
Handle H02 message new line
-rw-r--r--src/org/traccar/protocol/H02ProtocolDecoder.java2
-rw-r--r--test/org/traccar/protocol/H02ProtocolDecoderTest.java2
2 files changed, 2 insertions, 2 deletions
diff --git a/src/org/traccar/protocol/H02ProtocolDecoder.java b/src/org/traccar/protocol/H02ProtocolDecoder.java
index 5ee663ee1..9764adf04 100644
--- a/src/org/traccar/protocol/H02ProtocolDecoder.java
+++ b/src/org/traccar/protocol/H02ProtocolDecoder.java
@@ -456,7 +456,7 @@ public class H02ProtocolDecoder extends BaseProtocolDecoder {
switch (marker) {
case "*":
- String sentence = buf.toString(StandardCharsets.US_ASCII);
+ String sentence = buf.toString(StandardCharsets.US_ASCII).trim();
int typeStart = sentence.indexOf(',', sentence.indexOf(',') + 1) + 1;
int typeEnd = sentence.indexOf(',', typeStart);
if (typeEnd > 0) {
diff --git a/test/org/traccar/protocol/H02ProtocolDecoderTest.java b/test/org/traccar/protocol/H02ProtocolDecoderTest.java
index b5dcd9ffe..adbdc0a07 100644
--- a/test/org/traccar/protocol/H02ProtocolDecoderTest.java
+++ b/test/org/traccar/protocol/H02ProtocolDecoderTest.java
@@ -156,7 +156,7 @@ public class H02ProtocolDecoderTest extends ProtocolTest {
"*HQ,2705171109,V1,213324,A,5002.5849,N,01433.7822,E,0.00,000,140613,FFFFFFFF#"));
verifyPosition(decoder, buffer(
- "*TH,2020916012,V1,050316,A,2212.8745,N,11346.6574,E,14.28,028,220902,FFFFFBFF#"));
+ "*TH,2020916012,V1,050316,A,2212.8745,N,11346.6574,E,14.28,028,220902,FFFFFBFF#\r\n"));
verifyPosition(decoder, buffer(
"*TH,2020916012,V4,S17,130305,050316,A,2212.8745,N,11346.6574,E,14.28,028,220902,FFFFFBFF#"));