aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAnton Tananaev <anton.tananaev@gmail.com>2013-07-16 21:30:21 +1200
committerAnton Tananaev <anton.tananaev@gmail.com>2013-07-16 21:30:21 +1200
commit3a4b5c8647c9925ab740a566097c5e92d4a5eedf (patch)
tree0360a8cf9f0a5d9ba2eef911e6475bad7e8a8e3c
parent89af5a5798bbf1f34a446c3b357aa5cb63ef1e79 (diff)
downloadtraccar-server-3a4b5c8647c9925ab740a566097c5e92d4a5eedf.tar.gz
traccar-server-3a4b5c8647c9925ab740a566097c5e92d4a5eedf.tar.bz2
traccar-server-3a4b5c8647c9925ab740a566097c5e92d4a5eedf.zip
Fix Cellocator frame decoder
-rw-r--r--src/org/traccar/protocol/CellocatorFrameDecoder.java2
-rw-r--r--test/org/traccar/protocol/CellocatorProtocolDecoderTest.java3
2 files changed, 4 insertions, 1 deletions
diff --git a/src/org/traccar/protocol/CellocatorFrameDecoder.java b/src/org/traccar/protocol/CellocatorFrameDecoder.java
index cddb33d52..eb1c748b9 100644
--- a/src/org/traccar/protocol/CellocatorFrameDecoder.java
+++ b/src/org/traccar/protocol/CellocatorFrameDecoder.java
@@ -61,7 +61,7 @@ public class CellocatorFrameDecoder extends FrameDecoder {
// Read packet
if (length > 0 && available >= length) {
- return buf.readBytes(length + 2);
+ return buf.readBytes(length);
}
return null;
diff --git a/test/org/traccar/protocol/CellocatorProtocolDecoderTest.java b/test/org/traccar/protocol/CellocatorProtocolDecoderTest.java
index f1128a93a..1384b29bb 100644
--- a/test/org/traccar/protocol/CellocatorProtocolDecoderTest.java
+++ b/test/org/traccar/protocol/CellocatorProtocolDecoderTest.java
@@ -15,6 +15,9 @@ public class CellocatorProtocolDecoderTest {
byte[] buf1 = {0x4D,0x43,0x47,0x50,0x00,0x06,0x00,0x00,0x00,0x08,0x1A,0x02,0x02,0x12,0x04,0x00,0x00,0x00,0x21,0x00,0x62,0x30,0x00,0x00,0x00,0x6B,0x00,(byte)0xE1,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,(byte)0xE5,(byte)0xA1,0x00,0x04,0x02,0x06,0x61,0x4E,(byte)0xA3,0x03,0x18,0x1A,0x57,0x03,0x4E,0x12,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x15,0x25,0x07,0x14,0x03,(byte)0xD6,0x07,0x49};
assertNotNull(decoder.decode(null, null, ChannelBuffers.wrappedBuffer(ByteOrder.LITTLE_ENDIAN, buf1)));
+
+ byte[] buf2 = {0x4d,0x43,0x47,0x50,0x00,0x01,0x01,0x00,0x00,0x08,0x01,0x1f,0x04,0x18,0x04,0x00,0x00,0x00,0x20,0x01,0x00,0x00,0x00,0x00,0x00,0x5e,0x75,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x54,(byte)0x85,0x00,0x04,0x02,0x04,(byte)0xda,0x4d,(byte)0xa3,0x03,0x67,0x19,0x57,0x03,(byte)0xe8,0x03,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x20,0x14,0x15,0x10,0x07,(byte)0xdd,0x07,(byte)0xf7};
+ assertNotNull(decoder.decode(null, null, ChannelBuffers.wrappedBuffer(ByteOrder.LITTLE_ENDIAN, buf2)));
}