aboutsummaryrefslogtreecommitdiff
path: root/src/org/traccar
diff options
context:
space:
mode:
authorAnton Tananaev <anton.tananaev@gmail.com>2017-10-31 19:46:36 +1300
committerAnton Tananaev <anton.tananaev@gmail.com>2017-10-31 19:46:49 +1300
commita6f54888e873ff083d195f28ddebef08011c4306 (patch)
treecedb01c79b684ebfbf0c5baed744b8c1830abf12 /src/org/traccar
parent6475bc9db3b1446bb90d2102003201db5611ddf0 (diff)
downloadtrackermap-server-a6f54888e873ff083d195f28ddebef08011c4306.tar.gz
trackermap-server-a6f54888e873ff083d195f28ddebef08011c4306.tar.bz2
trackermap-server-a6f54888e873ff083d195f28ddebef08011c4306.zip
Handle Bofan PT600 long frames
Diffstat (limited to 'src/org/traccar')
-rw-r--r--src/org/traccar/protocol/Pt502FrameDecoder.java11
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;
}