Quantcast
Channel: Raspberry Pi Forums
Viewing all articles
Browse latest Browse all 4816

Python • Re: Runtime error waiting_for_edge GPIO

$
0
0
im trying to work this out...
I don't want to destroy your enthusiam but I think you're on a fruitless quest with your limited experience. The issue seems to be another bug in 'rpi-lgpio' which likely won't be overcome by hacking at things at a higher level. At least until we know what we are having to hack around.

I think polling rather that waiting for an edge would side-step the issue entirely but, as we are here, it's worth figuring out why it doesn't work.

The problem code is this -

Code:

    try:        alert = _get_alert(gpio, mode, edge, bouncetime)    except KeyError:        unset = True        alert = _set_alert(gpio, mode, edge, bouncetime)
I am not yet sure why the first '_get_alert' throws a 'KeyError' exception, but when it does it seems inevitable to me that calling '_get_alert' again will throw another error, as it does, though perhaps the 'unset = True' is somehow meant to avoid that.

When it gets there for the Power button -

gpio = 3, mode = 0x10121 (65825), edge = 0x20 (32), bounceTime = None

That all seems reasonable to me, presuming 'mode' is correct, so time to dig into '_get_alert' to see why that's throwing an error.

And, when we get there -

Code:

def _get_alert(gpio, mode, edge, bouncetime):    if not mode & _LG_ALERT:        raise KeyError(gpio)
That '_LG_ALERT' value is 0x400 (1024) and 'mode' has value 0x10121 (65825) so, the bit is not set, and the code throws the error.

So the question is why the 'mode' value is as it is, not how the code seems to expect it to be, or why the code is getting there if it in fact shouldn't.

That would seem to require an understanding of what it's all meant to be doing and how it does that and I don't have much of a clue on that at present.

Statistics: Posted by hippy — Mon Jul 29, 2024 10:47 am



Viewing all articles
Browse latest Browse all 4816

Trending Articles