aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/org/traccar/protocol/TytanProtocolDecoder.java12
-rw-r--r--test/org/traccar/protocol/TytanProtocolDecoderTest.java4
2 files changed, 12 insertions, 4 deletions
diff --git a/src/org/traccar/protocol/TytanProtocolDecoder.java b/src/org/traccar/protocol/TytanProtocolDecoder.java
index bfb1e33a3..04d095a9f 100644
--- a/src/org/traccar/protocol/TytanProtocolDecoder.java
+++ b/src/org/traccar/protocol/TytanProtocolDecoder.java
@@ -115,7 +115,7 @@ public class TytanProtocolDecoder extends BaseProtocolDecoder {
switch (type) {
case 2:
- position.set(Event.KEY_ODOMETER, buf.readUnsignedMedium());
+ position.set(Event.KEY_ODOMETER, buf.readUnsignedMedium() * 5);
break;
case 5:
position.set(Event.KEY_INPUT, buf.readUnsignedByte());
@@ -131,7 +131,13 @@ public class TytanProtocolDecoder extends BaseProtocolDecoder {
}
break;
case 7:
- position.set(Event.KEY_ALARM, buf.readUnsignedShort());
+ {
+ int alarm = buf.readUnsignedByte();
+ buf.readUnsignedByte();
+ if (BitUtil.check(alarm, 5)) {
+ position.set(Event.KEY_ALARM, BitUtil.range(alarm, 0, 4));
+ }
+ }
break;
case 8:
position.set("antihijack", buf.readUnsignedByte());
@@ -165,7 +171,7 @@ public class TytanProtocolDecoder extends BaseProtocolDecoder {
position.set(Event.KEY_POWER, readSwappedFloat(buf));
break;
case 107:
- position.set(Event.KEY_FUEL, buf.readUnsignedShort() & 0x3fff);
+ position.set(Event.KEY_FUEL, (buf.readUnsignedShort() & 0x3fff) * 0.5);
break;
case 150:
position.set("door", buf.readUnsignedByte());
diff --git a/test/org/traccar/protocol/TytanProtocolDecoderTest.java b/test/org/traccar/protocol/TytanProtocolDecoderTest.java
index 3777ad4c4..aeb45b341 100644
--- a/test/org/traccar/protocol/TytanProtocolDecoderTest.java
+++ b/test/org/traccar/protocol/TytanProtocolDecoderTest.java
@@ -3,7 +3,6 @@ package org.traccar.protocol;
import org.jboss.netty.buffer.ChannelBuffers;
import org.junit.Test;
import org.traccar.helper.ChannelBufferTools;
-
import static org.traccar.helper.DecoderVerifier.verify;
public class TytanProtocolDecoderTest extends ProtocolDecoderTest {
@@ -12,6 +11,9 @@ public class TytanProtocolDecoderTest extends ProtocolDecoderTest {
public void testDecode() throws Exception {
TytanProtocolDecoder decoder = new TytanProtocolDecoder(new TytanProtocol());
+
+ verify(decoder.decode(null, null, ChannelBuffers.wrappedBuffer(ChannelBufferTools.convertHexString(
+ "b50069a00000689d315604512b32378f1a8e9fe094005a04d7c84b41020300ab250402140c0702c0006501006601006b0280646c0402883db0315604525732378f1d8e9fdd94005a04d7c84b41020300ab250402140c0702c0006501006601006b0280646c0402883db08887"))));
verify(decoder.decode(null, null, ChannelBuffers.wrappedBuffer(ChannelBufferTools.convertHexString(
"b50028080000689d215602772f00378f1b8e9fdd98005a042efb3e4102030000000402140c070200000901"))));