From 9ab536ca8c4e1ad850cb5fa08bbe99f14676b535 Mon Sep 17 00:00:00 2001 From: Anton Tananaev Date: Sat, 29 Aug 2015 12:38:26 +1200 Subject: Fix GT06 protocol decoder (fix #1308) --- src/org/traccar/protocol/Gt06ProtocolDecoder.java | 4 +++- test/org/traccar/protocol/Gt06ProtocolDecoderTest.java | 4 +++- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/src/org/traccar/protocol/Gt06ProtocolDecoder.java b/src/org/traccar/protocol/Gt06ProtocolDecoder.java index fde34c8f7..018b42dc9 100644 --- a/src/org/traccar/protocol/Gt06ProtocolDecoder.java +++ b/src/org/traccar/protocol/Gt06ProtocolDecoder.java @@ -197,7 +197,9 @@ public class Gt06ProtocolDecoder extends BaseProtocolDecoder { position.set(Event.KEY_MNC, buf.readUnsignedByte()); position.set(Event.KEY_LAC, buf.readUnsignedShort()); position.set(Event.KEY_CELL, buf.readUnsignedShort() << 8 + buf.readUnsignedByte()); - buf.skipBytes(lbsLength - 9); + if (lbsLength > 0) { + buf.skipBytes(lbsLength - 9); + } // Status if (type == MSG_GPS_LBS_STATUS_1 || type == MSG_GPS_LBS_STATUS_2 || type == MSG_GPS_LBS_STATUS_3) { diff --git a/test/org/traccar/protocol/Gt06ProtocolDecoderTest.java b/test/org/traccar/protocol/Gt06ProtocolDecoderTest.java index 3570eb0d4..f8276b123 100644 --- a/test/org/traccar/protocol/Gt06ProtocolDecoderTest.java +++ b/test/org/traccar/protocol/Gt06ProtocolDecoderTest.java @@ -1,6 +1,5 @@ package org.traccar.protocol; -import org.traccar.helper.TestIdentityManager; import org.jboss.netty.buffer.ChannelBuffers; import static org.junit.Assert.assertNull; import org.junit.Test; @@ -16,6 +15,9 @@ public class Gt06ProtocolDecoderTest extends ProtocolDecoderTest { assertNull(decoder.decode(null, null, ChannelBuffers.wrappedBuffer(ChannelBufferTools.convertHexString( "787811010123456789012345100B3201000171930D0A")))); + + verify(decoder.decode(null, null, ChannelBuffers.wrappedBuffer(ChannelBufferTools.convertHexString( + "787823120f081b121d37cb01c8e2cc08afd3c020d50201940701d600a1190041ee100576d1470d0a")))); verify(decoder.decode(null, null, ChannelBuffers.wrappedBuffer(ChannelBufferTools.convertHexString( "78781F120B081D112E10CC027AC7EB0C46584900148F01CC00287D001FB8000380810D0A")))); -- cgit v1.2.3