#!/bin/sh # v0.1 - Joe.Liu @ Feb.28, 2026 # change list # 1. restructure the script # 2. add L9 process support echo Test Gsensor Function Starting ... # define global variables VERSION="v0.1" TESTMACHINENAME="C180" # test bundle name TARGETDISK="/dev/disk0" # target disk TARGETPARTITION="/dev/disk0s3" # target partition #______________________________________ #=== FUNCTIONS ======================== displayInfo() { echo echo "Test Gsensor Function Script $VERSION" echo "Test Machine Name = $TESTMACHINENAME" echo return 0 } displayPass() { echo echo -e "\033[32mGsensor Function pass" echo "===================================================" echo " ***** *** ***** ***** " echo " * * * * * * " echo " ***** ***** ***** ***** " echo " * * * * * " echo " * * * ***** ***** " echo "===================================================" echo -e "\033[0m" return 0 } displayFail() { echo echo -e "\033[31mGsensor Function fail" echo "=========================" echo "***** *** ***** * " echo "* * * * * " echo "**** ***** * * " echo "* * * * * " echo "* * * ***** ****" echo "=========================" echo -e "\033[0m" exit 1 } # find targeted disk for test bundle download checkGensorXAxisValue() { # for diskList in disk0 disk1 disk2 noLower; # do # deviceLocation=`diskutil info $diskList | awk -F\\" '/Device Location:/ {print $2;exit}'` # if [ "$deviceLocation" == "Lower" ]; then # echo "found Lower Device on $diskList." # TARGETDISK=$diskList # break # fi # done xraw=`cat /sys/bus/iio/devices/iio:device0/in_accel_x_raw` SECOND=0 #reset script date while : do if [ $SECONDS -ge 15 ]; then echo "exit on timeout after 3 minutes." return 1 break; fi xraw_new=`cat /sys/bus/iio/devices/iio:device0/in_accel_x_raw` abs_diff=$((xraw_new-xraw)) #if (( $abs_diff > 50 || $abs_diff < -50 )); then if [ $abs_diff -gt 50 ] || [ $abs_diff -lt -50 ]; then echo "gensor work normally! $xraw $xraw_new" break; else echo "the equipment/device is not rotating/turning - $xraw $xraw_new" sleep 1 fi done return 0 } #______________________________________ # HEY, MAIN ROUTINE FROM HERE :-------+ #rm /private/var/vm/swapfile* >& /dev/null # remove swapfile displayInfo || displayFail checkGensorXAxisValue || displayFail displayPass #read -n 1 -p "请按空格键关掉当前窗口......" INP #[ "$INP" != "" ] && echo "\b \n" #shutdown -h now #killall terminal & #______________________________________ # END OF SCRIPT :---------------------+