#
# beaglegsm.sh - SHell script to run beaglegsm.tcl from
# cron job.
#
# This script is meant to run 'tclsh beaglegsm.tcl' on a Beaglebone
# board, using an Option Icon 322 USB modem, connected to a UAB port with
# a special cable and circuit that allows a program to disconnect and reconnect the modem
# using the Beaglebone GPIO bit on pin 3 of the P8 expansion connector to disconnect and
# reconnect +5V USB power to the modem via the USB cable. The GPIO bit is named gpio1_6
# in the P8 connector pinout table in the Beaglebone System Reference Manual (A5).
#
# The need to disconnect and reconnect is due to some obscure bug that ocassionally
# makes the modem time-out during operations in the TCL script beaglegsm.tcl. It seems
# that the disconnect/reconnect is needed to reset the modem.
# We assume the gpio pin multiplexer is set up for pin 3 of P8
# to be a gpio bit (mode 7). This state seems to be maintained after power-down
# and rebooting.
#
# Check this using:
#
# root@beaglebone:~/work# cat /sys/kernel/debug/omap_mux/gpmc_ad6
# name: gpmc_ad6.gpio1_6 (0x44e10818/0x818 = 0x0037), b NA, t NA
# mode: OMAP_PIN_OUTPUT | OMAP_MUX_MODE7
# signals: gpmc_ad6 | mmc1_dat6 | NA | NA | NA | NA | NA | gpio1_6
# Export bit and set direction to out.
function setupgpio {
# Export gpio1_6 so we can manipulate it
# (38 = 1 * 32 + 6)
echo 38 > /sys/class/gpio/export
echo out >/sys/class/gpio/gpio38/direction
}
# Set gpio1_6 so that USB cuts power to modem
function cut_usbpower {
echo 1 >/sys/class/gpio/gpio38/value
}
# Set gpio1_6 so that USB supplies power to the modem.
function apply_usbpower {
echo 0 >/sys/class/gpio/gpio38/value
}
cd /home/root/tcl-from-beaglebone/tcl/
setupgpio
apply_usbpower
sleep 15
while [ true ]; do
echo "(`date`) Running beaglegsm.tcl"
tclsh beaglegsm.tcl &>beaglegsm-tclsh.out
echo "Beaglegsm.tcl exited. Resetting modem and restarting"
cut_usbpower
sleep 20
apply_usbpower
sleep 30
done
No comments:
Post a Comment