aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/org/traccar/protocol/Jt600ProtocolDecoder.java20
-rw-r--r--test/org/traccar/protocol/Jt600ProtocolDecoderTest.java8
2 files changed, 17 insertions, 11 deletions
diff --git a/src/org/traccar/protocol/Jt600ProtocolDecoder.java b/src/org/traccar/protocol/Jt600ProtocolDecoder.java
index 287235fb1..6d066299a 100644
--- a/src/org/traccar/protocol/Jt600ProtocolDecoder.java
+++ b/src/org/traccar/protocol/Jt600ProtocolDecoder.java
@@ -219,7 +219,7 @@ public class Jt600ProtocolDecoder extends BaseProtocolDecoder {
.number("(d+),") // lac
.number("(d+),") // gsm signal
.number("(d+),") // odometer
- .number("(d+),") // serial number
+ .number("(d+),?") // serial number
.number("(xx)").optional() // checksum
.any()
.compile();
@@ -267,13 +267,19 @@ public class Jt600ProtocolDecoder extends BaseProtocolDecoder {
case "U01":
case "U02":
case "U03":
- int checkSum = parser.nextInt(16);
- int calculatedCheckSum = Checksum.xor(sentence.substring(1, sentence.length() - 3));
- if (checkSum == calculatedCheckSum) {
- sendResponse(channel, "(S39)");
- return position;
+ // support protocol with check sum
+ if (parser.hasNext(2)) {
+ int checkSum = parser.nextInt(16);
+ int calculatedCheckSum = Checksum.xor(sentence.substring(1, sentence.length() - 3));
+ if (checkSum == calculatedCheckSum) {
+ sendResponse(channel, "(S39)");
+ return position;
+ } else {
+ return null;
+ }
+ // support protocol without check sum
} else {
- return null;
+ return position;
}
case "U06":
sendResponse(channel, "(S20)");
diff --git a/test/org/traccar/protocol/Jt600ProtocolDecoderTest.java b/test/org/traccar/protocol/Jt600ProtocolDecoderTest.java
index 6899418d9..3fc74081f 100644
--- a/test/org/traccar/protocol/Jt600ProtocolDecoderTest.java
+++ b/test/org/traccar/protocol/Jt600ProtocolDecoderTest.java
@@ -18,13 +18,13 @@ public class Jt600ProtocolDecoderTest extends ProtocolTest {
"2475605035891613002328091601152806086750106533350c00000000000a000000000000e1ff4f97007f1607"));
verifyPosition(decoder, buffer(
- "(3301210003,U01,040812,185302,T,22.564025,N,113.242329,E,5.21,152,9,32%,00000000000011,10133,5173,22,100,1,18)"));
+ "(3301210003,U01,040812,185302,T,22.564025,N,113.242329,E,5.21,152,9,32%,00000000000011,10133,5173,22,100,1)"));
verifyPosition(decoder, buffer(
- "(3301210003,U02,040812,185302,T,22.564025,N,113.242329,E,5,152,9,32%,00000000000011,10133,5173,22,100,1,36)"));
+ "(3301210003,U02,040812,185302,T,22.564025,N,113.242329,E,5,152,9,32%,00000000000011,10133,5173,22,100,1)"));
verifyPosition(decoder, buffer(
- "(3301210003,U03,040812,185302,T,22.564025,N,113.242329,E,5,152,9,32%,00000000000011,10133,5173,22,100,1,37)"));
+ "(3301210003,U03,040812,185302,T,22.564025,N,113.242329,E,5,152,9,32%,00000000000011,10133,5173,22,100,1)"));
verifyNothing(decoder, buffer(
"(3301210003,U04)"));
@@ -68,7 +68,7 @@ public class Jt600ProtocolDecoderTest extends ProtocolTest {
"(3120820029,W01,02553.3555,E,2438.0997,S,A,171012,053339,0,8,20,6,31,5,20,20)"));
verifyPosition(decoder, buffer(
- "(3330104377,U01,010100,010228,F,00.000000,N,000.000000,E,0,0,0,0%,00001000000000,741,14,22,0,206,1E)"));
+ "(3330104377,U01,010100,010228,F,00.000000,N,000.000000,E,0,0,0,0%,00001000000000,741,14,22,0,206)"));
verifyNothing(decoder, buffer(
"(6221107674,2,U09,129,2,A,280513113036,E,02711.0500,S,1721.0876,A,030613171243,E,02756.7618,S,2300.0325,3491,538200,14400,1)"));