aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAnton Tananaev <anton.tananaev@gmail.com>2016-02-19 11:24:29 +1300
committerAnton Tananaev <anton.tananaev@gmail.com>2016-02-19 11:24:29 +1300
commitdac5c6923044572b0714e29dfae650888332c920 (patch)
tree581afd86abc81810262b20824cb1e1bac5eaf1ca
parentb178acdc21483cc7bd9588453a4d8afc476ca294 (diff)
downloadtrackermap-server-dac5c6923044572b0714e29dfae650888332c920.tar.gz
trackermap-server-dac5c6923044572b0714e29dfae650888332c920.tar.bz2
trackermap-server-dac5c6923044572b0714e29dfae650888332c920.zip
Workaround for GT06 length issue (fix #1727)
-rw-r--r--src/org/traccar/protocol/Gt06FrameDecoder.java6
-rw-r--r--test/org/traccar/protocol/Gt06FrameDecoderTest.java2
2 files changed, 7 insertions, 1 deletions
diff --git a/src/org/traccar/protocol/Gt06FrameDecoder.java b/src/org/traccar/protocol/Gt06FrameDecoder.java
index ed0d8d548..21f5c8b52 100644
--- a/src/org/traccar/protocol/Gt06FrameDecoder.java
+++ b/src/org/traccar/protocol/Gt06FrameDecoder.java
@@ -37,6 +37,12 @@ public class Gt06FrameDecoder extends FrameDecoder {
if (buf.getByte(buf.readerIndex()) == 0x78) {
length += 1 + buf.getUnsignedByte(buf.readerIndex() + 2);
+
+ int type = buf.getUnsignedByte(buf.readerIndex() + 3);
+ if (type == Gt06ProtocolDecoder.MSG_STATUS && length == 13) {
+ length += 2; // workaround for #1727
+ }
+
} else {
length += 2 + buf.getUnsignedShort(buf.readerIndex() + 2);
}
diff --git a/test/org/traccar/protocol/Gt06FrameDecoderTest.java b/test/org/traccar/protocol/Gt06FrameDecoderTest.java
index 9ecd44e59..12ee6bb60 100644
--- a/test/org/traccar/protocol/Gt06FrameDecoderTest.java
+++ b/test/org/traccar/protocol/Gt06FrameDecoderTest.java
@@ -15,7 +15,7 @@ public class Gt06FrameDecoderTest extends ProtocolTest {
binary("78781f1210020e140613cc04770690003e3f2e3414b20000000000000000044c446a0d0a"),
decoder.decode(null, null, binary("78781f1210020e140613cc04770690003e3f2e3414b20000000000000000044c446a0d0a")));
- Assert.assertNotEquals(
+ Assert.assertEquals(
binary("787808134606020002044dc5050d0a"),
decoder.decode(null, null, binary("787808134606020002044dc5050d0a")));