aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAnton Tananaev <anton.tananaev@gmail.com>2018-09-27 15:15:29 +1200
committerAnton Tananaev <anton.tananaev@gmail.com>2018-09-27 15:15:29 +1200
commit38e77023844a5c76112ed79ddf8308cedfc3e099 (patch)
treed79c8583b15f7a66c5a7495f9f8c9c72d840c2f3
parent61f82e3dce810d99bfdd02e6b7e66c6f617a13b5 (diff)
downloadtrackermap-server-38e77023844a5c76112ed79ddf8308cedfc3e099.tar.gz
trackermap-server-38e77023844a5c76112ed79ddf8308cedfc3e099.tar.bz2
trackermap-server-38e77023844a5c76112ed79ddf8308cedfc3e099.zip
Fix Tramigo frame decoder
-rw-r--r--src/org/traccar/protocol/TramigoFrameDecoder.java4
-rw-r--r--test/org/traccar/protocol/TramigoFrameDecoderTest.java23
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")));
+
+ }
+
+}