RickR Posted November 2, 2018 Posted November 2, 2018 Hello, I have installed ARMBIAN 5.60 stable Debian GNU/Linux 9 (stretch) 4.14.70-sunxi on a Banana Pi M2+ and I need to read and write to the GPIO pins from a bash script, does anyone have a workable solution? I tried with an Orange Pi in the past and I compiled a binary to access the gpio values but it did not work and I cannot find that source any more. Thanks in advance. 0 Quote
martinayotte Posted November 2, 2018 Posted November 2, 2018 12 hours ago, RickR said: I need to read and write to the GPIO pins from a bash script The simplest way is to use gpio sysfs ... echo 20 > /sys/class/gpio/export echo out > /sys/class/gpio/gpio20/direction echo 1 > /sys/class/gpio/gpio20/value 1 Quote
RickR Posted November 4, 2018 Author Posted November 4, 2018 On 11/2/2018 at 11:43 PM, martinayotte said: The simplest way is to use gpio sysfs ... echo 20 > /sys/class/gpio/export echo out > /sys/class/gpio/gpio20/direction echo 1 > /sys/class/gpio/gpio20/value Thank you Martinayotte, I have had limited success with this approach and it requires superuser privileges which makes it a bit risky for me to call from the web server, but then I may be able to work out a secure way to access that interface. The "gpio" command from the WiringOP github repo seems to be very promising as well. Thank you Martinayotte, that is very helpful. The difficulty I found is that it required superuser permissions and I managed to get the gpio utility compiled and finally working late last night and it does not require superuser permissions 0 Quote
Levent Erenler Posted September 12, 2020 Posted September 12, 2020 On 11/2/2018 at 8:43 AM, martinayotte said: The simplest way is to use gpio sysfs ... echo 20 > /sys/class/gpio/export echo out > /sys/class/gpio/gpio20/direction echo 1 > /sys/class/gpio/gpio20/value Hi,I am a developing a c++ application with OPI 0+2 (h5 + mainline kernel), controls a motor with an encoder and a driver. I did it , but it consume to much cpu power (%8) . I could access with using sysfs and character device. Both of them works like open->read->close .Actually it works very well with polling. Unfortunately consume to much cpu. Interrupt freq around 6600hz (150 us) . Is there anyway to control interrupt with dev mem? Or could anyone give me a startup point to access (c++) gpio interrupts efficiently. Btw i tyied libgpiod based on character device. Thank you. 0 Quote
Tido Posted September 12, 2020 Posted September 12, 2020 1 hour ago, Levent Erenler said: Or could anyone give me a startup point to access (c++) gpio interrupts efficiently. ArmbianIO API - in C https://forum.armbian.com/topic/5655-armbianio-api-proposal/ User Space IO - is Python 3 and Java 8 bindings for user space GPIO, SPI, I2C, PWM and Serial interfaces https://forum.armbian.com/topic/6523-user-space-io-is-python-3-and-java-8-bindings-for-user-space-gpio-spi-i2c-pwm-and-serial-interfaces/ and his improvement: https://github.com/sgjava/java-periphery pyGPIO - A 'more general' python GPIO library based on pyA20 https://forum.armbian.com/topic/5662-pygpio-a-more-general-python-gpio-library 0 Quote
Levent Erenler Posted September 12, 2020 Posted September 12, 2020 1 hour ago, Tido said: ArmbianIO API - in C https://forum.armbian.com/topic/5655-armbianio-api-proposal/ pyGPIO - A 'more general' python GPIO library based on pyA20 https://forum.armbian.com/topic/5662-pygpio-a-more-general-python-gpio-library Thanks for your answer, i checked ArmbianIO, it is based on sysfs. pyGPIO is based on dev/mem, this is what i am looking unfortunatelly it does not support interrupts. I could not find a way to get gpio int from memory. thank you. 0 Quote
Kovács Gábor Posted November 11, 2022 Posted November 11, 2022 Hello RickR, Could you pplease share how you managed to compile it? With sources and some basic instructions? Thanks, Gabor 0 Quote
RickR Posted November 11, 2022 Author Posted November 11, 2022 Hello Gabor, Sorry, I do not have a valid Banana Pi platform to test this again as this project was done many years ago. If I do get a chance to test the compilation once again I shall send you the details. Best of luck, Rick 0 Quote
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.