From 1264391afbf2407b5ea406f3b540ca34cb667543 Mon Sep 17 00:00:00 2001 From: Anton Tananaev Date: Thu, 8 Oct 2015 22:06:36 +1300 Subject: Improve Tytan fuel decoding --- src/org/traccar/protocol/TytanProtocolDecoder.java | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/src/org/traccar/protocol/TytanProtocolDecoder.java b/src/org/traccar/protocol/TytanProtocolDecoder.java index a16bd4e4b..e6710413e 100644 --- a/src/org/traccar/protocol/TytanProtocolDecoder.java +++ b/src/org/traccar/protocol/TytanProtocolDecoder.java @@ -177,7 +177,20 @@ public class TytanProtocolDecoder extends BaseProtocolDecoder { position.set(Event.KEY_RPM, buf.readUnsignedByte() * 50); break; case 107: - position.set(Event.KEY_FUEL, (buf.readUnsignedShort() & 0x3fff) * 0.5); + { + int fuel = buf.readUnsignedShort(); + switch (fuel >> 16) { + case 1: + position.set(Event.KEY_FUEL, (buf.readUnsignedShort() & 0x3fff) * 0.4 + "%"); + break; + case 2: + position.set(Event.KEY_FUEL, (buf.readUnsignedShort() & 0x3fff) * 0.5 + "l"); + break; + case 3: + position.set(Event.KEY_FUEL, (buf.readUnsignedShort() & 0x3fff) * -0.5 + "l"); + break; + } + } break; case 108: position.set(Event.KEY_OBD_ODOMETER, buf.readUnsignedInt() * 5); -- cgit v1.2.3