aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/org/traccar/protocol/TytanProtocolDecoder.java124
-rw-r--r--test/org/traccar/protocol/TytanProtocolDecoderTest.java7
2 files changed, 123 insertions, 8 deletions
diff --git a/src/org/traccar/protocol/TytanProtocolDecoder.java b/src/org/traccar/protocol/TytanProtocolDecoder.java
index e0dc7f68e..8df8f6a25 100644
--- a/src/org/traccar/protocol/TytanProtocolDecoder.java
+++ b/src/org/traccar/protocol/TytanProtocolDecoder.java
@@ -20,15 +20,13 @@ import java.nio.charset.Charset;
import java.util.Date;
import java.util.LinkedList;
import java.util.List;
-import java.util.Properties;
import org.jboss.netty.buffer.ChannelBuffer;
import org.jboss.netty.buffer.ChannelBuffers;
import org.jboss.netty.channel.Channel;
import org.jboss.netty.channel.ChannelHandlerContext;
import org.traccar.BaseProtocolDecoder;
-import org.traccar.database.DataManager;
-import org.traccar.helper.Log;
+import org.traccar.helper.ChannelBufferTools;
import org.traccar.model.ExtendedInfoFormatter;
import org.traccar.model.Position;
@@ -102,7 +100,125 @@ public class TytanProtocolDecoder extends BaseProtocolDecoder {
position.setSpeed(speed * 0.539957);
}
- buf.skipBytes(end - buf.readerIndex());
+ while (buf.readerIndex() < end) {
+ switch (buf.readUnsignedByte()) {
+ case 2:
+ extendedInfo.set("milage", buf.readUnsignedMedium());
+ break;
+ case 4:
+ buf.readUnsignedShort(); // device start
+ break;
+ case 5:
+ extendedInfo.set("input", buf.readUnsignedByte());
+ break;
+ case 6:
+ buf.readUnsignedShort();
+ extendedInfo.set("adc", buf.readFloat());
+ break;
+ case 7:
+ extendedInfo.set("alarm", buf.readUnsignedShort());
+ break;
+ case 8:
+ extendedInfo.set("antihijack", buf.readUnsignedByte());
+ break;
+ case 9:
+ extendedInfo.set("authorized", ChannelBufferTools.readHexString(buf, 16));
+ break;
+ case 10:
+ extendedInfo.set("unauthorized", ChannelBufferTools.readHexString(buf, 16));
+ break;
+ case 24:
+ buf.readUnsignedByte();
+ extendedInfo.set("temperature", buf.readUnsignedByte());
+ break;
+ case 25:
+ buf.readUnsignedByte();
+ buf.readUnsignedShort(); // fuel
+ break;
+ case 26:
+ buf.skipBytes(buf.readUnsignedByte() * 2); // flowmeter
+ break;
+ case 28:
+ extendedInfo.set("weight", buf.readUnsignedShort());
+ buf.readUnsignedByte();
+ break;
+ case 29:
+ buf.readUnsignedByte(); // diagnostics
+ break;
+ case 30:
+ buf.readUnsignedByte(); // vending machine
+ buf.readUnsignedInt();
+ buf.readUnsignedInt();
+ buf.readUnsignedInt();
+ break;
+ case 31:
+ buf.readUnsignedByte(); // antihijack
+ break;
+ case 32:
+ buf.readUnsignedByte(); // audio
+ break;
+ case 33:
+ buf.readUnsignedByte(); // antihijack and authorization
+ break;
+ case 80:
+ case 81:
+ case 82:
+ case 83:
+ buf.readUnsignedInt(); // diagnostic
+ break;
+ case 99:
+ buf.readUnsignedInt(); // tachograph
+ break;
+ case 101:
+ buf.readUnsignedByte(); // speed
+ break;
+ case 102:
+ buf.readUnsignedByte(); // engine rpm
+ break;
+ case 103:
+ buf.readUnsignedByte(); // engine temperature
+ break;
+ case 104:
+ buf.readUnsignedByte(); // pedal position
+ break;
+ case 105:
+ buf.readUnsignedByte(); // engine load
+ break;
+ case 107:
+ extendedInfo.set("fuel", buf.readUnsignedShort() & 0x3fff);
+ break;
+ case 108:
+ buf.readUnsignedInt(); // total distance
+ break;
+ case 109:
+ buf.readUnsignedByte(); // ambient temperature
+ break;
+ case 122:
+ buf.readUnsignedByte(); // power take-off state
+ break;
+ case 127:
+ buf.readUnsignedInt(); // total fuel used
+ break;
+ case 129:
+ buf.readUnsignedInt(); // engine total hours
+ break;
+ case 130:
+ buf.readUnsignedShort(); // distance to service
+ break;
+ case 131:
+ buf.readUnsignedShort(); // axle weight
+ buf.readUnsignedShort();
+ buf.readUnsignedShort();
+ buf.readUnsignedShort();
+ break;
+ case 136:
+ buf.readUnsignedShort(); // fuel rate
+ break;
+ case 150:
+ extendedInfo.set("door", buf.readUnsignedByte());
+ break;
+ }
+ }
position.setExtendedInfo(extendedInfo.toString());
positions.add(position);
diff --git a/test/org/traccar/protocol/TytanProtocolDecoderTest.java b/test/org/traccar/protocol/TytanProtocolDecoderTest.java
index 5fdb847b1..57a5b0bd5 100644
--- a/test/org/traccar/protocol/TytanProtocolDecoderTest.java
+++ b/test/org/traccar/protocol/TytanProtocolDecoderTest.java
@@ -5,7 +5,6 @@ import static org.junit.Assert.assertNull;
import org.junit.Test;
import org.traccar.helper.ChannelBufferTools;
import static org.traccar.helper.DecoderVerifier.verify;
-import org.traccar.helper.TestDataManager;
public class TytanProtocolDecoderTest extends ProtocolDecoderTest {
@@ -13,6 +12,9 @@ public class TytanProtocolDecoderTest extends ProtocolDecoderTest {
public void testDecode() throws Exception {
TytanProtocolDecoder decoder = new TytanProtocolDecoder(null);
+
+ verify(decoder.decode(null, null, null, ChannelBuffers.wrappedBuffer(ChannelBufferTools.convertHexString(
+ "D5F0FF00001032552F9121D5325FCB8D11AFA0000205396504004C0602FB5B434118001765006603676B68006B80426C02E2C8206D2F9600"))));
verify(decoder.decode(null, null, null, ChannelBuffers.wrappedBuffer(ChannelBufferTools.convertHexString(
"D56000000AF20E4FA7C77AFF3282C68D2F890800"))));
@@ -21,9 +23,6 @@ public class TytanProtocolDecoderTest extends ProtocolDecoderTest {
"D56000000AF20e552e248007375bee8c02b3c002"))));
verify(decoder.decode(null, null, null, ChannelBuffers.wrappedBuffer(ChannelBufferTools.convertHexString(
- "D5F0FF00001032552F9121D5325FCB8D11AFA0000205396504004C0602FB5B434118001765006603676B68006B80426C02E2C8206D2F9600"))));
-
- verify(decoder.decode(null, null, null, ChannelBuffers.wrappedBuffer(ChannelBufferTools.convertHexString(
"D5C0FF00013D21552F9148D3325E8F8D11A80800060228816541061245FF674107C0001810130D21552F9148D3325E8F8D11A8080006022881654106121C46694107C0001810130D21552F9182D3325E8F8D11A8080006022881654106121C46694107C0001810140C"))));
verify(decoder.decode(null, null, null, ChannelBuffers.wrappedBuffer(ChannelBufferTools.convertHexString(