diff options
author | Stefan Clark <stefanclark@gmail.com> | 2022-07-25 13:34:02 +0000 |
---|---|---|
committer | Stefan Clark <stefanclark@gmail.com> | 2022-07-25 13:34:02 +0000 |
commit | 8b63ce5c51fca9462e0e561b8ce07ae49afce6f8 (patch) | |
tree | 65f591f36e36aae69056216bd01b3a68973ae9b8 /src/main/java | |
parent | 032d02b584553f4374c4bc6ae9f7c8e819595c42 (diff) | |
download | trackermap-server-8b63ce5c51fca9462e0e561b8ce07ae49afce6f8.tar.gz trackermap-server-8b63ce5c51fca9462e0e561b8ce07ae49afce6f8.tar.bz2 trackermap-server-8b63ce5c51fca9462e0e561b8ce07ae49afce6f8.zip |
Update Xexun2 Encoder
Diffstat (limited to 'src/main/java')
-rw-r--r-- | src/main/java/org/traccar/protocol/Xexun2ProtocolEncoder.java | 6 |
1 files changed, 3 insertions, 3 deletions
diff --git a/src/main/java/org/traccar/protocol/Xexun2ProtocolEncoder.java b/src/main/java/org/traccar/protocol/Xexun2ProtocolEncoder.java index d85c6734b..287364cf2 100644 --- a/src/main/java/org/traccar/protocol/Xexun2ProtocolEncoder.java +++ b/src/main/java/org/traccar/protocol/Xexun2ProtocolEncoder.java @@ -32,8 +32,8 @@ public class Xexun2ProtocolEncoder extends BaseProtocolEncoder { } private static ByteBuf encodeFrame(ByteBuf buf) { - buf.clear(); - if (buf.readableBytes() < 5) { + int bufLength = buf.readableBytes(); + if (bufLength < 5) { return null; } @@ -41,7 +41,7 @@ public class Xexun2ProtocolEncoder extends BaseProtocolEncoder { result.writeBytes(buf.readBytes(2)); - while (buf.readerIndex() < buf.capacity() - 2) { + while (buf.readerIndex() < bufLength - 2) { int b = buf.readUnsignedByte(); if (b == 0xfa && buf.isReadable() && buf.getUnsignedByte(buf.readerIndex()) == 0xaf) { buf.readUnsignedByte(); |