diff options
author | Vitaly Litvak <vitavaque@gmail.com> | 2016-10-02 08:28:27 +0300 |
---|---|---|
committer | Vitaly Litvak <vitavaque@gmail.com> | 2016-10-02 08:28:27 +0300 |
commit | bb211eea5f62014c0700138e922cb1adcdc9d9dd (patch) | |
tree | 418b6a3b5fb006936d549e8e1a831d09b1544ae3 /src | |
parent | 2d145a029bf45d309366b5b6367befd00efb5efc (diff) | |
download | trackermap-server-bb211eea5f62014c0700138e922cb1adcdc9d9dd.tar.gz trackermap-server-bb211eea5f62014c0700138e922cb1adcdc9d9dd.tar.bz2 trackermap-server-bb211eea5f62014c0700138e922cb1adcdc9d9dd.zip |
Support old protocol versions without checksum
Diffstat (limited to 'src')
-rw-r--r-- | src/org/traccar/protocol/Jt600ProtocolDecoder.java | 20 |
1 files changed, 13 insertions, 7 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)"); |