Hello KenUnix,

Seth here. Do you want me to still work on the C++ code or are you 
satisfied w/ the shell script you are working on currently?

Seth

P.S. I found my book, ideas, and everything is on chapter six w/ source 
already done for specific ideas. I would probably need to change some 
source, too. Let a brother know. 

On Tuesday, April 7, 2020 at 11:39:56 AM UTC-5, KenUnix wrote:
>
> Robert,
>
> You were correct high level is better for now. It's been a long while 
> since working
> with 'c'.  Went the way of a bash script. Works well see below. Even 
> supports --help.
>
> ---Code Start--
> #!/bin/bash
> #
> # 4-7-2020 Ken
> #
> # cmd [state|label|on|off|in|out] gpio #
> # Example : cmd state 112
> #
> if [ "$1" == "--help" ]
>    then
>     echo -e "\ngpio relay cape tool. 4-7-2020 KenUnix\n"
>     echo "state  Get state of gpio number"
>     echo "label  Display associated P number"
>     echo "on     Set relay # to on"
>     echo "off    Turn relay off"
>     echo -e "out    Set gpio to out\n"
>     echo "Example: cmd status 115 Will display the state of gpio 115"
>     echo -e "         cmd on 20      Will turn relay 1 on for gpio 20\n"
>     exit
> fi
>
> case $2 in
>     20|7|112|115) ;;
>     *) echo "Invalid gpio $2"
>        echo "Vaild numbers are 20, 7, 112 or 115"
>            echo -e "Relay 1 20, relay 2 7, relay 3 112, relay 4 115\007"
>        exit 1 ;;
> esac
>
> case $1 in
>    "state")
>       direction=`cat /sys/class/gpio/gpio$2/direction`
>       echo -n "Direction $direction, State "
>       state=`cat /sys/class/gpio/gpio$2/value`
>       if [ "$state" == "0" ]; then echo "off"; fi
>       if [ "$state" == "1" ]; then echo "on"; fi
>       exit ;;
>    "label")
>       echo -n "Physical header pin number "
>       cat /sys/class/gpio/gpio$2/label ;
>       exit ;;
>    "on")
>       echo 1 >/sys/class/gpio/gpio$2/value
>       exit ;;
>    "off")
>       echo 0 >/sys/class/gpio/gpio$2/value
>       exit ;;
>    "out")
>       echo "out" > /sys/class/gpio/gpio$2/direction ;
>       exit ;;
>    "in")
>       echo "in" > /sys/class/gpio/gpio$2/direction ;
>       exit ;;
>    *) echo -e "Invalid operation $1. Try cmd --help\007" ; exit 1 ;;
> esac
> --Code End--
>
> Maybe someone else may find this useful.
>
> Ken
>
>
On Tuesday, April 7, 2020 at 11:39:56 AM UTC-5, KenUnix wrote:
>
> Robert,
>
> You were correct high level is better for now. It's been a long while 
> since working
> with 'c'.  Went the way of a bash script. Works well see below. Even 
> supports --help.
>
> ---Code Start--
> #!/bin/bash
> #
> # 4-7-2020 Ken
> #
> # cmd [state|label|on|off|in|out] gpio #
> # Example : cmd state 112
> #
> if [ "$1" == "--help" ]
>    then
>     echo -e "\ngpio relay cape tool. 4-7-2020 KenUnix\n"
>     echo "state  Get state of gpio number"
>     echo "label  Display associated P number"
>     echo "on     Set relay # to on"
>     echo "off    Turn relay off"
>     echo -e "out    Set gpio to out\n"
>     echo "Example: cmd status 115 Will display the state of gpio 115"
>     echo -e "         cmd on 20      Will turn relay 1 on for gpio 20\n"
>     exit
> fi
>
> case $2 in
>     20|7|112|115) ;;
>     *) echo "Invalid gpio $2"
>        echo "Vaild numbers are 20, 7, 112 or 115"
>            echo -e "Relay 1 20, relay 2 7, relay 3 112, relay 4 115\007"
>        exit 1 ;;
> esac
>
> case $1 in
>    "state")
>       direction=`cat /sys/class/gpio/gpio$2/direction`
>       echo -n "Direction $direction, State "
>       state=`cat /sys/class/gpio/gpio$2/value`
>       if [ "$state" == "0" ]; then echo "off"; fi
>       if [ "$state" == "1" ]; then echo "on"; fi
>       exit ;;
>    "label")
>       echo -n "Physical header pin number "
>       cat /sys/class/gpio/gpio$2/label ;
>       exit ;;
>    "on")
>       echo 1 >/sys/class/gpio/gpio$2/value
>       exit ;;
>    "off")
>       echo 0 >/sys/class/gpio/gpio$2/value
>       exit ;;
>    "out")
>       echo "out" > /sys/class/gpio/gpio$2/direction ;
>       exit ;;
>    "in")
>       echo "in" > /sys/class/gpio/gpio$2/direction ;
>       exit ;;
>    *) echo -e "Invalid operation $1. Try cmd --help\007" ; exit 1 ;;
> esac
> --Code End--
>
> Maybe someone else may find this useful.
>
> Ken
>
>

-- 
For more options, visit http://beagleboard.org/discuss
--- 
You received this message because you are subscribed to the Google Groups 
"BeagleBoard" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/beagleboard/869c0859-6666-452f-9471-65627c6dc9aa%40googlegroups.com.

Reply via email to