2019-10-09 19:22:36 -06:00
|
|
|
#!/bin/bash
|
2019-11-21 13:51:18 -07:00
|
|
|
runDir="/run/ubxtool"
|
2019-10-09 19:22:36 -06:00
|
|
|
|
2019-11-21 13:51:18 -07:00
|
|
|
CONSTELLATIONS="--galileo --gps --glonass"
|
|
|
|
# CONSTELLATIONS="--galileo --gps --beidou"
|
|
|
|
# CONSTELLATIONS="--galileo --gps --glonass --beidou" # only on the F9P
|
2019-10-09 19:22:36 -06:00
|
|
|
|
2020-01-18 07:00:50 -07:00
|
|
|
if [ -e /usr/local/ubxtool/constellations ]
|
|
|
|
then
|
|
|
|
CONSTELLATIONS=$(cat /usr/local/ubxtool/constellations)
|
|
|
|
fi
|
|
|
|
|
2019-11-21 13:51:18 -07:00
|
|
|
# DEVICE="/dev/ttyACM0" # comment out or leave blank to auto-search
|
2019-10-09 19:22:36 -06:00
|
|
|
|
2019-11-21 13:51:18 -07:00
|
|
|
#########################################################################
|
|
|
|
rotate() {
|
|
|
|
logt=$1
|
|
|
|
cd ${runDir}
|
|
|
|
if [ -r ${logt}.log ]; # only rotate if there's a current logfile
|
|
|
|
then
|
|
|
|
if [ -r ${logt}.log.4 ]; then mv ${logt}.log.4 ${logt}.log.5 ; fi;
|
|
|
|
if [ -r ${logt}.log.3 ]; then mv ${logt}.log.3 ${logt}.log.4 ; fi;
|
|
|
|
if [ -r ${logt}.log.2 ]; then mv ${logt}.log.2 ${logt}.log.3 ; fi;
|
|
|
|
if [ -r ${logt}.log.1 ]; then mv ${logt}.log.1 ${logt}.log.2 ; fi;
|
|
|
|
if [ -r ${logt}.log ]; then mv ${logt}.log ${logt}.log.1 ; fi;
|
|
|
|
fi
|
|
|
|
}
|
2019-10-09 19:22:36 -06:00
|
|
|
|
2019-11-21 13:51:18 -07:00
|
|
|
if [ -z "${DEVICE}" ];
|
|
|
|
then
|
|
|
|
# programmatically find the interface
|
|
|
|
SYSD=$(grep -il u-blox /sys/bus/usb/devices/*/manufacturer)
|
|
|
|
SYSD=${SYSD//manufacturer/}
|
|
|
|
DEVD=$(find ${SYSD} -type d -iname 'ttyACM*')
|
|
|
|
DEVICE="/dev/${DEVD##*/}"
|
|
|
|
fi
|
2019-10-09 19:22:36 -06:00
|
|
|
|
2019-11-21 13:51:18 -07:00
|
|
|
DESTINATION=$(cat /usr/local/ubxtool/destination)
|
|
|
|
STATION=$(cat /usr/local/ubxtool/station)
|
|
|
|
|
2020-01-18 07:00:50 -07:00
|
|
|
|
2019-11-21 13:51:18 -07:00
|
|
|
# systemctl script will do this, but if you don't use systemctl, we need to take care of it
|
|
|
|
[[ -d ${runDir} ]] || mkdir -p ${runDir}
|
|
|
|
|
|
|
|
for logFile in stdout stderr logfile
|
|
|
|
do
|
|
|
|
rotate ${logFile}
|
|
|
|
done
|
|
|
|
|
|
|
|
|
2020-01-18 07:00:50 -07:00
|
|
|
exec /usr/local/ubxtool/ubxtool ${CONSTELLATIONS} --port ${DEVICE} --station ${STATION} --destination ${DESTINATION} >> ${runDir}/stdout.log 2>> ${runDir}/stderr.log < /dev/null
|