From a6f54888e873ff083d195f28ddebef08011c4306 Mon Sep 17 00:00:00 2001 From: Anton Tananaev Date: Tue, 31 Oct 2017 19:46:36 +1300 Subject: Handle Bofan PT600 long frames --- src/org/traccar/protocol/Pt502FrameDecoder.java | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) (limited to 'src/org/traccar') 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; } -- cgit v1.2.3