aboutsummaryrefslogtreecommitdiff
path: root/src/org/traccar/protocol
diff options
context:
space:
mode:
authorAnton Tananaev <anton.tananaev@gmail.com>2016-08-30 21:15:12 +1200
committerAnton Tananaev <anton.tananaev@gmail.com>2016-08-30 21:15:23 +1200
commit8a866049c73636f6f25ff59550da8c5445e7c8fc (patch)
treec63cb810508c6eecb75083072b6dcc84f14bec0f /src/org/traccar/protocol
parente9e587ab105f8741770b8313f8406a28a2e02704 (diff)
downloadtrackermap-server-8a866049c73636f6f25ff59550da8c5445e7c8fc.tar.gz
trackermap-server-8a866049c73636f6f25ff59550da8c5445e7c8fc.tar.bz2
trackermap-server-8a866049c73636f6f25ff59550da8c5445e7c8fc.zip
Improve Megastek frame decoder
Diffstat (limited to 'src/org/traccar/protocol')
-rw-r--r--src/org/traccar/protocol/MegastekFrameDecoder.java10
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;
}
}