aboutsummaryrefslogtreecommitdiff
path: root/src/org/traccar/helper
diff options
context:
space:
mode:
authoruser <user@laptop.(none)>2012-10-21 17:44:59 +1300
committeruser <user@laptop.(none)>2012-10-21 17:44:59 +1300
commita3441d3bcd02ec48e408957dfdc61dc6850bc339 (patch)
treeb62cd0cd31b7deb2e6c4360e5a4d2cbcba55acc4 /src/org/traccar/helper
parentf5bb85ff12db673ecc30f5cbaddc3b43a9d3310b (diff)
downloadtraccar-server-a3441d3bcd02ec48e408957dfdc61dc6850bc339.tar.gz
traccar-server-a3441d3bcd02ec48e408957dfdc61dc6850bc339.tar.bz2
traccar-server-a3441d3bcd02ec48e408957dfdc61dc6850bc339.zip
Add JT600 support (fix #58)
Diffstat (limited to 'src/org/traccar/helper')
-rw-r--r--src/org/traccar/helper/ChannelBufferTools.java24
1 files changed, 24 insertions, 0 deletions
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;
+ }
}