O'Reilly logo

GNU/Linux Rapid Embedded Programming by Rodolfo Giometti

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Using GPIOs with scripting languages

Having the possibility to manage the GPIO lines in a scripting language in an easy manner allows us to have a powerful tool to speed up simple tasks involving these peripherals. That's why in this section, we're going to see how the GPIO lines can be managed in both PHP and Python scripting languages in a manner similar to what we did in C.

However, in order to keep the code simple, we suppose that the GPIO lines gpio24 and gpio91 have been exported in some way already. For example, we can properly set them up with the following well-known commands:

root@wb:~# echo 24 > /sys/class/gpio/export
root@wb:~# echo in > /sys/class/gpio/gpio24/direction
root@wb:~# echo falling > /sys/class/gpio/gpio24/edge
root@wb:~# ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required