Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

rpi-retroflag-AdvancedSafeShutdown failing on GPIO.wait_for_edge #12953

Open
Alloc86 opened this issue Nov 19, 2024 · 3 comments
Open

rpi-retroflag-AdvancedSafeShutdown failing on GPIO.wait_for_edge #12953

Alloc86 opened this issue Nov 19, 2024 · 3 comments
Labels

Comments

@Alloc86
Copy link

Alloc86 commented Nov 19, 2024

Batocera build version

40 2024/08/02 00:36

Your architecture

Raspberry Pi 4

Your Graphic Processor Unit(s) (GPU)

Raspberry Pi 4

Issue description

Trying o get the buttons on a SUPERPI 4 case working. As they did nothing I checked the PID stored in /tmp/rpi-retroflag-AdvancedSafeShutdown.pid and it always points to a non-existant process.
So I tried running the respective script rpi-retroflag-AdvancedSafeShutdown directly but it always fails with this output:

Process Process-1:
Process Process-2:
Traceback (most recent call last):
Traceback (most recent call last):
Process Process-3:
Traceback (most recent call last):
  File "/usr/lib/python3.11/multiprocessing/process.py", line 314, in _bootstrap
    self.run()
  File "/usr/lib/python3.11/multiprocessing/process.py", line 314, in _bootstrap
    self.run()
  File "/usr/lib/python3.11/multiprocessing/process.py", line 108, in run
    self._target(*self._args, **self._kwargs)
  File "/usr/bin/rpi-retroflag-AdvancedSafeShutdown", line 29, in poweroff
    GPIO.wait_for_edge(powerPin, GPIO.FALLING)
RuntimeError: Error waiting for edge
  File "/usr/lib/python3.11/multiprocessing/process.py", line 108, in run
    self._target(*self._args, **self._kwargs)
  File "/usr/bin/rpi-retroflag-AdvancedSafeShutdown", line 40, in ledBlink
    GPIO.wait_for_edge(powerPin, GPIO.FALLING)
RuntimeError: Error waiting for edge
  File "/usr/lib/python3.11/multiprocessing/process.py", line 314, in _bootstrap
    self.run()
  File "/usr/lib/python3.11/multiprocessing/process.py", line 108, in run
    self._target(*self._args, **self._kwargs)
  File "/usr/bin/rpi-retroflag-AdvancedSafeShutdown", line 51, in reset
    GPIO.wait_for_edge(resetPin, GPIO.FALLING)
RuntimeError: Error waiting for edge

This is a fresh installation of Batocera, running /etc/init.d/S92switch setup was the only thing I did trying to get this working.

Detailed reproduction steps

Raspberry Pi 4 in a SUPERPI 4 case.
Fresh installation of Batocera.
Buttons not working (as expected) so ran /etc/init.d/S92switch setup and selected RETROFLAG_ADV.
Rebooted, still not working.
Checked if rpi-retroflag-AdvancedSafeShutdown was running - not the case but pid-file exists.
Tried running it manually - error as above.

Details of any attempts to fix this yourself

Nothing yet, only searched google and issues here for others having the problem but couldn't find anything specific to these scripts. Only general Raspberry + Python hints on this method no longer being supported.

Details of any modifications you have made to Batocera.

None

Logs and data

No response

@Alloc86
Copy link
Author

Alloc86 commented Nov 19, 2024

I changed the code in the script like this to replace the wait_for_edge calls with loops checking the pin states, so it runs for now. I don't think this would be the ideal solution, but I'm not experienced with RPi programming so I didn't look any further.

def poweroff():
        while True:
                ### New:
                while GPIO.input(powerPin) == GPIO.LOW:
                        time.sleep(0.1)
                while GPIO.input(powerPin) == GPIO.HIGH:
                        time.sleep(0.01)
                ###Orig:
                # GPIO.wait_for_edge(powerPin, GPIO.FALLING)
                output = int(subprocess.check_output(['batocera-es-swissknife', '--espid']))
                if output:
                        os.system("batocera-es-swissknife --shutdown")
                else:
                        os.system("shutdown -h now")

#blinks the LED to signal button being pushed
def ledBlink():
        while True:
                GPIO.output(ledPin, GPIO.HIGH)
                ### New:
                while GPIO.input(powerPin) == GPIO.HIGH:
                        time.sleep(0.01)
                ###Orig:
                # GPIO.wait_for_edge(powerPin, GPIO.FALLING)
                start = time.time()
                while GPIO.input(powerPin) == GPIO.LOW:
                        GPIO.output(ledPin, GPIO.LOW)
                        time.sleep(0.2)
                        GPIO.output(ledPin, GPIO.HIGH)
                        time.sleep(0.2)

#resets the pi
def reset():
        while True:
                ### New:
                while GPIO.input(resetPin) == GPIO.LOW:
                        time.sleep(0.1)
                while GPIO.input(resetPin) == GPIO.HIGH:
                        time.sleep(0.01)
                ###Orig:
                # GPIO.wait_for_edge(resetPin, GPIO.FALLING)
                output = int(subprocess.check_output(['batocera-es-swissknife', '--espid']))
                output_rc = int(subprocess.check_output(['batocera-es-swissknife', '--emupid']))

@dmanlfc
Copy link
Collaborator

dmanlfc commented Nov 24, 2024

please come on Discord to discuss & do some testing. The later kernel requires a change of library

@Alloc86
Copy link
Author

Alloc86 commented Nov 25, 2024

I'm happy to run any tests you give me whenever I have a moment, but I won't be available for any live discussion for the next two weeks.
If you want me to do anything until then please just post here, otherwise I'll get back to you later on :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants