From 0de1d3e5ba4527bdef27b4e90f528300f5197c3e Mon Sep 17 00:00:00 2001 From: Anton Tananaev Date: Wed, 29 Jul 2015 11:23:40 +1200 Subject: Update Xexun frame decoder --- src/org/traccar/helper/ChannelBufferTools.java | 6 +++++- src/org/traccar/protocol/XexunFrameDecoder.java | 8 ++++---- 2 files changed, 9 insertions(+), 5 deletions(-) (limited to 'src/org/traccar') diff --git a/src/org/traccar/helper/ChannelBufferTools.java b/src/org/traccar/helper/ChannelBufferTools.java index ef9384138..1ebe89666 100644 --- a/src/org/traccar/helper/ChannelBufferTools.java +++ b/src/org/traccar/helper/ChannelBufferTools.java @@ -24,7 +24,11 @@ import org.traccar.protocol.IntellitracFrameDecoder; * ChannelBuffer helper methods */ public class ChannelBufferTools { - + + public static Integer find(ChannelBuffer buf, int start, String subString) { + return find(buf, start, buf.readerIndex() + buf.readableBytes(), subString); + } + /** * Find string in network buffer */ diff --git a/src/org/traccar/protocol/XexunFrameDecoder.java b/src/org/traccar/protocol/XexunFrameDecoder.java index 1b3446ff9..60fa02696 100644 --- a/src/org/traccar/protocol/XexunFrameDecoder.java +++ b/src/org/traccar/protocol/XexunFrameDecoder.java @@ -36,22 +36,22 @@ public class XexunFrameDecoder extends FrameDecoder { } // Find start - Integer beginIndex = ChannelBufferTools.find(buf, 0, length, "GPRMC"); + Integer beginIndex = ChannelBufferTools.find(buf, buf.readerIndex(), "GPRMC"); if (beginIndex == null) { - beginIndex = ChannelBufferTools.find(buf, 0, length, "GNRMC"); + beginIndex = ChannelBufferTools.find(buf, buf.readerIndex(), "GNRMC"); if (beginIndex == null) { return null; } } // Find identifier - Integer idIndex = ChannelBufferTools.find(buf, beginIndex, length, "imei:"); + Integer idIndex = ChannelBufferTools.find(buf, beginIndex, "imei:"); if (idIndex == null) { return null; } // Find end - Integer endIndex = ChannelBufferTools.find(buf, idIndex, length, ","); + Integer endIndex = ChannelBufferTools.find(buf, idIndex, ","); if (endIndex == null) { return null; } -- cgit v1.2.3