Freek de Kruijf wrote:
I have been struggling with this on a Raspberry Pi 1B and made the Python module for that device called RPi.GPIO. However there is a difference between a RPi1 and other RPi's. RPi1 shows "export gpio321 gpiochip298 unexport" in /sys/class/gpio/, where the start of N is clearly 298. However on a RPi4 /sys/ class/gpio/ shows "export gpiochip446 gpiochip454 unexport". To me the question is: which one of 446 and 454 is the start value?
454 is the correct start value. You get more info running (from libgpiod-utils) Pi4:~ # gpiodetect gpiochip0 [pinctrl-bcm2711] (58 lines) gpiochip1 [raspberrypi-exp-gpio] (8 lines) Pi4:~ # cat /sys/class/gpio/gpiochip454/label pinctrl-bcm2711
On a RPi3 with Raspbian one gets in /sys/class/gpio/ "export gpiochip0 gpiochip100 gpiochip504 unexport", as mentioned earlier the start value is 0.
I got several other replies - not sure why they don't show up here on the list. Upshot is, Raspbian has a downstream patch that changes that number for the 'right' gpiochip to 0 :( I'm now using python3-gpiod. Seems straight forward, given that even I with my absolutely basic python knowledge was able to make the needed changes. import gpiod chip=gpiod.Chip("gpiochip0") fan=chip.get_lines([17]) fan.request(consumer='fancontrol', type=gpiod.LINE_REQ_DIR_OUT) fan.set_values([1]) fan.get_values() fan.release() chip.close() :D