-
Notifications
You must be signed in to change notification settings - Fork 0
/
mux.sh
executable file
·127 lines (127 loc) · 5.82 KB
/
mux.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
#!/usr/bin/env bash
#
# Note: Serial ports on MacOS:
# may require Prolific drivers: https://plugable.com/drivers/prolific/
#
OS=$(uname -s)
#
# MUX_PROP_FILE=nmea.mux.properties # Default value
# MUX_PROP_FILE=nmea.mux.rpi.demo.properties
CLI_PRMS=
if [[ $# -gt 0 ]]; then
if [[ "$1" != "--interactive-config" ]]; then
MUX_PROP_FILE=$1
else
CLI_PRMS=$1 # "--interactive-config"
fi
fi
#
echo Using properties file ${MUX_PROP_FILE}
#
JAVA_OPTIONS=
if [[ "$OS" == "Darwin" ]]; then
# Copy the jnilib file where it belongs, if it is not there.
JAVA_OPTIONS="${JAVA_OPTIONS} -Djava.library.path=/Library/Java/Extensions" # for Mac
# JAVA_OPTIONS="${JAVA_OPTIONS} -Djava.library.path=../Serial.IO/libs" # for Mac
fi
if [[ "$OS" == "Linux" ]]; then
JAVA_OPTIONS="${JAVA_OPTIONS} -Djava.library.path=/usr/lib/jni" # for Raspberry Pi
fi
#
# This variable is used to set the System variable process.on.start.
# (See below).
# It controls ALL the forwarders at once.
#
PROCESS_ON_START=true # Default is true for process.on.start
#
MACHINE_NAME=`uname -a | awk '{ print $2 }'`
HTTP_PORT=`cat ${MUX_PROP_FILE} | grep -e 'http.port[:|=]'`
HTTP_PORT=$(echo ${HTTP_PORT}) # Trim the blanks
PORT=${HTTP_PORT#*http.port=}
if [[ ${PORT} =~ http.port* ]]; then
PORT=${HTTP_PORT#*http.port:}
fi
PORT=$(echo ${PORT}) # Trim the blanks
if [[ "$PROCESS_ON_START" == "false" ]]; then
echo -e "+-------- N O T E o n F O R W A R D E R S ------------------"
echo -e "| You will need to start the forwarders yourself,"
echo -e "| invoke PUT http://${MACHINE_NAME}:${PORT}/mux/mux-process/on to start"
echo -e "| invoke PUT http://${MACHINE_NAME}:${PORT}/mux/mux-process/off to stop"
echo -e "| Or use http://${MACHINE_NAME}:${PORT}/web/runner.html from a "
echo -e "| browser (laptop, cell, tablet...)"
echo -e "+---------------------------------------------------------------"
else
echo -e "+---------------------------------------------------------------"
echo -e "| From a browser, try http://${MACHINE_NAME}:${PORT}/web/index.html"
echo -e "| or http://${MACHINE_NAME}:${PORT}/zip/index.html"
echo -e "+---------------------------------------------------------------"
fi
#
# JAVA_OPTIONS="${JAVA_OPTIONS} -Dserial.data.verbose=false"
# JAVA_OPTIONS="${JAVA_OPTIONS} -Dtcp.data.verbose=false"
# JAVA_OPTIONS="${JAVA_OPTIONS} -Dfile.data.verbose=false"
# JAVA_OPTIONS="${JAVA_OPTIONS} -Dws.data.verbose=true"
JAVA_OPTIONS="${JAVA_OPTIONS} -Drmc.decl.only=true"
# JAVA_OPTIONS="${JAVA_OPTIONS} -Drmc.verbose=true"
# JAVA_OPTIONS="${JAVA_OPTIONS} -Ddo.not.use.GGA.date.time=true"
# JAVA_OPTIONS="${JAVA_OPTIONS} -Dhtu21df.data.verbose=false"
# JAVA_OPTIONS="${JAVA_OPTIONS} -Dbme280.data.verbose=false"
# JAVA_OPTIONS="${JAVA_OPTIONS} -Drnd.data.verbose=false"
# JAVA_OPTIONS="${JAVA_OPTIONS} -Dzda.data.verbose=true"
# JAVA_OPTIONS="${JAVA_OPTIONS} -Dhttp.verbose=true"
# JAVA_OPTIONS="${JAVA_OPTIONS} -Drest.verbose=true"
# JAVA_OPTIONS="${JAVA_OPTIONS} -Dmux.data.verbose=true"
# JAVA_OPTIONS="${JAVA_OPTIONS} -Dmux.infra.verbose=true"
# JAVA_OPTIONS="${JAVA_OPTIONS} -Dverbose=false"
JAVA_OPTIONS="${JAVA_OPTIONS} -Dscreen.verbose=true" # Unit changes for SSD1306 (I2C)
JAVA_OPTIONS="${JAVA_OPTIONS} -Drest.feeder.verbose=true"
JAVA_OPTIONS="${JAVA_OPTIONS} -Dparse.ais=true"
JAVA_OPTIONS="${JAVA_OPTIONS} -Dmux.props.verbose=true"
#
JAVA_OPTIONS="${JAVA_OPTIONS} -Dprocess.on.start=${PROCESS_ON_START}"
#
JAVA_OPTIONS="${JAVA_OPTIONS} -Dmux.properties=${MUX_PROP_FILE}"
JAVA_OPTIONS="${JAVA_OPTIONS} -Dno.ais=false" # Accept AIS Strings
JAVA_OPTIONS="${JAVA_OPTIONS} -Dcalculate.solar.with.eot=true"
#
# To test the AISManager
# JAVA_OPTIONS="${JAVA_OPTIONS} -Ddefault.mux.latitude=47.705 -Ddefault.mux.longitude=-3.105" # Locoal.
# JAVA_OPTIONS="${JAVA_OPTIONS} -Ddefault.mux.latitude=47.661667 -Ddefault.mux.longitude=-2.758167" # Vannes.
# JAVA_OPTIONS="${JAVA_OPTIONS} -Ddefault.mux.latitude=47.677667 -Ddefault.mux.longitude=-3.135667" # Belz.
JAVA_OPTIONS="${JAVA_OPTIONS} -Ddefault.mux.latitude=49.293167 -Ddefault.mux.longitude=-0.098833" # Dives.
# JAVA_OPTIONS="${JAVA_OPTIONS} -Ddefault.mux.latitude=37.7489 -Ddefault.mux.longitude=-122.5070" # SF.
# JAVA_OPTIONS="${JAVA_OPTIONS} -Ddefault.mux.latitude=48.48518833333333 -Ddefault.mux.longitude=-123.07788833333333" # False Bay, San Juan Island
# JAVA_OPTIONS="${JAVA_OPTIONS} -Ddefault.mux.latitude=48.60448 -Ddefault.mux.longitude=-122.819285" # Olga, Orcas Island
# JAVA_OPTIONS="${JAVA_OPTIONS} -Ddefault.mux.latitude=39.167398801021655 -Ddefault.mux.longitude=-107.24753700739706" # Redstone, CO.
JAVA_OPTIONS="${JAVA_OPTIONS} -Dtry.to.speak=true"
#
# JAVA_OPTIONS="$JAVA_OPTONS -Dpi4j.debug -Dpi4j.linking=dynamic"
#
CP=./build/libs/NMEA-multiplexer-basic-1.0-all.jar
SUDO=
if [[ "$OS" == "Darwin" ]]; then
# CP=${CP}:./libs/RXTXcomm.jar # for Mac
CP=${CP}:../Serial.IO/libs/RXTXcomm.jar # for Mac
fi
if [[ "$OS" == "Linux" ]]; then
CP=${CP}:/usr/share/java/RXTXcomm.jar # For Raspberry Pi
SUDO="sudo "
fi
#
# For JFR
JFR_FLAGS=
# JFR_FLAGS="-XX:+UnlockCommercialFeatures -XX:+FlightRecorder -XX:StartFlightRecording=duration=10m,filename=nmea.jfr"
# For remote debugging
REMOTE_DEBUG_FLAGS=
# REMOTE_DEBUG_FLAGS="${REMOTE_DEBUG_FLAGS} -agentlib:jdwp=transport=dt_socket,server=y,suspend=n,address=5005"
#
LOGGING_FLAG=
LOGGING_FLAG=-Djava.util.logging.config.file=./logging.properties
#
# JAVA_OPTIONS="${JAVA_OPTIONS} -Dhttp.proxyHost=www-proxy.us.oracle.com -Dhttp.proxyPort=80 -Dhttps.proxyHost=www-proxy.us.oracle.com -Dhttps.proxyPort=80"
# use sudo on Raspberry Pi, specially if reading serial port(s)
# sudo java ${JAVA_OPTIONS} $LOGGING_FLAG $JFR_FLAGS ${REMOTE_DEBUG_FLAGS} -cp ${CP} nmea.mux.GenericNMEAMultiplexer
COMMAND="${SUDO}java ${JAVA_OPTIONS} ${LOGGING_FLAG} ${JFR_FLAGS} ${REMOTE_DEBUG_FLAGS} -cp ${CP} nmea.mux.GenericNMEAMultiplexer ${CLI_PRMS}"
echo -e "Running ${COMMAND}"
${COMMAND}
#