From a3441d3bcd02ec48e408957dfdc61dc6850bc339 Mon Sep 17 00:00:00 2001 From: user Date: Sun, 21 Oct 2012 17:44:59 +1300 Subject: Add JT600 support (fix #58) --- src/org/traccar/helper/ChannelBufferTools.java | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) (limited to 'src/org/traccar/helper/ChannelBufferTools.java') diff --git a/src/org/traccar/helper/ChannelBufferTools.java b/src/org/traccar/helper/ChannelBufferTools.java index 6df1f7ba2..9139ed7ae 100644 --- a/src/org/traccar/helper/ChannelBufferTools.java +++ b/src/org/traccar/helper/ChannelBufferTools.java @@ -52,5 +52,29 @@ public class ChannelBufferTools { return null; } + + /** + * Convert hex to integer (length in hex digits) + */ + public static int readHexInteger(ChannelBuffer buf, int length) { + + int result = 0; + + for (int i = 0; i < length / 2; i++) { + int b = buf.readUnsignedByte(); + result *= 10; + result += b >>> 4; + result *= 10; + result += b & 0x0f; + } + + if (length % 2 == 1) { + int b = buf.getUnsignedByte(buf.readerIndex()); + result *= 10; + result += b >>> 4; + } + + return result; + } } -- cgit v1.2.3