diff options
-rw-r--r-- | src/org/traccar/protocol/AtrackProtocolDecoder.java | 4 | ||||
-rw-r--r-- | test/org/traccar/protocol/AtrackProtocolDecoderTest.java | 3 |
2 files changed, 6 insertions, 1 deletions
diff --git a/src/org/traccar/protocol/AtrackProtocolDecoder.java b/src/org/traccar/protocol/AtrackProtocolDecoder.java index 1323ce8a3..607b3e558 100644 --- a/src/org/traccar/protocol/AtrackProtocolDecoder.java +++ b/src/org/traccar/protocol/AtrackProtocolDecoder.java @@ -42,6 +42,8 @@ public class AtrackProtocolDecoder extends BaseProtocolDecoder { private static final int MSG_HEARTBEAT = 0x1A; private static final int MSG_DATA = 0x10; + private static final int MIN_DATA_LENGTH = 40; + private static void sendResponse(Channel channel, SocketAddress remoteAddress, long rawId, int index) { if (channel != null) { ChannelBuffer response = ChannelBuffers.directBuffer(12); @@ -104,7 +106,7 @@ public class AtrackProtocolDecoder extends BaseProtocolDecoder { List<Position> positions = new LinkedList<Position>(); - while (buf.readable()) { + while (buf.readableBytes() >= MIN_DATA_LENGTH) { // Create new position Position position = new Position(); diff --git a/test/org/traccar/protocol/AtrackProtocolDecoderTest.java b/test/org/traccar/protocol/AtrackProtocolDecoderTest.java index c06845df7..043c843c0 100644 --- a/test/org/traccar/protocol/AtrackProtocolDecoderTest.java +++ b/test/org/traccar/protocol/AtrackProtocolDecoderTest.java @@ -23,6 +23,9 @@ public class AtrackProtocolDecoderTest { verify(decoder.decode(null, null, null, ChannelBuffers.wrappedBuffer(ChannelBufferTools.convertHexString( "40501e58003301e000014104d8f19682525ecd5d525ee344525ee35effc88815026ab4d70000020000104403de01000b0000000007d007d000")))); + verify(decoder.decode(null, null, null, ChannelBuffers.wrappedBuffer(ChannelBufferTools.convertHexString( + "40501e58003301e000014104d8f19682525ecd5d525ee344525ee35effc88815026ab4d70000020000104403de01000b0000000007d007d000000000000000")))); + // 7-byte date //verify(decoder.decode(null, null, null, ChannelBuffers.wrappedBuffer(ChannelBufferTools.convertHexString( // "0203b494003c00eb00014104d8dd3a3e07de011b0b1f0307de011b0b1f0307de011b0b1f0300307f28030574d30000020000000600160100020000000007d007d000")))); |