Thank you for your donation!


Cloudsmith graciously provides open-source package management and distribution for our project.


enable gpio output when boot is complete
#18
(01-09-2024, 10:01 PM)Wallyboy Wrote: Try these small changes, cosmetics...
Code:
#!/usr/bin/env python

import RPi.GPIO as GPIO
import os
import subprocess

GPIO.setwarnings(False)
GPIO.setmode(GPIO.BCM)
GPIO.setup(16, GPIO.OUT)

boot_complete = int(subprocess.run(["/usr/local/bin/moodeutl", "-q", "select value from cfg_system where param='wrkready'"], capture_output=True, text=True).stdout)
print(boot_complete)

if boot_complete == 1:
       GPIO.output(16, True)
else:
       GPIO.output(16, False)

I recommend you keep your file safe, then try my changes, and keep them ONLY if they work (I might have introduced typos, or simply the Python engine my changes might not like my code shrinking...)

You can also try this, instead of the IF/ELSE:

Code:
GPIO.output(16, boot_complete == 1 ? True : False)

And remove the print(boot_complete) if you like, or comment it by adding a # at the beginning of the line, with no spaces before nor after, so that the line reads

Code:
#print(boot_complete)

That's it.

Good to hear you managed to accomplish then task, and that's what's important.
Reply


Messages In This Thread
RE: enable gpio output when boot is complete - by Nutul - 01-10-2024, 02:07 AM

Forum Jump: