summaryrefslogtreecommitdiff
path: root/test/resettest.sh
diff options
context:
space:
mode:
authorJohn Klug <john.klug@multitech.com>2021-09-03 04:59:39 -0500
committerJohn Klug <john.klug@multitech.com>2021-09-03 05:02:41 -0500
commit1d2d4cb343e6d8b290e801a7dc776f9fb0aa8999 (patch)
treee584dc2b9e399a37817fe2c4dccaa2e645702c1b /test/resettest.sh
parentbc918398a517f618ac102cde2ade494924a85a0c (diff)
downloadmts-io-1d2d4cb343e6d8b290e801a7dc776f9fb0aa8999.tar.gz
mts-io-1d2d4cb343e6d8b290e801a7dc776f9fb0aa8999.tar.bz2
mts-io-1d2d4cb343e6d8b290e801a7dc776f9fb0aa8999.zip
radio reset monitor feature and MTRV1-0.4 hardware4.7.0
Diffstat (limited to 'test/resettest.sh')
-rwxr-xr-xtest/resettest.sh46
1 files changed, 46 insertions, 0 deletions
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