From dac5c6923044572b0714e29dfae650888332c920 Mon Sep 17 00:00:00 2001 From: Anton Tananaev Date: Fri, 19 Feb 2016 11:24:29 +1300 Subject: Workaround for GT06 length issue (fix #1727) --- src/org/traccar/protocol/Gt06FrameDecoder.java | 6 ++++++ test/org/traccar/protocol/Gt06FrameDecoderTest.java | 2 +- 2 files changed, 7 insertions(+), 1 deletion(-) 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"))); -- cgit v1.2.3