diff options
author | Anton Tananaev <anton.tananaev@gmail.com> | 2014-01-05 13:17:44 +1300 |
---|---|---|
committer | Anton Tananaev <anton.tananaev@gmail.com> | 2014-01-05 13:17:44 +1300 |
commit | 6575ff8587bb1507cab8847dd3f6e545a88ae225 (patch) | |
tree | a80db13c0b9ffef63435ee735c3b97bbb92111f1 | |
parent | d5be71c70bfb2ba608c2e0587d21ac6dc538ca4e (diff) | |
download | traccar-server-6575ff8587bb1507cab8847dd3f6e545a88ae225.tar.gz traccar-server-6575ff8587bb1507cab8847dd3f6e545a88ae225.tar.bz2 traccar-server-6575ff8587bb1507cab8847dd3f6e545a88ae225.zip |
Fix H02 binary decoder
-rw-r--r-- | src/org/traccar/protocol/H02ProtocolDecoder.java | 6 | ||||
-rw-r--r-- | test/org/traccar/protocol/H02ProtocolDecoderTest.java | 3 |
2 files changed, 6 insertions, 3 deletions
diff --git a/src/org/traccar/protocol/H02ProtocolDecoder.java b/src/org/traccar/protocol/H02ProtocolDecoder.java index cc59eea9d..f9a1decd6 100644 --- a/src/org/traccar/protocol/H02ProtocolDecoder.java +++ b/src/org/traccar/protocol/H02ProtocolDecoder.java @@ -1,5 +1,5 @@ /* - * Copyright 2012 - 2013 Anton Tananaev (anton.tananaev@gmail.com) + * Copyright 2012 - 2014 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. @@ -40,7 +40,7 @@ public class H02ProtocolDecoder extends BaseProtocolDecoder { int degrees = ChannelBufferTools.readHexInteger(buf, 2); if (lon) { - degrees = degrees * 10 + (buf.getByte(buf.readerIndex()) >> 4); + degrees = degrees * 10 + (buf.getUnsignedByte(buf.readerIndex()) >> 4); } double result = 0; @@ -154,7 +154,7 @@ public class H02ProtocolDecoder extends BaseProtocolDecoder { time.set(Calendar.SECOND, Integer.valueOf(parser.group(index++))); // Validity - position.setValid(parser.group(index++).compareTo("A") == 0 ? true : false); + position.setValid(parser.group(index++).compareTo("A") == 0); // Latitude Double latitude = Double.valueOf(parser.group(index++)); diff --git a/test/org/traccar/protocol/H02ProtocolDecoderTest.java b/test/org/traccar/protocol/H02ProtocolDecoderTest.java index 3ad601cc9..e39c88671 100644 --- a/test/org/traccar/protocol/H02ProtocolDecoderTest.java +++ b/test/org/traccar/protocol/H02ProtocolDecoderTest.java @@ -82,6 +82,9 @@ public class H02ProtocolDecoderTest { int[] buf3 = {0x24,0x10,0x30,0x73,0x10,0x01,0x05,0x03,0x16,0x22,0x09,0x02,0x22,0x12,0x87,0x45,0x00,0x11,0x34,0x66,0x57,0x4C,0x01,0x40,0x28,0xff,0xff,0xfb,0xff,0xff,0x00,0x00}; verify(decoder.decode(null, null, ChannelBuffers.wrappedBuffer(ChannelBufferTools.convertArray(buf3)))); + int[] buf4 = {0x24,0x41,0x09,0x00,0x13,0x45,0x08,0x31,0x25,0x04,0x01,0x14,0x50,0x47,0x88,0x80,0x00,0x00,0x85,0x54,0x65,0x0e,0x00,0x00,0x00,0xff,0xff,0xf9,0xff,0xff,0x00,0x10,0x06,0x00,0x00,0x00,0x00,0x01,0x06,0x02,0x02,0x99,0x10,0x9c,0x01}; + verify(decoder.decode(null, null, ChannelBuffers.wrappedBuffer(ChannelBufferTools.convertArray(buf4)))); + } } |