Hello jonnymo,

Seth here. The book exploringBB has some nice source for C++ workings w/ it 
geared to, on Chapter 6, GPIO and other peripherals. 

Seth

P.S. See 
here: https://github.com/derekmolloy/exploringBB/tree/version2/chp06. 
Although this was from two years ago, I am sure if we work on it, minor 
improvements or some similar changes might be all that is needed. Who knows?

On Tuesday, April 7, 2020 at 5:28:31 PM UTC-5, jonnymo wrote:
>
> Is this what you are referring to?
>
>
> http://derekmolloy.ie/beaglebone/beaglebone-gpio-programming-on-arm-embedded-linux/
>  
>
>  https://github.com/derekmolloy/exploringBB
>
> Jon
>
> On Tue, Apr 7, 2020 at 3:20 PM Mala Dies <[email protected] <javascript:>> 
> wrote:
>
>> 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] <javascript:>.
>> To view this discussion on the web visit 
>> https://groups.google.com/d/msgid/beagleboard/869c0859-6666-452f-9471-65627c6dc9aa%40googlegroups.com
>>  
>> <https://groups.google.com/d/msgid/beagleboard/869c0859-6666-452f-9471-65627c6dc9aa%40googlegroups.com?utm_medium=email&utm_source=footer>
>> .
>>
>
On Tuesday, April 7, 2020 at 5:28:31 PM UTC-5, jonnymo wrote:
>
> Is this what you are referring to?
>
>
> http://derekmolloy.ie/beaglebone/beaglebone-gpio-programming-on-arm-embedded-linux/
>  
>
>  https://github.com/derekmolloy/exploringBB
>
> Jon
>
> On Tue, Apr 7, 2020 at 3:20 PM Mala Dies <[email protected] <javascript:>> 
> wrote:
>
>> 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] <javascript:>.
>> To view this discussion on the web visit 
>> https://groups.google.com/d/msgid/beagleboard/869c0859-6666-452f-9471-65627c6dc9aa%40googlegroups.com
>>  
>> <https://groups.google.com/d/msgid/beagleboard/869c0859-6666-452f-9471-65627c6dc9aa%40googlegroups.com?utm_medium=email&utm_source=footer>
>> .
>>
>

-- 
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/2cf0a7c2-676a-49d5-bd9b-63d71cd8855a%40googlegroups.com.

Reply via email to