diff options
Diffstat (limited to 'src/org')
-rw-r--r-- | src/org/traccar/protocol/MegastekFrameDecoder.java | 10 |
1 files changed, 8 insertions, 2 deletions
diff --git a/src/org/traccar/protocol/MegastekFrameDecoder.java b/src/org/traccar/protocol/MegastekFrameDecoder.java index ba2cc1d25..da77d95fd 100644 --- a/src/org/traccar/protocol/MegastekFrameDecoder.java +++ b/src/org/traccar/protocol/MegastekFrameDecoder.java @@ -1,5 +1,5 @@ /* - * Copyright 2015 Anton Tananaev (anton.tananaev@gmail.com) + * Copyright 2015 - 2016 Anton Tananaev (anton.tananaev@gmail.com) * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -39,10 +39,16 @@ public class MegastekFrameDecoder extends FrameDecoder { return buf.readBytes(length); } } else { + while (buf.getByte(buf.readerIndex()) == '\r' || buf.getByte(buf.readerIndex()) == '\n') { + buf.skipBytes(1); + } int delimiter = buf.indexOf(buf.readerIndex(), buf.writerIndex(), new StringFinder("\r\n")); + if (delimiter == -1) { + delimiter = buf.indexOf(buf.readerIndex(), buf.writerIndex(), (byte) '!'); + } if (delimiter != -1) { ChannelBuffer result = buf.readBytes(delimiter - buf.readerIndex()); - buf.skipBytes(2); + buf.skipBytes(1); return result; } } |