diff options
author | Anton Tananaev <anton.tananaev@gmail.com> | 2017-10-31 19:46:36 +1300 |
---|---|---|
committer | Anton Tananaev <anton.tananaev@gmail.com> | 2017-10-31 19:46:49 +1300 |
commit | a6f54888e873ff083d195f28ddebef08011c4306 (patch) | |
tree | cedb01c79b684ebfbf0c5baed744b8c1830abf12 /src | |
parent | 6475bc9db3b1446bb90d2102003201db5611ddf0 (diff) | |
download | trackermap-server-a6f54888e873ff083d195f28ddebef08011c4306.tar.gz trackermap-server-a6f54888e873ff083d195f28ddebef08011c4306.tar.bz2 trackermap-server-a6f54888e873ff083d195f28ddebef08011c4306.zip |
Handle Bofan PT600 long frames
Diffstat (limited to 'src')
-rw-r--r-- | src/org/traccar/protocol/Pt502FrameDecoder.java | 11 |
1 files changed, 9 insertions, 2 deletions
diff --git a/src/org/traccar/protocol/Pt502FrameDecoder.java b/src/org/traccar/protocol/Pt502FrameDecoder.java index ce20dff1f..252c8dd02 100644 --- a/src/org/traccar/protocol/Pt502FrameDecoder.java +++ b/src/org/traccar/protocol/Pt502FrameDecoder.java @@ -37,9 +37,16 @@ public class Pt502FrameDecoder extends FrameDecoder { } int index = buf.indexOf(buf.readerIndex(), buf.writerIndex(), (byte) '\r'); - if (index != -1 && index + 1 < buf.writerIndex()) { + if (index < 0) { + index = buf.indexOf(buf.readerIndex(), buf.writerIndex(), (byte) '\n'); + } + + if (index > 0) { ChannelBuffer result = buf.readBytes(index - buf.readerIndex()); - buf.skipBytes(2); + while (buf.readable() + && (buf.getByte(buf.readerIndex()) == '\r' || buf.getByte(buf.readerIndex()) == '\n')) { + buf.skipBytes(1); + } return result; } |