gnss-init: added option to script for setting the check timeout
adapted also the default timeout down to 20s BugzID: 72787 Signed-off-by: Marc Mattmueller <marc.mattmueller@netmodule.com>
This commit is contained in:
parent
c3e5b9af5a
commit
8487d2fb79
|
|
@ -5,7 +5,7 @@ After=usb-hub-reset.service v2x-ieee802.11p.service
|
||||||
[Service]
|
[Service]
|
||||||
Type=oneshot
|
Type=oneshot
|
||||||
|
|
||||||
ExecStartPre=/usr/bin/sh -c "/usr/bin/gnss-reset -c"
|
ExecStartPre=/usr/bin/sh -c "/usr/bin/gnss-reset -c -t 20"
|
||||||
ExecStart=/usr/bin/sh -c "/usr/bin/gnss-reset -s on"
|
ExecStart=/usr/bin/sh -c "/usr/bin/gnss-reset -s on"
|
||||||
|
|
||||||
RemainAfterExit=yes
|
RemainAfterExit=yes
|
||||||
|
|
|
||||||
|
|
@ -26,7 +26,7 @@ START_REASON=/sys/kernel/broker/start-reason
|
||||||
GNSS_RST=/sys/class/leds/gnss_rst/brightness
|
GNSS_RST=/sys/class/leds/gnss_rst/brightness
|
||||||
ON_VALUE=0
|
ON_VALUE=0
|
||||||
OFF_VALUE=255
|
OFF_VALUE=255
|
||||||
CHECK_TIMEOUT_S=50
|
CHECK_TIMEOUT_S=20
|
||||||
|
|
||||||
export RST_STATE="off"
|
export RST_STATE="off"
|
||||||
export IS_CHECK=false
|
export IS_CHECK=false
|
||||||
|
|
@ -36,7 +36,7 @@ export IS_CHECK=false
|
||||||
#**********************************************************************************************
|
#**********************************************************************************************
|
||||||
function printUsage()
|
function printUsage()
|
||||||
{
|
{
|
||||||
echo -e "\\nUsage: ${SCRIPT_NAME} CMD \\n\\n"
|
echo -e "\\nUsage: ${SCRIPT_NAME} [OPT] CMD \\n\\n"
|
||||||
echo -e " CMD:"
|
echo -e " CMD:"
|
||||||
echo -e " -c|--check Check start reason and usb-hub message"
|
echo -e " -c|--check Check start reason and usb-hub message"
|
||||||
echo -e " -s|--set=STATE Set the requested STATE of the gnss module:"
|
echo -e " -s|--set=STATE Set the requested STATE of the gnss module:"
|
||||||
|
|
@ -44,6 +44,9 @@ function printUsage()
|
||||||
echo -e " * off = set module in reset mode (default)"
|
echo -e " * off = set module in reset mode (default)"
|
||||||
echo -e " -h|--help Show this help"
|
echo -e " -h|--help Show this help"
|
||||||
echo -e ""
|
echo -e ""
|
||||||
|
echo -e " OPT:"
|
||||||
|
echo -e " -t|--timeout=TIMEOUT_S Set the check timeout in seconds (default=${CHECK_TIMEOUT_S}s)"
|
||||||
|
echo -e ""
|
||||||
}
|
}
|
||||||
|
|
||||||
function checkDeviceState()
|
function checkDeviceState()
|
||||||
|
|
@ -51,7 +54,7 @@ function checkDeviceState()
|
||||||
if [ $(cat $START_REASON | grep reboot | wc -l) == 1 ]; then
|
if [ $(cat $START_REASON | grep reboot | wc -l) == 1 ]; then
|
||||||
echo "$SCRIPT_NAME: Reboot, no further check necessary"
|
echo "$SCRIPT_NAME: Reboot, no further check necessary"
|
||||||
else
|
else
|
||||||
echo "$SCRIPT_NAME: Power cycle detected, checking usb hub"
|
echo "$SCRIPT_NAME: Power cycle detected, checking usb hub (timeout=${CHECK_TIMEOUT_S}s)"
|
||||||
timeout $CHECK_TIMEOUT_S bash -c -- 'while true; do dmesg | grep "usb 1-1.*USB disconnect"; if [ $? == 0 ]; then break; fi; done'
|
timeout $CHECK_TIMEOUT_S bash -c -- 'while true; do dmesg | grep "usb 1-1.*USB disconnect"; if [ $? == 0 ]; then break; fi; done'
|
||||||
if [ $? == 124 ]; then
|
if [ $? == 124 ]; then
|
||||||
echo "$SCRIPT_NAME: timed out - no reset of v2x module detected"
|
echo "$SCRIPT_NAME: timed out - no reset of v2x module detected"
|
||||||
|
|
@ -63,7 +66,7 @@ function checkDeviceState()
|
||||||
# main
|
# main
|
||||||
#**********************************************************************************************
|
#**********************************************************************************************
|
||||||
|
|
||||||
O=$(getopt -o hcs: --long help,check,set: -- "$@") || exit 1
|
O=$(getopt -o hct:s: --long help,check,timeout:,set: -- "$@") || exit 1
|
||||||
if [ $? != 0 ]; then
|
if [ $? != 0 ]; then
|
||||||
echo "ERROR: Could not parse $SCRIPT_NAME command line options"
|
echo "ERROR: Could not parse $SCRIPT_NAME command line options"
|
||||||
exit 1
|
exit 1
|
||||||
|
|
@ -76,6 +79,10 @@ while true; do
|
||||||
export IS_CHECK=true
|
export IS_CHECK=true
|
||||||
shift
|
shift
|
||||||
;;
|
;;
|
||||||
|
-t|--timeout)
|
||||||
|
export CHECK_TIMEOUT_S=${2}
|
||||||
|
shift 2
|
||||||
|
;;
|
||||||
-s|--set)
|
-s|--set)
|
||||||
export RST_STATE="${2}"
|
export RST_STATE="${2}"
|
||||||
shift 2
|
shift 2
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue