aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAnton Tananaev <anton.tananaev@gmail.com>2016-08-10 11:11:20 +0300
committerAnton Tananaev <anton.tananaev@gmail.com>2016-08-10 11:11:29 +0300
commit78f8d278276f0826eb302a08213609b083570760 (patch)
tree8e14160463c956e7f0ac260d7c72d85680c77d92
parent21641679ddc92ad3f51ae6e84409c9186e668bbc (diff)
downloadtrackermap-server-78f8d278276f0826eb302a08213609b083570760.tar.gz
trackermap-server-78f8d278276f0826eb302a08213609b083570760.tar.bz2
trackermap-server-78f8d278276f0826eb302a08213609b083570760.zip
Workaround for CalAmp issue
-rw-r--r--src/org/traccar/protocol/CalAmpProtocolDecoder.java6
-rw-r--r--test/org/traccar/protocol/CalAmpProtocolDecoderTest.java3
2 files changed, 7 insertions, 2 deletions
diff --git a/src/org/traccar/protocol/CalAmpProtocolDecoder.java b/src/org/traccar/protocol/CalAmpProtocolDecoder.java
index 99edb9fb7..47d7bf483 100644
--- a/src/org/traccar/protocol/CalAmpProtocolDecoder.java
+++ b/src/org/traccar/protocol/CalAmpProtocolDecoder.java
@@ -1,5 +1,5 @@
/*
- * Copyright 2015 Anton Tananaev (anton.tananaev@gmail.com)
+ * Copyright 2015 - 2016 Anton Tananaev (anton.tananaev@gmail.com)
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -130,7 +130,9 @@ public class CalAmpProtocolDecoder extends BaseProtocolDecoder {
}
for (int i = 0; i < accCount; i++) {
- position.set("acc" + i, buf.readUnsignedInt());
+ if (buf.readableBytes() >= 4) {
+ position.set("acc" + i, buf.readUnsignedInt());
+ }
}
return position;
diff --git a/test/org/traccar/protocol/CalAmpProtocolDecoderTest.java b/test/org/traccar/protocol/CalAmpProtocolDecoderTest.java
index 238e6df3f..9ed4c4a43 100644
--- a/test/org/traccar/protocol/CalAmpProtocolDecoderTest.java
+++ b/test/org/traccar/protocol/CalAmpProtocolDecoderTest.java
@@ -11,6 +11,9 @@ public class CalAmpProtocolDecoderTest extends ProtocolTest {
CalAmpProtocolDecoder decoder = new CalAmpProtocolDecoder(new CalAmpProtocol());
verifyPosition(decoder, binary(
+ "8305454205067001010102008157a9bddc57a96aaa17cdb98fccc1a457000056ac00000000000007250000ff8f000e00082711570000000000ffff101b00003148000010680000000000000000000000050000000000000000000005b0000000000000289600000000000000000000069b00000000000008e400000000000000000000000000000003000000010000070f"));
+
+ verifyPosition(decoder, binary(
"83052132052924010101020001575c590300000000000000000000000000000000000000000000002c0000ff8f0000030801010000"));
verifyPosition(decoder, binary(