From bb211eea5f62014c0700138e922cb1adcdc9d9dd Mon Sep 17 00:00:00 2001 From: Vitaly Litvak Date: Sun, 2 Oct 2016 08:28:27 +0300 Subject: Support old protocol versions without checksum --- src/org/traccar/protocol/Jt600ProtocolDecoder.java | 20 +++++++++++++------- 1 file changed, 13 insertions(+), 7 deletions(-) (limited to 'src/org/traccar') 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)"); -- cgit v1.2.3