aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorAnton Tananaev <anton.tananaev@gmail.com>2020-11-14 11:30:06 -0800
committerAnton Tananaev <anton.tananaev@gmail.com>2020-11-14 11:30:06 -0800
commitf3d1281d421a83677fbbcd25426e3440efc4c00a (patch)
tree7bdcfadb97d9806bd0398f009d62bddcad0f1b11 /src
parentebd0688d342d26be078f89ca6b5fbd0d5717bbdc (diff)
downloadtraccar-server-f3d1281d421a83677fbbcd25426e3440efc4c00a.tar.gz
traccar-server-f3d1281d421a83677fbbcd25426e3440efc4c00a.tar.bz2
traccar-server-f3d1281d421a83677fbbcd25426e3440efc4c00a.zip
Support ControlSat CST-10
Diffstat (limited to 'src')
-rw-r--r--src/main/java/org/traccar/protocol/TaipProtocolDecoder.java42
-rw-r--r--src/test/java/org/traccar/protocol/TaipProtocolDecoderTest.java11
2 files changed, 50 insertions, 3 deletions
diff --git a/src/main/java/org/traccar/protocol/TaipProtocolDecoder.java b/src/main/java/org/traccar/protocol/TaipProtocolDecoder.java
index 8a0cb870b..285e68ddd 100644
--- a/src/main/java/org/traccar/protocol/TaipProtocolDecoder.java
+++ b/src/main/java/org/traccar/protocol/TaipProtocolDecoder.java
@@ -1,5 +1,5 @@
/*
- * Copyright 2013 - 2018 Anton Tananaev (anton@traccar.org)
+ * Copyright 2013 - 2020 Anton Tananaev (anton@traccar.org)
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -49,7 +49,7 @@ public class TaipProtocolDecoder extends BaseProtocolDecoder {
.groupEnd("?")
.number("(d{5})") // seconds
.or()
- .expression("(?:RGP|RCQ|RCV|RBR)") // type
+ .expression("(?:RGP|RCQ|RCV|RBR|RUS00),?") // type
.number("(dd)?") // event
.number("(dd)(dd)(dd)") // date (mmddyy)
.number("(dd)(dd)(dd)") // time (hhmmss)
@@ -67,8 +67,20 @@ public class TaipProtocolDecoder extends BaseProtocolDecoder {
.number("([023])") // fix mode
.number("xx") // data age
.number("(xx)") // input
+ .groupBegin()
+ .number(",d+") // flow meter
+ .number(",(d+)") // odometer
+ .number(",(d{4})(d{4})") // power / battery
+ .number(",(d+)") // rpm
+ .groupBegin()
+ .number(",(-?d+)") // temperature 1
+ .number(",(-?d+)") // temperature 2
+ .groupEnd("?")
+ .number(",(xx)") // alarm
+ .or()
.number("(dd)") // event
.number("(dd)") // hdop
+ .groupEnd()
.or()
.groupBegin()
.number("(xx)") // input
@@ -108,6 +120,17 @@ public class TaipProtocolDecoder extends BaseProtocolDecoder {
return DateUtil.correctDay(dateBuilder.getDate());
}
+ private String decodeAlarm(int value) {
+ switch (value) {
+ case 0x01:
+ return Position.ALARM_SOS;
+ case 0x02:
+ return Position.ALARM_POWER_CUT;
+ default:
+ return null;
+ }
+ }
+
@Override
protected Object decode(
Channel channel, SocketAddress remoteAddress, Object msg) throws Exception {
@@ -156,11 +179,24 @@ public class TaipProtocolDecoder extends BaseProtocolDecoder {
position.setSpeed(UnitsConverter.knotsFromMph(parser.nextDouble(0)));
position.setCourse(parser.nextDouble(0));
- if (parser.hasNext(4)) {
+ if (parser.hasNext(2)) {
valid = parser.nextInt() > 0;
int input = parser.nextHexInt();
position.set(Position.KEY_IGNITION, BitUtil.check(input, 7));
position.set(Position.KEY_INPUT, input);
+ }
+
+ if (parser.hasNext(7)) {
+ position.set(Position.KEY_ODOMETER, parser.nextInt());
+ position.set(Position.KEY_POWER, parser.nextInt() * 0.01);
+ position.set(Position.KEY_BATTERY, parser.nextInt() * 0.01);
+ position.set(Position.KEY_RPM, parser.nextInt());
+ position.set(Position.PREFIX_TEMP + 1, parser.nextInt());
+ position.set(Position.PREFIX_TEMP + 2, parser.nextInt());
+ position.set(Position.KEY_ALARM, decodeAlarm(parser.nextHexInt()));
+ }
+
+ if (parser.hasNext(2)) {
event = parser.nextInt();
position.set(Position.KEY_HDOP, parser.nextInt());
}
diff --git a/src/test/java/org/traccar/protocol/TaipProtocolDecoderTest.java b/src/test/java/org/traccar/protocol/TaipProtocolDecoderTest.java
index 0b9eacb8d..b4594bb0e 100644
--- a/src/test/java/org/traccar/protocol/TaipProtocolDecoderTest.java
+++ b/src/test/java/org/traccar/protocol/TaipProtocolDecoderTest.java
@@ -2,6 +2,7 @@ package org.traccar.protocol;
import org.junit.Test;
import org.traccar.ProtocolTest;
+import org.traccar.model.Position;
public class TaipProtocolDecoderTest extends ProtocolTest {
@@ -10,6 +11,16 @@ public class TaipProtocolDecoderTest extends ProtocolTest {
TaipProtocolDecoder decoder = new TaipProtocolDecoder(null);
+ verifyAttribute(decoder, text(
+ ">RUS00,031120185945-3138060-06417622000209200FF,000000000000000000000000000,0000000000,11440419,00000,00000,00000,00;ID=CST3G0495;#IP0:1EF7;*4B<"),
+ Position.KEY_BATTERY, 4.19);
+
+ verifyPosition(decoder, text(
+ ">RUS00,031120185945-3138060-06417622000209200FF,000000000000000000000000000,0000000000,11440419,00000,00;ID=CST3G0495;#IP0:1EF7;*4B<"));
+
+ verifyPosition(decoder, text(
+ ">RGP041120190000-3137454-064075520001883004D50;ID=8385;#IP0:0080;*19<"));
+
verifyNull(decoder, text(
">RLN25601000+297185103-0955755990+000059150000+0000000012000000000000000000000000000000000000000000000000000000000012;ID=3580;*48<"));