aboutsummaryrefslogtreecommitdiff
path: root/src/org/traccar
diff options
context:
space:
mode:
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;
}