Version 6 of piio

Updated 2017-02-05 15:34:14 by sbron

piio by Schelte Bron is a library for accessing a couple of the I/O possibilities of the Raspberry Pi. The library supports both gpio and i2c .

dzach 2016-9-5 Looks interesting. I have compiled the library for a Raspberry Pi 3, but have not been able to produce positive results. What is the naming convention for the pins? There seem to exist a number of them. E.g. if I want to use physical pin 11 (pin number on the connector) as an output, should I say:

    piio function 11 output
    piio output 11 1

in order to turn on pin#11 ?

Could you please post a simple "Hello world" example (e.g. blink)? Thanks!

crshults 2016-10-01 Take a look at the note on this page: http://elinux.org/RPi_GPIO_Code_Samples "Note: For Raspberry Pi 2, change BCM2708_PERI_BASE to 0x3F000000 for the code to work."

dzach Thanks for the link!

sbron 2017-02-05 The library uses the GPIO pin numbering. That way you can also address pins that are not on P1, like P5. It also resolves issues with pins that have changed between hardware revisions, like P1 pin 3 and 5. The image below shows the mapping. So P1 pin 11 is GPIO 17.

http://raspi.tv/wp-content/uploads/2014/07/Raspberry-Pi-GPIO-pinouts-1024x703.png

(Image by RasPi.TV)


A very simple blink example might look like this (LED + resistor connected between P1 pin 39 and 40):

package require piio

piio function 21 output

proc blink {{state 1}} {
    piio output 21 $state
    after 500 [list blink [expr {!$state}]]
}

blink
vwait forever

crshults 2017-02-02 In gpio.c, change "/dev/mem" to "/dev/gpiomem" and you can use the library as a non super user. Your user just has to be in the gpio group.

sbron 2017-02-05 The latest version will use /dev/gpiomem if available, and fall back to /dev/mem if not.