diff options
author | Anton Tananaev <anton.tananaev@gmail.com> | 2014-08-26 19:33:53 +1200 |
---|---|---|
committer | Anton Tananaev <anton.tananaev@gmail.com> | 2014-08-26 19:33:53 +1200 |
commit | 6522fd1027e086c2708757792f2c8e44d4597908 (patch) | |
tree | 67cd4bb5c1fa7c7bdcafe7e72117483d966fc03d | |
parent | d78b41d36a84f5e0560c3474cdc1912def450971 (diff) | |
download | trackermap-server-6522fd1027e086c2708757792f2c8e44d4597908.tar.gz trackermap-server-6522fd1027e086c2708757792f2c8e44d4597908.tar.bz2 trackermap-server-6522fd1027e086c2708757792f2c8e44d4597908.zip |
Fix KHD id decoding (fix #800)
-rw-r--r-- | src/org/traccar/protocol/KhdProtocolDecoder.java | 2 | ||||
-rw-r--r-- | test/org/traccar/protocol/KhdProtocolDecoderTest.java | 31 |
2 files changed, 18 insertions, 15 deletions
diff --git a/src/org/traccar/protocol/KhdProtocolDecoder.java b/src/org/traccar/protocol/KhdProtocolDecoder.java index 9eb78c6ca..bd21592e1 100644 --- a/src/org/traccar/protocol/KhdProtocolDecoder.java +++ b/src/org/traccar/protocol/KhdProtocolDecoder.java @@ -41,7 +41,7 @@ public class KhdProtocolDecoder extends BaseProtocolDecoder { int b3 = buf.readUnsignedByte(); if (b3 > 0x80) b3 -= 0x80; int b4 = buf.readUnsignedByte(); String serialNumber = String.format("%02d%02d%02d%02d", b1, b2, b3, b4); - return String.valueOf(Integer.valueOf(serialNumber)); + return String.valueOf(Long.valueOf(serialNumber)); } private static final int MSG_LOGIN = 0xB1; diff --git a/test/org/traccar/protocol/KhdProtocolDecoderTest.java b/test/org/traccar/protocol/KhdProtocolDecoderTest.java index 44d8ac2bd..2c9b3560e 100644 --- a/test/org/traccar/protocol/KhdProtocolDecoderTest.java +++ b/test/org/traccar/protocol/KhdProtocolDecoderTest.java @@ -15,26 +15,29 @@ public class KhdProtocolDecoderTest { KhdProtocolDecoder decoder = new KhdProtocolDecoder(null); decoder.setDataManager(new TestDataManager()); - int[] buf1 = {0x29,0x29,0xb1,0x00,0x06,0x05,0x16,0x29,0x35,0xb8,0x0d}; - assertNull(decoder.decode(null, null, ChannelBuffers.wrappedBuffer(ChannelBufferTools.convertArray(buf1)))); + assertNull(decoder.decode(null, null, ChannelBuffers.wrappedBuffer(ChannelBufferTools.convertArray( + new int[] {0x29,0x29,0xb1,0x00,0x06,0x05,0x16,0x29,0x35,0xb8,0x0d})))); - int[] buf2 = {0x29,0x29,0x80,0x00,0x28,0x05,0x16,0x29,0x35,0x14,0x01,0x08,0x07,0x47,0x27,0x80,0x11,0x29,0x67,0x03,0x65,0x33,0x69,0x00,0x00,0x01,0x03,0xff,0xff,0x00,0x00,0x82,0xfc,0x00,0x00,0x00,0x1e,0x78,0x09,0x1b,0x00,0x00,0x00,0x36,0x0d}; - verify(decoder.decode(null, null, ChannelBuffers.wrappedBuffer(ChannelBufferTools.convertArray(buf2)))); + verify(decoder.decode(null, null, ChannelBuffers.wrappedBuffer(ChannelBufferTools.convertArray( + new int[] {0x29,0x29,0x80,0x00,0x28,0x05,0x16,0x29,0x35,0x14,0x01,0x08,0x07,0x47,0x27,0x80,0x11,0x29,0x67,0x03,0x65,0x33,0x69,0x00,0x00,0x01,0x03,0xff,0xff,0x00,0x00,0x82,0xfc,0x00,0x00,0x00,0x1e,0x78,0x09,0x1b,0x00,0x00,0x00,0x36,0x0d})))); - int[] buf3 = {0x29,0x29,0x81,0x00,0x28,0x0A,0x9F,0x95,0x38,0x08,0x12,0x28,0x16,0x01,0x31,0x02,0x23,0x94,0x30,0x11,0x40,0x37,0x25,0x00,0x00,0x03,0x30,0xFF,0x00,0x00,0x00,0x7F,0xFC,0x0F,0x00,0x00,0x1E,0x00,0x00,0x00,0x00,0x00,0x34,0x29,0x0D}; - verify(decoder.decode(null, null, ChannelBuffers.wrappedBuffer(ChannelBufferTools.convertArray(buf3)))); + verify(decoder.decode(null, null, ChannelBuffers.wrappedBuffer(ChannelBufferTools.convertArray( + new int[] {0x29,0x29,0x81,0x00,0x28,0x0A,0x9F,0x95,0x38,0x08,0x12,0x28,0x16,0x01,0x31,0x02,0x23,0x94,0x30,0x11,0x40,0x37,0x25,0x00,0x00,0x03,0x30,0xFF,0x00,0x00,0x00,0x7F,0xFC,0x0F,0x00,0x00,0x1E,0x00,0x00,0x00,0x00,0x00,0x34,0x29,0x0D})))); - int[] buf4 = {0x29,0x29,0x80,0x00,0x28,0x0A,0x81,0x85,0x0A,0x12,0x03,0x10,0x09,0x57,0x50,0x00,0x52,0x81,0x37,0x00,0x61,0x19,0x08,0x00,0x00,0x02,0x32,0xF8,0x48,0xFF,0xBB,0xFF,0xFF,0x00,0x00,0x00,0x1E,0x00,0x00,0x00,0x00,0x00,0x00,0xED,0x0D}; - verify(decoder.decode(null, null, ChannelBuffers.wrappedBuffer(ChannelBufferTools.convertArray(buf4)))); + verify(decoder.decode(null, null, ChannelBuffers.wrappedBuffer(ChannelBufferTools.convertArray( + new int[] {0x29,0x29,0x80,0x00,0x28,0x0A,0x81,0x85,0x0A,0x12,0x03,0x10,0x09,0x57,0x50,0x00,0x52,0x81,0x37,0x00,0x61,0x19,0x08,0x00,0x00,0x02,0x32,0xF8,0x48,0xFF,0xBB,0xFF,0xFF,0x00,0x00,0x00,0x1E,0x00,0x00,0x00,0x00,0x00,0x00,0xED,0x0D})))); - int[] buf5 = {0x29,0x29,0x8E,0x00,0x28,0x0F,0x80,0x81,0x5A,0x12,0x12,0x18,0x20,0x31,0x16,0x02,0x23,0x18,0x46,0x11,0x40,0x22,0x70,0x00,0x72,0x02,0x62,0xFB,0x00,0x07,0x7C,0x7F,0xBF,0x56,0x00,0x00,0x1E,0x3C,0x32,0x00,0x00,0x00,0x00,0x85,0x0D}; - verify(decoder.decode(null, null, ChannelBuffers.wrappedBuffer(ChannelBufferTools.convertArray(buf5)))); + verify(decoder.decode(null, null, ChannelBuffers.wrappedBuffer(ChannelBufferTools.convertArray( + new int[] {0x29,0x29,0x8E,0x00,0x28,0x0F,0x80,0x81,0x5A,0x12,0x12,0x18,0x20,0x31,0x16,0x02,0x23,0x18,0x46,0x11,0x40,0x22,0x70,0x00,0x72,0x02,0x62,0xFB,0x00,0x07,0x7C,0x7F,0xBF,0x56,0x00,0x00,0x1E,0x3C,0x32,0x00,0x00,0x00,0x00,0x85,0x0D})))); - int[] buf6 = {0x29,0x29,0x82,0x00,0x23,0x0A,0xA2,0xCC,0x39,0x12,0x05,0x03,0x05,0x05,0x22,0x02,0x85,0x94,0x79,0x03,0x10,0x95,0x50,0x00,0x80,0x02,0x07,0x84,0x00,0x00,0x00,0x02,0x00,0x00,0x00,0x00,0x00,0x00,0x75,0x0D}; - verify(decoder.decode(null, null, ChannelBuffers.wrappedBuffer(ChannelBufferTools.convertArray(buf6)))); + verify(decoder.decode(null, null, ChannelBuffers.wrappedBuffer(ChannelBufferTools.convertArray( + new int[] {0x29,0x29,0x82,0x00,0x23,0x0A,0xA2,0xCC,0x39,0x12,0x05,0x03,0x05,0x05,0x22,0x02,0x85,0x94,0x79,0x03,0x10,0x95,0x50,0x00,0x80,0x02,0x07,0x84,0x00,0x00,0x00,0x02,0x00,0x00,0x00,0x00,0x00,0x00,0x75,0x0D})))); - int[] buf7 = {0x29,0x29,0x85,0x00,0x08,0x1D,0xD0,0x8C,0x22,0x12,0x03,0x12,0x17,0x40,0x26,0x02,0x65,0x45,0x71,0x03,0x12,0x54,0x17,0x00,0x00,0x00,0x00,0xF8,0x19,0xC8,0x39,0xFF,0xFF,0x1D,0x00,0x00,0x1E,0x00,0x50,0x00,0x00,0x00,0x3A,0xF9,0x0D}; - verify(decoder.decode(null, null, ChannelBuffers.wrappedBuffer(ChannelBufferTools.convertArray(buf7)))); + verify(decoder.decode(null, null, ChannelBuffers.wrappedBuffer(ChannelBufferTools.convertArray( + new int[] {0x29,0x29,0x85,0x00,0x08,0x1D,0xD0,0x8C,0x22,0x12,0x03,0x12,0x17,0x40,0x26,0x02,0x65,0x45,0x71,0x03,0x12,0x54,0x17,0x00,0x00,0x00,0x00,0xF8,0x19,0xC8,0x39,0xFF,0xFF,0x1D,0x00,0x00,0x1E,0x00,0x50,0x00,0x00,0x00,0x3A,0xF9,0x0D})))); + + verify(decoder.decode(null, null, ChannelBuffers.wrappedBuffer(ChannelBufferTools.convertArray( + new int[] {0x29,0x29,0x80,0x00,0x28,0x22,0x83,0x66,0x65,0x14,0x08,0x25,0x14,0x20,0x37,0x04,0x53,0x43,0x77,0x01,0x93,0x87,0x92,0x00,0x00,0x00,0x50,0xff,0xff,0x00,0x00,0x82,0xfc,0x00,0x00,0x04,0xb0,0x78,0x0b,0x17,0x00,0x00,0x00,0x2a,0x0d})))); } |