diff options
author | user <user@laptop.(none)> | 2012-10-21 17:44:59 +1300 |
---|---|---|
committer | user <user@laptop.(none)> | 2012-10-21 17:44:59 +1300 |
commit | a3441d3bcd02ec48e408957dfdc61dc6850bc339 (patch) | |
tree | b62cd0cd31b7deb2e6c4360e5a4d2cbcba55acc4 /src/org/traccar/helper | |
parent | f5bb85ff12db673ecc30f5cbaddc3b43a9d3310b (diff) | |
download | trackermap-server-a3441d3bcd02ec48e408957dfdc61dc6850bc339.tar.gz trackermap-server-a3441d3bcd02ec48e408957dfdc61dc6850bc339.tar.bz2 trackermap-server-a3441d3bcd02ec48e408957dfdc61dc6850bc339.zip |
Add JT600 support (fix #58)
Diffstat (limited to 'src/org/traccar/helper')
-rw-r--r-- | src/org/traccar/helper/ChannelBufferTools.java | 24 |
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; + } } |