aboutsummaryrefslogtreecommitdiff
path: root/src/org/traccar/protocol/TytanProtocolDecoder.java
diff options
context:
space:
mode:
authorAnton Tananaev <anton.tananaev@gmail.com>2015-05-05 12:18:30 +1200
committerAnton Tananaev <anton.tananaev@gmail.com>2015-05-05 12:18:30 +1200
commitb9d6befdbcc1a56c87d14066d67da574762d81bc (patch)
treeec1ebaa1ed015439c3560472e7233d6ee759d4d9 /src/org/traccar/protocol/TytanProtocolDecoder.java
parentc8793e2163f59a25c2d78aaa141ffab2e6338dff (diff)
downloadtrackermap-server-b9d6befdbcc1a56c87d14066d67da574762d81bc.tar.gz
trackermap-server-b9d6befdbcc1a56c87d14066d67da574762d81bc.tar.bz2
trackermap-server-b9d6befdbcc1a56c87d14066d67da574762d81bc.zip
Fix Tytan extra data decoding
Diffstat (limited to 'src/org/traccar/protocol/TytanProtocolDecoder.java')
-rw-r--r--src/org/traccar/protocol/TytanProtocolDecoder.java20
1 files changed, 14 insertions, 6 deletions
diff --git a/src/org/traccar/protocol/TytanProtocolDecoder.java b/src/org/traccar/protocol/TytanProtocolDecoder.java
index 5d8abd9ae..49757d7b0 100644
--- a/src/org/traccar/protocol/TytanProtocolDecoder.java
+++ b/src/org/traccar/protocol/TytanProtocolDecoder.java
@@ -17,9 +17,7 @@ package org.traccar.protocol;
import java.net.SocketAddress;
import java.nio.charset.Charset;
-import java.util.Date;
-import java.util.LinkedList;
-import java.util.List;
+import java.util.*;
import org.jboss.netty.buffer.ChannelBuffer;
import org.jboss.netty.buffer.ChannelBuffers;
@@ -96,6 +94,7 @@ public class TytanProtocolDecoder extends BaseProtocolDecoder {
}
while (buf.readerIndex() < end) {
+ int x = buf.getUnsignedByte(buf.readerIndex());
switch (buf.readUnsignedByte()) {
case 2:
position.set(Event.KEY_ODOMETER, buf.readUnsignedMedium());
@@ -107,7 +106,7 @@ public class TytanProtocolDecoder extends BaseProtocolDecoder {
position.set(Event.KEY_INPUT, buf.readUnsignedByte());
break;
case 6:
- buf.readUnsignedShort();
+ buf.readUnsignedByte();
position.set(Event.PREFIX_ADC + 1, buf.readFloat());
break;
case 7:
@@ -126,8 +125,17 @@ public class TytanProtocolDecoder extends BaseProtocolDecoder {
buf.skipBytes(9);
break;
case 24:
- buf.readUnsignedByte();
- position.set(Event.PREFIX_TEMP + 1, buf.readUnsignedByte());
+ Set<Integer> temps = new LinkedHashSet<Integer>();
+ int temp = buf.readUnsignedByte();
+ for (int i = 3; i >= 0; i--) {
+ int n = (temp >> (2 * i)) & 0x03;
+ if (!temps.contains(n)) {
+ temps.add(n);
+ }
+ }
+ for (int n : temps) {
+ position.set(Event.PREFIX_TEMP + n, buf.readUnsignedByte());
+ }
break;
case 25:
buf.readUnsignedByte();