From 1d2d4cb343e6d8b290e801a7dc776f9fb0aa8999 Mon Sep 17 00:00:00 2001 From: John Klug Date: Fri, 3 Sep 2021 04:59:39 -0500 Subject: radio reset monitor feature and MTRV1-0.4 hardware --- test/resettest.sh | 46 ++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 46 insertions(+) create mode 100755 test/resettest.sh (limited to 'test') diff --git a/test/resettest.sh b/test/resettest.sh new file mode 100755 index 0000000..b0cb9e1 --- /dev/null +++ b/test/resettest.sh @@ -0,0 +1,46 @@ +#!/bin/bash +# Register for with radio-reset-monitor to +# get a signal when radio-reset occurs. +# Child process exists so the parent +# does not need to worry about resets +# starting before it can get through +# checks, and possibly sleeping forever. +# pgrep was needed to kill the sleep. +# wait is called to wait for the SIGUSR1 signal. +# The child never terminates. +# The hope is that the parent will fall into wait +# before the child registers for the radio-reset. +# checking for do_wait is risky if the kernel ever +# changes. The child will exit if the reset is not +# in process. +# + +USR1=10 +TERM=15 +function sleep_reset +{ + # Wait for parent to enter wait. + trap "kill $!;kill $BASHPID" $TERM + while [[ $(ps -h -o wchan -p $PPID) != do_wait ]] ; do usleep 100 ; done + echo Register parent for SIGUSR1 + echo "$$" "$USR1" >/sys/devices/platform/mts-io/radio-reset-monitor + discovered=$(cat /sys/devices/platform/mts-io/radio-udev-discovery) + if ((discovered == 1)) ; then + # reset is not in progress. + exit 0 + fi + sleep 4294967295 # Hopefully forever + exit 0 +} + +date +trap ":" $USR1 +in_reset=$(cat /sys/devices/platform/mts-io/radio-udev-discovery) +if ((in_reset == 0)) ; then + sleep_reset & + wait $! + # pgrep is needed to find the sleep process + pgrep -P $! | xargs kill +fi +echo Radio Reset is done. +date -- cgit v1.2.3