aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAnton Tananaev <anton.tananaev@gmail.com>2016-06-28 16:35:07 +1200
committerAnton Tananaev <anton.tananaev@gmail.com>2016-06-28 16:35:07 +1200
commitaaff3f18b8dbc44287a237cd39eba91b77705f82 (patch)
tree36a1a76526aed75da591076f13ea662ad0f13543
parent7327681f0bd2338f9c8ee3ea1b4a19dcc5f0de48 (diff)
downloadtraccar-server-aaff3f18b8dbc44287a237cd39eba91b77705f82.tar.gz
traccar-server-aaff3f18b8dbc44287a237cd39eba91b77705f82.tar.bz2
traccar-server-aaff3f18b8dbc44287a237cd39eba91b77705f82.zip
Add CAN support for Galileo protocol
-rw-r--r--src/org/traccar/protocol/GalileoProtocolDecoder.java15
-rw-r--r--test/org/traccar/protocol/GalileoProtocolDecoderTest.java3
2 files changed, 14 insertions, 4 deletions
diff --git a/src/org/traccar/protocol/GalileoProtocolDecoder.java b/src/org/traccar/protocol/GalileoProtocolDecoder.java
index fddabee60..02d3ac314 100644
--- a/src/org/traccar/protocol/GalileoProtocolDecoder.java
+++ b/src/org/traccar/protocol/GalileoProtocolDecoder.java
@@ -50,6 +50,7 @@ public class GalileoProtocolDecoder extends BaseProtocolDecoder {
private static final int TAG_ODOMETER = 0xd4;
private static final int TAG_REFRIGERATOR = 0x5b;
private static final int TAG_PRESSURE = 0x5c;
+ private static final int TAG_CAN = 0xc1;
private static final Map<Integer, Integer> TAG_LENGTH_MAP = new HashMap<>();
@@ -74,10 +75,10 @@ public class GalileoProtocolDecoder extends BaseProtocolDecoder {
0x69, 0x6a, 0x6b, 0x6c, 0x6d, 0x6e
};
int[] l4 = {
- 0x20, 0x33, 0x44, 0x90, 0xc0, 0xc1, 0xc2, 0xc3,
- 0xd3, 0xd4, 0xdb, 0xdc, 0xdd, 0xde, 0xdf, 0xf0,
- 0xf9, 0x5a, 0x47, 0xf1, 0xf2, 0xf3, 0xf4, 0xf5,
- 0xf6, 0xf7, 0xf8
+ 0x20, 0x33, 0x44, 0x90, 0xc0, 0xc2, 0xc3, 0xd3,
+ 0xd4, 0xdb, 0xdc, 0xdd, 0xde, 0xdf, 0xf0, 0xf9,
+ 0x5a, 0x47, 0xf1, 0xf2, 0xf3, 0xf4, 0xf5, 0xf6,
+ 0xf7, 0xf8
};
for (int i : l1) {
TAG_LENGTH_MAP.put(i, 1);
@@ -183,6 +184,12 @@ public class GalileoProtocolDecoder extends BaseProtocolDecoder {
position.set(Position.KEY_ODOMETER, buf.readUnsignedInt());
break;
+ case TAG_CAN:
+ position.set(Position.KEY_FUEL, buf.readUnsignedByte() * 0.4);
+ position.set(Position.PREFIX_TEMP + 1, buf.readUnsignedByte() - 40);
+ position.set(Position.KEY_RPM, buf.readUnsignedShort() * 0.125);
+ break;
+
default:
buf.skipBytes(getTagLength(tag));
break;
diff --git a/test/org/traccar/protocol/GalileoProtocolDecoderTest.java b/test/org/traccar/protocol/GalileoProtocolDecoderTest.java
index d396627b5..c18a652f7 100644
--- a/test/org/traccar/protocol/GalileoProtocolDecoderTest.java
+++ b/test/org/traccar/protocol/GalileoProtocolDecoderTest.java
@@ -12,6 +12,9 @@ public class GalileoProtocolDecoderTest extends ProtocolTest {
GalileoProtocolDecoder decoder = new GalileoProtocolDecoder(new GalileoProtocol());
+ verifyPositions(decoder, binary(ByteOrder.LITTLE_ENDIAN,
+ "0144030338363832303430303132363939333404320010ee0f20f5a86c57300570172f03bc7dfd023363002604343e00351c40092a414a6842af0e432445000046030050246b51666a524c055300000338363832303430303132363939333404320010ed0f20f4a86c57300570172f03b47dfd023363000d05343e00351140090a41c56742a60e432445000046030050b56a514f6a521b045300000338363832303430303132363939333404320010ec0f20e6a86c57300b34172f03287efd023300000000344900350d40290a41562742030b43234500004603205023455190445295005300000338363832303430303132363939333404320010eb0f20e4a86c57300b34172f03287efd023300000000344900350d40290b41000042bd0b432345000046032050dc31518c315200005300000338363832303430303132363939333404320010ea0f20c7a86c57300b34172f03287efd023300000000344900350d40a90b41000042050d43234500004600205000005100005200005300000338363832303430303132363939333404320010e90f204fa86c57300b34172f03287efd023300000000344900350d40a90b41000042ff0c43244500004600205000005100005200005300000338363832303430303132363939333404320010e80f20d7a76c57300b34172f03287efd023300000000344900350d40a90b41000042fd0c43244500004600205000005100005200005300000338363832303430303132363939333404320010e70f205fa76c57300b34172f03287efd023300000000344900350d40a90b41000042fd0c43254500004600205000005100005200005300000338363832303430303132363939333404320010e60f20e7a66c57300b34172f03287efd023300000000344900350d40a90b41000042fd0c43264500004600205000005100005200005300000338363832303430303132363939333404320010e50f206fa66c57300468172f03907cfd023300007a0a343600352b40a90b41000042030d43274500004600205000005100005200005300000338363832303430303132363939333404320010e40f2051a66c5730048c172f03ac7cfd02335300980a341600352b40a12b41000042040d43274500004600e0500000510000520000530000abde"));
+
verifyNothing(decoder, binary(ByteOrder.LITTLE_ENDIAN,
"011380033836383230343030313534393038370432008590"));