Semi fix for pwm
[matches/MCTX3420.git] / server / run.sh
index be6d4cf..18af55b 100755 (executable)
@@ -18,10 +18,18 @@ fi
 
 # Identify cape-manager slots
 slot=$(echo /sys/devices/bone_capemgr.*/slots | awk '{print $1}')
 
 # Identify cape-manager slots
 slot=$(echo /sys/devices/bone_capemgr.*/slots | awk '{print $1}')
+pwm=/sys/class/pwm/
 
 # Load PWM module
 
 # Load PWM module
-modprobe pwm_test
+#modprobe pwm_test
 (echo am33xx_pwm > $slot) 1>&2 >> /dev/null
 (echo am33xx_pwm > $slot) 1>&2 >> /dev/null
+#for port in P9_21 P9_22 P9_14 P9_16 P9_29 P9_31 P9_42 P8_13 P8_19 P8_34 P8_36 P8_45 P8_46; do
+#      echo bone_pwm_$port > $slot
+#done
+echo 0 > $pwm/export
+echo 1 > $pwm/export
+echo bone_pwm_P9_21 > $slot
+echo bone_pwm_P9_22 > $slot
 
 # Load ADCs
 (echo cape-bone-iio > $slot) 1>&2 >> /dev/null
 
 # Load ADCs
 (echo cape-bone-iio > $slot) 1>&2 >> /dev/null
@@ -33,4 +41,16 @@ adc_device_path=$(dirname $(find /sys -name *AIN0))
 # Run the program with parameters
 # TODO: Can tell spawn-fcgi to run the program as an unprivelaged user?
 # But first will have to work out how to set PWM/GPIO as unprivelaged user
 # Run the program with parameters
 # TODO: Can tell spawn-fcgi to run the program as an unprivelaged user?
 # But first will have to work out how to set PWM/GPIO as unprivelaged user
-spawn-fcgi -p9005 -n -- ./server -a "$adc_device_path"
+fails=0
+while [ $fails -lt 10 ]; do
+       spawn-fcgi -p9005 -n -- ./server -a "$adc_device_path"
+       if [ "$?" == "0" ]; then
+               exit 0
+       fi
+       fails=$(( $fails + 1 ))
+       (echo "Restarting server after Fatal Error #$fails") 1>&2
+       
+done
+(echo "Server had too many Fatal Errors ($fails)") 1>&2
+exit $fails
+

UCC git Repository :: git.ucc.asn.au