• Has gpio changed completely betwen bookworm and trixie?

    From Chris Green@cl@isbd.net to comp.sys.raspberry-pi on Thu Aug 28 15:24:26 2025
    From Newsgroup: comp.sys.raspberry-pi

    I have upgraded my Pi 4B from bookworm to trixie and, while most
    things work fine, my gpiod code in Python is completely broken. Can
    anyone confirm that everything has changed a lot or am I going mad?
    --
    Chris Green
    -+
    --- Synchronet 3.21a-Linux NewsLink 1.2
  • From John R Walliker@jrwalliker@gmail.com to comp.sys.raspberry-pi on Thu Aug 28 16:15:24 2025
    From Newsgroup: comp.sys.raspberry-pi

    On 28/08/2025 15:24, Chris Green wrote:
    I have upgraded my Pi 4B from bookworm to trixie and, while most
    things work fine, my gpiod code in Python is completely broken. Can
    anyone confirm that everything has changed a lot or am I going mad?

    You are not going mad. Here are before and after examples from
    a shell script that I had to change. It reads a PIO pin and puts
    a message in a log file if a PIR detector has been triggered.
    There will be some equivalent change in Python.
    John

    BEFORE

    #!/bin/bash

    echo "9" > /sys/class/gpio/export
    echo "in" > /sys/class/gpio/gpio9/direction

    while true;
    do

    temp=$(</sys/class/gpio/gpio9/value)
    if [[ $temp -eq 1 ]];
    then
    echo -n "Ceiling "; date; echo
    fi

    sleep 2

    done

    echo "9" > /sys/class/gpio/unexport


    AFTER

    #!/bin/bash

    while true

    do

    temp=$(pinctrl lev 9)
    if [[ $temp -eq 1 ]];
    then
    echo -n "Ceiling "; date; echo
    fi

    sleep 2

    done

    --- Synchronet 3.21a-Linux NewsLink 1.2
  • From scott@scott@alfter.diespammersdie.us (Scott Alfter) to comp.sys.raspberry-pi on Thu Aug 28 16:34:38 2025
    From Newsgroup: comp.sys.raspberry-pi

    In article <qd56ol-6mhl.ln1@q957.zbmc.eu>, Chris Green <cl@isbd.net> wrote:
    I have upgraded my Pi 4B from bookworm to trixie and, while most
    things work fine, my gpiod code in Python is completely broken. Can
    anyone confirm that everything has changed a lot or am I going mad?

    I noticed that when I tried updating a RPi 4 + Geekworm X728 system
    yesterday. The scripts that talk to the X728 (using rpi-lgpio instead of rpi-gpio) were completely broken. I'm trying to rework them to use
    gpiozero, hoping that it might be a better-supported system for the long
    term.
    --
    _/_
    / v \ Scott Alfter (remove the obvious to send mail)
    (IIGS( https://alfter.us/ Top-posting!
    \_^_/ >What's the most annoying thing on Usenet? --- Synchronet 3.21a-Linux NewsLink 1.2
  • From The Natural Philosopher@tnp@invalid.invalid to comp.sys.raspberry-pi on Thu Aug 28 17:41:15 2025
    From Newsgroup: comp.sys.raspberry-pi

    On 28/08/2025 17:34, Scott Alfter wrote:
    In article <qd56ol-6mhl.ln1@q957.zbmc.eu>, Chris Green <cl@isbd.net> wrote:
    I have upgraded my Pi 4B from bookworm to trixie and, while most
    things work fine, my gpiod code in Python is completely broken. Can
    anyone confirm that everything has changed a lot or am I going mad?

    I noticed that when I tried updating a RPi 4 + Geekworm X728 system yesterday. The scripts that talk to the X728 (using rpi-lgpio instead of rpi-gpio) were completely broken. I'm trying to rework them to use
    gpiozero, hoping that it might be a better-supported system for the long term.

    It's probably some rearrangement of the /sys hierarchy.

    At some level the C library gpio functions should still work...
    --
    For in reason, all government without the consent of the governed is the
    very definition of slavery.

    Jonathan Swift


    --- Synchronet 3.21a-Linux NewsLink 1.2
  • From Chris Green@cl@isbd.net to comp.sys.raspberry-pi on Thu Aug 28 19:05:55 2025
    From Newsgroup: comp.sys.raspberry-pi

    The Natural Philosopher <tnp@invalid.invalid> wrote:
    On 28/08/2025 17:34, Scott Alfter wrote:
    In article <qd56ol-6mhl.ln1@q957.zbmc.eu>, Chris Green <cl@isbd.net> wrote:
    I have upgraded my Pi 4B from bookworm to trixie and, while most
    things work fine, my gpiod code in Python is completely broken. Can
    anyone confirm that everything has changed a lot or am I going mad?

    I noticed that when I tried updating a RPi 4 + Geekworm X728 system yesterday. The scripts that talk to the X728 (using rpi-lgpio instead of rpi-gpio) were completely broken. I'm trying to rework them to use gpiozero, hoping that it might be a better-supported system for the long term.

    It's probably some rearrangement of the /sys hierarchy.

    At some level the C library gpio functions should still work...

    OP here, yes, I'm not going mad. There are major changes between the
    i.6.x and 2.x versions of python3-libgpiod. The trouble is that
    finding out about it all is very difficult because there are so many
    different python wrappers for gpiod and this makes searching very
    frustrating.

    The best I've found so far is the 'source':-
    https://github.com/brgl/libgpiod/blob/master/bindings/python/README.md

    It has some Python examples but the coding style is very odd and makes
    it difficult to follow what's going on IMHO.
    --
    Chris Green
    -+
    --- Synchronet 3.21a-Linux NewsLink 1.2
  • From The Natural Philosopher@tnp@invalid.invalid to comp.sys.raspberry-pi on Fri Aug 29 10:47:18 2025
    From Newsgroup: comp.sys.raspberry-pi

    On 28/08/2025 19:05, Chris Green wrote:
    The Natural Philosopher <tnp@invalid.invalid> wrote:
    On 28/08/2025 17:34, Scott Alfter wrote:
    In article <qd56ol-6mhl.ln1@q957.zbmc.eu>, Chris Green <cl@isbd.net> wrote:
    I have upgraded my Pi 4B from bookworm to trixie and, while most
    things work fine, my gpiod code in Python is completely broken. Can
    anyone confirm that everything has changed a lot or am I going mad?

    I noticed that when I tried updating a RPi 4 + Geekworm X728 system
    yesterday. The scripts that talk to the X728 (using rpi-lgpio instead of >>> rpi-gpio) were completely broken. I'm trying to rework them to use
    gpiozero, hoping that it might be a better-supported system for the long >>> term.

    It's probably some rearrangement of the /sys hierarchy.

    At some level the C library gpio functions should still work...

    OP here, yes, I'm not going mad. There are major changes between the
    i.6.x and 2.x versions of python3-libgpiod. The trouble is that
    finding out about it all is very difficult because there are so many different python wrappers for gpiod and this makes searching very frustrating.

    The best I've found so far is the 'source':-
    https://github.com/brgl/libgpiod/blob/master/bindings/python/README.md

    It has some Python examples but the coding style is very odd and makes
    it difficult to follow what's going on IMHO.

    Can't help. I never use python.
    --
    WOKE is an acronym... Without Originality, Knowledge or Education.

    --- Synchronet 3.21a-Linux NewsLink 1.2
  • From scott@scott@alfter.diespammersdie.us (Scott Alfter) to comp.sys.raspberry-pi on Fri Aug 29 18:25:16 2025
    From Newsgroup: comp.sys.raspberry-pi

    In article <108q0rb$1fmpt$6@dont-email.me>,
    The Natural Philosopher <tnp@invalid.invalid> wrote:
    On 28/08/2025 17:34, Scott Alfter wrote:
    In article <qd56ol-6mhl.ln1@q957.zbmc.eu>, Chris Green <cl@isbd.net> wrote: >>> I have upgraded my Pi 4B from bookworm to trixie and, while most
    things work fine, my gpiod code in Python is completely broken. Can
    anyone confirm that everything has changed a lot or am I going mad?

    I noticed that when I tried updating a RPi 4 + Geekworm X728 system
    yesterday. The scripts that talk to the X728 (using rpi-lgpio instead of
    rpi-gpio) were completely broken. I'm trying to rework them to use
    gpiozero, hoping that it might be a better-supported system for the long
    term.

    It's probably some rearrangement of the /sys hierarchy.

    One thing I forgot to mention: the system in question was running Armbian.
    I'm trying again under Raspbian to see if that makes a difference.

    Before blowing Armbian off the board, I was tinkering around with gpiod
    instead of gpiozero. I tweaked a gpiod example and got the buzzer on the
    X728 to sound off, but it looks like porting to gpiod would be much more difficult than porting to gpiozero.
    --
    _/_
    / v \ Scott Alfter (remove the obvious to send mail)
    (IIGS( https://alfter.us/ Top-posting!
    \_^_/ >What's the most annoying thing on Usenet? --- Synchronet 3.21a-Linux NewsLink 1.2
  • From Lawrence =?iso-8859-13?q?D=FFOliveiro?=@ldo@nz.invalid to comp.sys.raspberry-pi on Sat Aug 30 00:23:46 2025
    From Newsgroup: comp.sys.raspberry-pi

    On Thu, 28 Aug 2025 19:05:55 +0100, Chris Green wrote:

    The best I've found so far is the 'source':-
    https://github.com/brgl/libgpiod/blob/master/bindings/python/README.md

    It has some Python examples but the coding style is very odd and
    makes it difficult to follow what's going on IMHO.

    I had a look at one or two examples, but they didnrCOt look very rCLoddrCY
    to me. Any particular ones you are having trouble with?
    --- Synchronet 3.21a-Linux NewsLink 1.2
  • From Chris Green@cl@isbd.net to comp.sys.raspberry-pi on Sat Aug 30 09:02:46 2025
    From Newsgroup: comp.sys.raspberry-pi

    Lawrence DrCOOliveiro <ldo@nz.invalid> wrote:
    On Thu, 28 Aug 2025 19:05:55 +0100, Chris Green wrote:

    The best I've found so far is the 'source':-
    https://github.com/brgl/libgpiod/blob/master/bindings/python/README.md

    It has some Python examples but the coding style is very odd and
    makes it difficult to follow what's going on IMHO.

    I had a look at one or two examples, but they didnrCOt look very rCLoddrCY
    to me. Any particular ones you are having trouble with?

    I worked it all out OK, I do write quite a lot of Python code. My
    comment was rather that the style using 'with' and so on which makes
    it rather diffcult to actually follow the sequence of calls required
    to do simple things like 'set this line high' or 'read the state of
    that line'.
    --
    Chris Green
    -+
    --- Synchronet 3.21a-Linux NewsLink 1.2
  • From The Natural Philosopher@tnp@invalid.invalid to comp.sys.raspberry-pi on Sat Aug 30 09:11:44 2025
    From Newsgroup: comp.sys.raspberry-pi

    On 30/08/2025 09:02, Chris Green wrote:
    Lawrence DrCOOliveiro <ldo@nz.invalid> wrote:
    On Thu, 28 Aug 2025 19:05:55 +0100, Chris Green wrote:

    The best I've found so far is the 'source':-
    https://github.com/brgl/libgpiod/blob/master/bindings/python/README.md >>>
    It has some Python examples but the coding style is very odd and
    makes it difficult to follow what's going on IMHO.

    I had a look at one or two examples, but they didnrCOt look very rCLoddrCY >> to me. Any particular ones you are having trouble with?

    I worked it all out OK, I do write quite a lot of Python code. My
    comment was rather that the style using 'with' and so on which makes
    it rather diffcult to actually follow the sequence of calls required
    to do simple things like 'set this line high' or 'read the state of
    that line'.

    Ah. Written by a computer scientist rather than a software engineer.
    Designed to impress, not to elucidate...
    --
    rCLSome people like to travel by train because it combines the slowness of
    a car with the cramped public exposure of rC?an airplane.rCY

    Dennis Miller


    --- Synchronet 3.21a-Linux NewsLink 1.2
  • From Lawrence =?iso-8859-13?q?D=FFOliveiro?=@ldo@nz.invalid to comp.sys.raspberry-pi on Sat Aug 30 09:13:15 2025
    From Newsgroup: comp.sys.raspberry-pi

    On Sat, 30 Aug 2025 09:02:46 +0100, Chris Green wrote:

    Lawrence DrCOOliveiro <ldo@nz.invalid> wrote:

    On Thu, 28 Aug 2025 19:05:55 +0100, Chris Green wrote:

    The best I've found so far is the 'source':-
    https://github.com/brgl/libgpiod/blob/master/bindings/python/README.md >>>
    It has some Python examples but the coding style is very odd and
    makes it difficult to follow what's going on IMHO.

    I had a look at one or two examples, but they didnrCOt look very
    rCLoddrCY to me. Any particular ones you are having trouble with?

    I worked it all out OK, I do write quite a lot of Python code. My
    comment was rather that the style using 'with' and so on which makes
    it rather diffcult to actually follow the sequence of calls required
    to do simple things like 'set this line high' or 'read the state of
    that line'.

    You donrCOt know about context managers? TheyrCOre a basic Python
    mechanism for ensuring proper cleanup. You consider it rCLoddrCY just
    because you hadnrCOt learned about that feature of Python?
    --- Synchronet 3.21a-Linux NewsLink 1.2
  • From Chris Green@cl@isbd.net to comp.sys.raspberry-pi on Sat Aug 30 13:42:52 2025
    From Newsgroup: comp.sys.raspberry-pi

    Lawrence DrCOOliveiro <ldo@nz.invalid> wrote:
    On Sat, 30 Aug 2025 09:02:46 +0100, Chris Green wrote:

    Lawrence DrCOOliveiro <ldo@nz.invalid> wrote:

    On Thu, 28 Aug 2025 19:05:55 +0100, Chris Green wrote:

    The best I've found so far is the 'source':-
    https://github.com/brgl/libgpiod/blob/master/bindings/python/README.md

    It has some Python examples but the coding style is very odd and
    makes it difficult to follow what's going on IMHO.

    I had a look at one or two examples, but they didnrCOt look very
    rCLoddrCY to me. Any particular ones you are having trouble with?

    I worked it all out OK, I do write quite a lot of Python code. My
    comment was rather that the style using 'with' and so on which makes
    it rather diffcult to actually follow the sequence of calls required
    to do simple things like 'set this line high' or 'read the state of
    that line'.

    You donrCOt know about context managers? TheyrCOre a basic Python
    mechanism for ensuring proper cleanup. You consider it rCLoddrCY just
    because you hadnrCOt learned about that feature of Python?

    Look, I'm a software engineer (Eur. Ing., FEANI) with well over 50
    years of programming experience in all sorts of languages.

    Yes, context managers are a 'good thing' but using them to help
    **understand** how the basics of a package work is not, IMHO, a good
    idea. First show how to do something **then** emphasise that you
    must release resources and say that using a context manager is one
    way of doing it.

    Someone unfamiliar with Python and/or someone who is not an
    experienced programmer is much more likely to be the audience for
    these examples. The more professional/skilful people will probably
    simply dive in to the API documentation.
    --
    Chris Green
    -+
    --- Synchronet 3.21a-Linux NewsLink 1.2
  • From Lawrence =?iso-8859-13?q?D=FFOliveiro?=@ldo@nz.invalid to comp.sys.raspberry-pi on Sat Aug 30 23:01:15 2025
    From Newsgroup: comp.sys.raspberry-pi

    On Sat, 30 Aug 2025 13:42:52 +0100, Chris Green wrote:

    Yes, context managers are a 'good thing' but using them to help **understand** how the basics of a package work is not, IMHO, a good
    idea.

    It is in fact quite a common thing. Look at the examples of use
    of the open() function in the standard Python library docs <https://docs.python.org/3/library/functions.html#open>, for instance.

    There is another call to open() on that page, in an example for another function, and that uses a with-statement too.

    First show how to do something **then** emphasise that you
    must release resources and say that using a context manager is one
    way of doing it.

    This is the old rCLdo as I say, not as I dorCY school of writing example code. You tell people to understand what the code does and use it as a model,
    not just blindly copy-and-paste, and ... guess what they do?

    Someone unfamiliar with Python and/or someone who is not an
    experienced programmer is much more likely to be the audience for
    these examples.

    In other words, precisely the ones who are in a hurry to get something
    done, finish an assignment or whatever, and therefore ... blindly copy- and-paste.

    The more professional/skilful people will probably simply dive in to the
    API documentation.

    One would hope so, but given some discussions that have been happening recently, IrCOm not so sure ...
    --- Synchronet 3.21a-Linux NewsLink 1.2