Hi Seth, Exactly that, it's just an option to consider or rule out, for this or a future project. It's pretty open, only limits liability. It can be used in commercial or open source projects, and can be distributed in binary or source form, provided the text below is placed somewhere. As far as I know, it was used in a product, and it was used for an academic paper:
Copyright (c) 2015, Shabaz, VegetableAvenger All rights reserved. Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: * Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. * Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution. * Neither the name of BBBIOlib, iobb, libiobb nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. ________________________________ From: [email protected] <[email protected]> on behalf of Mala Dies <[email protected]> Sent: 09 April 2020 00:03 To: BeagleBoard <[email protected]> Subject: Re: [beagleboard] Re: 4 Relay relay Cape 'c' code Hey Sir, Yep. I will test out this C source soon. I guess you are right. It boils down to what I want. I mean, if you wanted it and I did not, I guess I would be wasting my time using it. W/ that typed out, I would like to use your library. ... Should I put where I got the library in my source if used? Seth P.S. For instance, should I reference each of your names from the github page or can I just put https://github.com/shabaz123/iobb in the source? On Wednesday, April 8, 2020 at 5:54:46 PM UTC-5, shabaz wrote: The Derek Molloy code (at least from the link below from Seth) uses Linux system 'sysfs' to perform the low-level GPIO, so it is far slower than the method I ended up using (which directly maps and modifies the registers). Despite it not being a microcontroller, I still sometimes want that high speed. For instance, I used my library to make an FPGA programmer with the BBB. It runs fast. Also, I already had a BBB book - didn't really fancy buying another book, I don't see the point when I can write a simple-to-use GPIO library and document it as well as a book might. It depends on what's wanted. I prefer (naturally, otherwise I would not have written it : ) my method, primarily for the high speed and Arduino-like simplicity. The disadvantages of this method are that it's not as portable (as evidenced by the time taken to port to BB-AI : ( - due to having to go down to register level, so it is restricted to BBB and PocketBeagle so far. Another disadvantage is that the code is poor, it deserves a re-write from scratch. I'd hoped someone would have written a better library over the years so it would not be needed, but fast-forward five years, in 2019 I still couldn't find a usable fast library, so (for my purposes) I had to ressurect it and re-test it - because of non-backward-compatible changes in the BBB Linux image that had occurred over the years. Having said all that, if all that is needed is to control relays, today I'd also consider to do it with Python, because that's fast enough. No point using a fast library unless you plan to use it for future things that may need the higher speed. Also, nothing wrong perhaps with doing it in a bash script, it's just not something I prefer (I'm not super-familiar with shell scripts, so I do the bare minimum in such scripts). For the past few years I've also used the Pi (with the wiringPi C library, which is also fast and Arduino-like). I built my own relay board for it. I wrote code for it in C (usable with Python of course) to be able to control relays from Python or from bash scripts etc. The only suggestions I have based on that experience, is if you're going to switch multiple relays on or off simultaneously, then it's 'friendlier' electrically to have a few millisecond pause between each. I ended up incorporating that in my code, i.e. for simultaneous control it would automatically stagger by a few milliseconds multiple relays switching on to make it just a perceived simultaneous time. ________________________________ From: [email protected] <[email protected]> on behalf of jonnymo <[email protected]> Sent: 08 April 2020 23:00 To: Beagle Board <[email protected]> Subject: Re: [beagleboard] Re: 4 Relay relay Cape 'c' code Mala, Yeah, I have 3 variations of Molloy's books and I do find them quite nice. His code more up to date than the shabaz code, so I would prefer that. The other option is the AdaFruit BBIO Python code, which I believe Molloy uses. https://learn.adafruit.com/setting-up-io-python-library-on-beaglebone-black/installation-on-ubuntu Regardless, its best to just understand how the underline system is working and how to make calls to the GPIO pins and then go your own route. Jon On Wed, Apr 8, 2020 at 2:42 PM Mala Dies <[email protected]> wrote: 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]> 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]. 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]> 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]. 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<https://groups.google.com/d/msgid/beagleboard/2cf0a7c2-676a-49d5-bd9b-63d71cd8855a%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/CAG99bko%3DnRu9MH3zBS_X4_c_JME9xdgzqRJi%2BP5W70zTD9P6fQ%40mail.gmail.com<https://groups.google.com/d/msgid/beagleboard/CAG99bko%3DnRu9MH3zBS_X4_c_JME9xdgzqRJi%2BP5W70zTD9P6fQ%40mail.gmail.com?utm_medium=email&utm_source=footer>. On Wednesday, April 8, 2020 at 5:54:46 PM UTC-5, shabaz wrote: The Derek Molloy code (at least from the link below from Seth) uses Linux system 'sysfs' to perform the low-level GPIO, so it is far slower than the method I ended up using (which directly maps and modifies the registers). Despite it not being a microcontroller, I still sometimes want that high speed. For instance, I used my library to make an FPGA programmer with the BBB. It runs fast. Also, I already had a BBB book - didn't really fancy buying another book, I don't see the point when I can write a simple-to-use GPIO library and document it as well as a book might. It depends on what's wanted. I prefer (naturally, otherwise I would not have written it : ) my method, primarily for the high speed and Arduino-like simplicity. The disadvantages of this method are that it's not as portable (as evidenced by the time taken to port to BB-AI : ( - due to having to go down to register level, so it is restricted to BBB and PocketBeagle so far. Another disadvantage is that the code is poor, it deserves a re-write from scratch. I'd hoped someone would have written a better library over the years so it would not be needed, but fast-forward five years, in 2019 I still couldn't find a usable fast library, so (for my purposes) I had to ressurect it and re-test it - because of non-backward-compatible changes in the BBB Linux image that had occurred over the years. Having said all that, if all that is needed is to control relays, today I'd also consider to do it with Python, because that's fast enough. No point using a fast library unless you plan to use it for future things that may need the higher speed. Also, nothing wrong perhaps with doing it in a bash script, it's just not something I prefer (I'm not super-familiar with shell scripts, so I do the bare minimum in such scripts). For the past few years I've also used the Pi (with the wiringPi C library, which is also fast and Arduino-like). I built my own relay board for it. I wrote code for it in C (usable with Python of course) to be able to control relays from Python or from bash scripts etc. The only suggestions I have based on that experience, is if you're going to switch multiple relays on or off simultaneously, then it's 'friendlier' electrically to have a few millisecond pause between each. I ended up incorporating that in my code, i.e. for simultaneous control it would automatically stagger by a few milliseconds multiple relays switching on to make it just a perceived simultaneous time. ________________________________ From: [email protected] <[email protected]> on behalf of jonnymo <[email protected]> Sent: 08 April 2020 23:00 To: Beagle Board <[email protected]> Subject: Re: [beagleboard] Re: 4 Relay relay Cape 'c' code Mala, Yeah, I have 3 variations of Molloy's books and I do find them quite nice. His code more up to date than the shabaz code, so I would prefer that. The other option is the AdaFruit BBIO Python code, which I believe Molloy uses. https://learn.adafruit.com/setting-up-io-python-library-on-beaglebone-black/installation-on-ubuntu Regardless, its best to just understand how the underline system is working and how to make calls to the GPIO pins and then go your own route. Jon On Wed, Apr 8, 2020 at 2:42 PM Mala Dies <[email protected]> wrote: 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]> 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]. 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]> 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]. 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<https://groups.google.com/d/msgid/beagleboard/2cf0a7c2-676a-49d5-bd9b-63d71cd8855a%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/CAG99bko%3DnRu9MH3zBS_X4_c_JME9xdgzqRJi%2BP5W70zTD9P6fQ%40mail.gmail.com<https://groups.google.com/d/msgid/beagleboard/CAG99bko%3DnRu9MH3zBS_X4_c_JME9xdgzqRJi%2BP5W70zTD9P6fQ%40mail.gmail.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]<mailto:[email protected]>. To view this discussion on the web visit https://groups.google.com/d/msgid/beagleboard/89b406c9-5817-4c15-8e36-1a908b1ec17c%40googlegroups.com<https://groups.google.com/d/msgid/beagleboard/89b406c9-5817-4c15-8e36-1a908b1ec17c%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/DB6P18901MB0214EFCD1054B639CD6B9EB084C00%40DB6P18901MB0214.EURP189.PROD.OUTLOOK.COM.
