aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--setup/other/traccar.sh48
-rwxr-xr-xsetup/package.sh2
-rw-r--r--src/org/traccar/protocol/UproProtocolDecoder.java11
-rw-r--r--test/org/traccar/protocol/UproProtocolDecoderTest.java3
4 files changed, 63 insertions, 1 deletions
diff --git a/setup/other/traccar.sh b/setup/other/traccar.sh
new file mode 100644
index 000000000..fdf1b78e4
--- /dev/null
+++ b/setup/other/traccar.sh
@@ -0,0 +1,48 @@
+#!/bin/sh
+#service traccar server for universal version
+#e.g. ./traccar.sh start
+#e.g. ./traccar.sh stop
+#e.g. ./traccar.sh restart
+
+SERVICE_NAME=traccar
+PATH_TO_JAR=tracker-server.jar
+PATH_TO_CONF=conf/traccar.xml
+PID_PATH_NAME=/tmp/traccar-pid
+case $1 in
+ start)
+ echo "Starting $SERVICE_NAME ..."
+ if [ ! -f $PID_PATH_NAME ]; then
+ nohup java -jar $PATH_TO_JAR $PATH_TO_CONF /tmp 2>> /dev/null >> /dev/null &
+ echo $! > $PID_PATH_NAME
+ echo "$SERVICE_NAME started ..."
+ else
+ echo "$SERVICE_NAME is already running ..."
+ fi
+ ;;
+ stop)
+ if [ -f $PID_PATH_NAME ]; then
+ PID=$(cat $PID_PATH_NAME);
+ echo "$SERVICE_NAME stoping ..."
+ kill $PID;
+ echo "$SERVICE_NAME stopped ..."
+ rm $PID_PATH_NAME
+ else
+ echo "$SERVICE_NAME is not running ..."
+ fi
+ ;;
+ restart)
+ if [ -f $PID_PATH_NAME ]; then
+ PID=$(cat $PID_PATH_NAME);
+ echo "$SERVICE_NAME stopping ...";
+ kill $PID;
+ echo "$SERVICE_NAME stopped ...";
+ rm $PID_PATH_NAME
+ echo "$SERVICE_NAME starting ..."
+ nohup java -jar $PATH_TO_JAR $PATH_TO_CONF /tmp 2>> /dev/null >> /dev/null &
+ echo $! > $PID_PATH_NAME
+ echo "$SERVICE_NAME started ..."
+ else
+ echo "$SERVICE_NAME is not running ..."
+ fi
+ ;;
+esac
diff --git a/setup/package.sh b/setup/package.sh
index d168762d6..4aba86328 100755
--- a/setup/package.sh
+++ b/setup/package.sh
@@ -117,7 +117,7 @@ package_unix () {
mkdir -p out/{bin,conf,data,lib,logs,web,schema,templates}
copy_wrapper "bin"
- find out -type f -name \*.sh -o -name \*.vm -print0 | xargs -0 dos2unix
+ find out -type f \( -name \*.sh -o -name \*.vm \) -print0 | xargs -0 dos2unix
copy_files
makeself out traccar.run "traccar" "\
diff --git a/src/org/traccar/protocol/UproProtocolDecoder.java b/src/org/traccar/protocol/UproProtocolDecoder.java
index d5a00c6df..c6f400cae 100644
--- a/src/org/traccar/protocol/UproProtocolDecoder.java
+++ b/src/org/traccar/protocol/UproProtocolDecoder.java
@@ -121,12 +121,23 @@ public class UproProtocolDecoder extends BaseProtocolDecoder {
case 'B':
position.set(Position.KEY_STATUS, data[i].substring(1));
break;
+ case 'C':
+ long odometer = 0;
+ for (int j = 1; j < data[i].length(); j++) {
+ odometer <<= 4;
+ odometer += data[i].charAt(j) - '0';
+ }
+ position.set(Position.KEY_ODOMETER, odometer);
+ break;
case 'P':
position.set(Position.KEY_MCC, Integer.parseInt(data[i].substring(1, 5)));
position.set(Position.KEY_MNC, Integer.parseInt(data[i].substring(5, 9)));
position.set(Position.KEY_LAC, Integer.parseInt(data[i].substring(9, 13), 16));
position.set(Position.KEY_CID, Integer.parseInt(data[i].substring(13, 17), 16));
break;
+ case 'S':
+ position.set("obd", data[i]);
+ break;
default:
break;
}
diff --git a/test/org/traccar/protocol/UproProtocolDecoderTest.java b/test/org/traccar/protocol/UproProtocolDecoderTest.java
index 034fd78a1..711fe39b6 100644
--- a/test/org/traccar/protocol/UproProtocolDecoderTest.java
+++ b/test/org/traccar/protocol/UproProtocolDecoderTest.java
@@ -11,6 +11,9 @@ public class UproProtocolDecoderTest extends ProtocolTest {
UproProtocolDecoder decoder = new UproProtocolDecoder(new UproProtocol());
verifyPosition(decoder, text(
+ "*MG201693502000035441,BA&A1213073325458307036690710000151116&P0730000032ce4fb3&D1&B0000000000&C005799?7&S3,20161115120025,07035.54659E,3324.87721N,3000,0,0,0,0,847,599,8,40,0,19,20&U_P\0\0\0\0\0\0\0\0\0\0\0\0\0\0&T0107#"));
+
+ verifyPosition(decoder, text(
"*MG201693502000034964,AB&A0800253335360507036975710000091116&P0730000032d2a94d&B0000000000&N13&Z12&U_P\0\0\0\u0004\0\0\0\0\0\0\0\0\0\0#"),
position("2016-11-09 08:00:25.000", true, -33.58934, -70.61626));