aboutsummaryrefslogtreecommitdiff
path: root/src/org/traccar
diff options
context:
space:
mode:
authorAnton Tananaev <anton.tananaev@gmail.com>2017-10-01 08:56:53 +1300
committerAnton Tananaev <anton.tananaev@gmail.com>2017-10-01 08:56:53 +1300
commit81e6d5825615fbe0be253e500b2c997f304349e6 (patch)
tree1860fae31a09afe1a9c31a201b53695a83be06f2 /src/org/traccar
parent8e137d15f3db64909f5bd6e1ceb4b6a0bef8bed1 (diff)
downloadtraccar-server-81e6d5825615fbe0be253e500b2c997f304349e6.tar.gz
traccar-server-81e6d5825615fbe0be253e500b2c997f304349e6.tar.bz2
traccar-server-81e6d5825615fbe0be253e500b2c997f304349e6.zip
Workaround for GT06 frame decoder
Diffstat (limited to 'src/org/traccar')
-rw-r--r--src/org/traccar/protocol/Gt06FrameDecoder.java19
1 files changed, 10 insertions, 9 deletions
diff --git a/src/org/traccar/protocol/Gt06FrameDecoder.java b/src/org/traccar/protocol/Gt06FrameDecoder.java
index 9b93979e4..c8b5e56ae 100644
--- a/src/org/traccar/protocol/Gt06FrameDecoder.java
+++ b/src/org/traccar/protocol/Gt06FrameDecoder.java
@@ -38,17 +38,18 @@ public class Gt06FrameDecoder extends FrameDecoder {
length += 2 + buf.getUnsignedShort(buf.readerIndex() + 2);
}
- if (buf.readableBytes() >= length) {
- if (buf.getUnsignedShort(buf.readerIndex() + length - 2) == 0x0d0a) {
- return buf.readBytes(length);
- } else {
- int endIndex = buf.indexOf(buf.readerIndex(), buf.writerIndex(), (byte) 0x0d);
- if (endIndex > 0 && buf.writerIndex() > endIndex + 1 && buf.getByte(endIndex + 1) == 0x0a) {
- return buf.readBytes(endIndex + 2 - buf.readerIndex());
- }
- }
+ if (buf.readableBytes() >= length && buf.getUnsignedShort(buf.readerIndex() + length - 2) == 0x0d0a) {
+ return buf.readBytes(length);
}
+ int endIndex = buf.readerIndex() - 1;
+ do {
+ endIndex = buf.indexOf(endIndex + 1, buf.writerIndex(), (byte) 0x0d);
+ if (endIndex > 0 && buf.writerIndex() > endIndex + 1 && buf.getByte(endIndex + 1) == 0x0a) {
+ return buf.readBytes(endIndex + 2 - buf.readerIndex());
+ }
+ } while (endIndex > 0);
+
return null;
}