gnss-init: disable device state check when timeout is set to 0 (default)

BugzID: 72787
Signed-off-by: Marc Mattmueller <marc.mattmueller@netmodule.com>
This commit is contained in:
Marc Mattmueller 2021-06-07 14:06:18 +02:00
parent 21679f459f
commit b9e18a3a0b
1 changed files with 7 additions and 4 deletions

View File

@ -26,7 +26,7 @@ START_REASON=/sys/kernel/broker/start-reason
GNSS_RST=/sys/class/leds/gnss_rst/brightness
ON_VALUE=0
OFF_VALUE=255
CHECK_TIMEOUT_S=20
CHECK_TIMEOUT_S=0
export RST_STATE="off"
export IS_CHECK=false
@ -45,7 +45,8 @@ function printUsage()
echo -e " -h|--help Show this help"
echo -e ""
echo -e " OPT:"
echo -e " -t|--timeout=TIMEOUT_S Set the check timeout in seconds (default=${CHECK_TIMEOUT_S}s)"
echo -e " -t|--timeout=TIMEOUT_S Set the check timeout in seconds"
echo -e " * 0s = disabled (default)"
echo -e ""
}
@ -53,12 +54,14 @@ function checkDeviceState()
{
if [ $(cat $START_REASON | grep reboot | wc -l) == 1 ]; then
echo "$SCRIPT_NAME: Reboot, no further check necessary"
else
echo "$SCRIPT_NAME: Power cycle detected, checking usb hub (timeout=${CHECK_TIMEOUT_S}s)"
elif [ $CHECK_TIMEOUT_S != 0 ]; then
echo "$SCRIPT_NAME: Power cycle detected, checking for v2x event on 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'
if [ $? == 124 ]; then
echo "$SCRIPT_NAME: timed out - no reset of v2x module detected"
fi
else
echo "$SCRIPT_NAME: Power cycle detected (disabled v2x event check)"
fi
}