From d0a7032d6e391fc2148d8d91baf1543ac403af96 Mon Sep 17 00:00:00 2001 From: Anton Tananaev Date: Sat, 4 Jan 2020 16:27:56 -0800 Subject: Fix frame decoder --- src/main/java/org/traccar/protocol/OmnicommFrameDecoder.java | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) (limited to 'src/main/java/org/traccar') diff --git a/src/main/java/org/traccar/protocol/OmnicommFrameDecoder.java b/src/main/java/org/traccar/protocol/OmnicommFrameDecoder.java index d6fedc40e..1caf6ceb9 100644 --- a/src/main/java/org/traccar/protocol/OmnicommFrameDecoder.java +++ b/src/main/java/org/traccar/protocol/OmnicommFrameDecoder.java @@ -31,14 +31,14 @@ public class OmnicommFrameDecoder extends BaseFrameDecoder { return null; } - int endIndex = buf.getUnsignedShortLE(2) + buf.readerIndex() + 5; + int endIndex = buf.getUnsignedShortLE(2) + buf.readerIndex() + 6; if (buf.writerIndex() < endIndex) { return null; } ByteBuf result = Unpooled.buffer(); result.writeByte(buf.readUnsignedByte()); - while (buf.readerIndex() <= endIndex) { + while (buf.readerIndex() < endIndex) { int b = buf.readUnsignedByte(); if (b == 0xDB) { int ext = buf.readUnsignedByte(); @@ -47,11 +47,12 @@ public class OmnicommFrameDecoder extends BaseFrameDecoder { } else if (ext == 0xDD) { result.writeByte(0xDB); } + endIndex += 1; } else { result.writeByte(b); } } - return result; + return result; } } -- cgit v1.2.3