aboutsummaryrefslogtreecommitdiff
path: root/src/org/traccar
diff options
context:
space:
mode:
Diffstat (limited to 'src/org/traccar')
-rw-r--r--src/org/traccar/protocol/H02FrameDecoder.java16
1 files changed, 9 insertions, 7 deletions
diff --git a/src/org/traccar/protocol/H02FrameDecoder.java b/src/org/traccar/protocol/H02FrameDecoder.java
index d461c9219..a22252a57 100644
--- a/src/org/traccar/protocol/H02FrameDecoder.java
+++ b/src/org/traccar/protocol/H02FrameDecoder.java
@@ -54,16 +54,18 @@ public class H02FrameDecoder extends FrameDecoder {
} else if (marker == '$') {
- if (messageLength > 0 && buf.readableBytes() >= messageLength) {
- return buf.readBytes(messageLength);
- } else if (buf.readableBytes() >= MESSAGE_SHORT) {
- if (buf.getUnsignedByte(buf.readerIndex() + MESSAGE_SHORT - 1) == 0) {
- return buf.readBytes(MESSAGE_SHORT);
- } else if (buf.readableBytes() >= MESSAGE_LONG) {
- return buf.readBytes(MESSAGE_LONG);
+ if (messageLength == 0) {
+ if (buf.readableBytes() == MESSAGE_LONG) {
+ messageLength = MESSAGE_LONG;
+ } else {
+ messageLength = MESSAGE_SHORT;
}
}
+ if (buf.readableBytes() >= messageLength) {
+ return buf.readBytes(messageLength);
+ }
+
}
return null;