From 8487d2fb79e7b9ad592fc2166cef93f11a0d67c3 Mon Sep 17 00:00:00 2001 From: Marc Mattmueller Date: Thu, 3 Jun 2021 13:59:10 +0200 Subject: [PATCH] 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 --- .../gnss-init/files/gnss-init.service | 2 +- recipes-connectivity/gnss-init/files/gnss-reset | 15 +++++++++++---- 2 files changed, 12 insertions(+), 5 deletions(-) diff --git a/recipes-connectivity/gnss-init/files/gnss-init.service b/recipes-connectivity/gnss-init/files/gnss-init.service index a31f2f5..38aa797 100644 --- a/recipes-connectivity/gnss-init/files/gnss-init.service +++ b/recipes-connectivity/gnss-init/files/gnss-init.service @@ -5,7 +5,7 @@ After=usb-hub-reset.service v2x-ieee802.11p.service [Service] 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" RemainAfterExit=yes diff --git a/recipes-connectivity/gnss-init/files/gnss-reset b/recipes-connectivity/gnss-init/files/gnss-reset index 4636f3b..8110de9 100755 --- a/recipes-connectivity/gnss-init/files/gnss-reset +++ b/recipes-connectivity/gnss-init/files/gnss-reset @@ -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=50 +CHECK_TIMEOUT_S=20 export RST_STATE="off" export IS_CHECK=false @@ -36,7 +36,7 @@ export IS_CHECK=false #********************************************************************************************** function printUsage() { - echo -e "\\nUsage: ${SCRIPT_NAME} CMD \\n\\n" + echo -e "\\nUsage: ${SCRIPT_NAME} [OPT] CMD \\n\\n" echo -e " CMD:" echo -e " -c|--check Check start reason and usb-hub message" 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 " -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 "" } function checkDeviceState() @@ -51,7 +54,7 @@ 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" + 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' if [ $? == 124 ]; then echo "$SCRIPT_NAME: timed out - no reset of v2x module detected" @@ -63,7 +66,7 @@ function checkDeviceState() # 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 echo "ERROR: Could not parse $SCRIPT_NAME command line options" exit 1 @@ -76,6 +79,10 @@ while true; do export IS_CHECK=true shift ;; + -t|--timeout) + export CHECK_TIMEOUT_S=${2} + shift 2 + ;; -s|--set) export RST_STATE="${2}" shift 2