All you did worked for me under Buster on a Pi 3B ...I guess something has changed with Bookworm and/or Raspberry Pi 5.
I believe it's likely "gpiochip4" you need on a Pi 5 rather than "gpiochip0".
No idea why you have to specify "/dev/gpiochipN" or why 'get_line' no longer exists but I guess you are using a later version of 'libgpiod' or its Python bindings. Determine the version and hit Google is all I can suggest.
Update : Worked for me under Bookworm using a Pi 4B, using 'gpiochip0' or '/dev/gpiochip0' -So "no idea" from me. Perhaps you are using some different 'gpiod' than me ? I don't have a Pi 5 to test with.
Code:
Python 3.7.3 (default, Mar 23 2024, 16:12:05)>>> import gpiod>>> chip = gpiod.Chip('gpiochip0')>>> led_line = chip.get_line(0)>>>>>> chip'gpiochip0 /pinctrl-bcm2835/ 54 lines'>>> led_line'gpiochip0:0 /unnamed/'>>> gpiod.version_string()'1.2'
I believe it's likely "gpiochip4" you need on a Pi 5 rather than "gpiochip0".
No idea why you have to specify "/dev/gpiochipN" or why 'get_line' no longer exists but I guess you are using a later version of 'libgpiod' or its Python bindings. Determine the version and hit Google is all I can suggest.
Update : Worked for me under Bookworm using a Pi 4B, using 'gpiochip0' or '/dev/gpiochip0' -
Code:
Python 3.11.2 (main, Mar 13 2023, 12:18:29) [GCC 12.2.0] on linux>>> import gpiod>>> chip = gpiod.Chip('gpiochip0')>>> led_line = chip.get_line(0)>>>>>> chip'gpiochip0 /pinctrl-bcm2711/ 58 lines'>>> led_line'gpiochip0:0 /ID_SDA/'>>> gpiod.version_string()'1.6.3'
Statistics: Posted by hippy — Sat Apr 27, 2024 3:30 pm