diff options
-rw-r--r-- | src/org/traccar/protocol/TramigoFrameDecoder.java | 4 | ||||
-rw-r--r-- | test/org/traccar/protocol/TramigoFrameDecoderTest.java | 23 |
2 files changed, 25 insertions, 2 deletions
diff --git a/src/org/traccar/protocol/TramigoFrameDecoder.java b/src/org/traccar/protocol/TramigoFrameDecoder.java index fae9efecf..aaaaccb60 100644 --- a/src/org/traccar/protocol/TramigoFrameDecoder.java +++ b/src/org/traccar/protocol/TramigoFrameDecoder.java @@ -31,9 +31,9 @@ public class TramigoFrameDecoder extends BaseFrameDecoder { int length; if (buf.getUnsignedByte(buf.readerIndex()) == 0x80) { - length = buf.getUnsignedShort(buf.readerIndex() + 6); - } else { length = buf.getUnsignedShortLE(buf.readerIndex() + 6); + } else { + length = buf.getUnsignedShort(buf.readerIndex() + 6); } if (length >= buf.readableBytes()) { diff --git a/test/org/traccar/protocol/TramigoFrameDecoderTest.java b/test/org/traccar/protocol/TramigoFrameDecoderTest.java new file mode 100644 index 000000000..f482a00bb --- /dev/null +++ b/test/org/traccar/protocol/TramigoFrameDecoderTest.java @@ -0,0 +1,23 @@ +package org.traccar.protocol; + +import org.junit.Test; +import org.traccar.ProtocolTest; + +public class TramigoFrameDecoderTest extends ProtocolTest { + + @Test + public void testDecode() throws Exception { + + TramigoFrameDecoder decoder = new TramigoFrameDecoder(); + + verifyFrame( + binary("8000ed2bb0009c000101bee000050b09633d925b5472616d69676f3a205472697020737461727465642c2053686f636b2053656e736f722c206174204b696e6720437265656b20526f61642d46726565746f776e205374726565742c20506f727420486172636f7572742c205269766572732c204e472c20342e37363336312c20372e30313836382c2030373a31383a333620536570203320454f46"), + decoder.decode(null, null, binary("8000ed2bb0009c000101bee000050b09633d925b5472616d69676f3a205472697020737461727465642c2053686f636b2053656e736f722c206174204b696e6720437265656b20526f61642d46726565746f776e205374726565742c20506f727420486172636f7572742c205269766572732c204e472c20342e37363336312c20372e30313836382c2030373a31383a333620536570203320454f46"))); + + verifyFrame( + binary("80003d1ac0001c00010100000367152b13bc1d5970696e6720454f46"), + decoder.decode(null, null, binary("80003d1ac0001c00010100000367152b13bc1d5970696e6720454f46"))); + + } + +} |