01-09-2021, 04:29 PM
(01-05-2021, 08:24 PM)TheOldPresbyope Wrote:(01-05-2021, 08:12 PM)JuanJB Wrote: ...
It would be perfect to have a catchable signal indicating that Moode is ready. The script could then wait until this signal arrives and then put GPIO22=1.
...
Check out Tim's post from yesterday.
Regards,
Kent
Thank you @TheOldPresbyope.
I'm not very skilled in python so it took to me a little to translate the command from @Tim Curtis (thank you too) into python statements. But finally I did.
Now the button finishs blinking only when MoOde is really ready.
The script is launched from /etc/rc.local by adding, before exit 0, at the end of rc.local script:
python3 /home/pi/sds.py &
This is my new sds.py script
Code:
#!/usr/bin/python3
# Moode for Audiophonics SPC II power management board
# Initialisation of GPIO outputs 4 (SofthutDown) and 22 (BootOK)
# Script is lauched by /etc/rc.local
# Power LED stops slowly blinking and lights steadily after MoOde is ready
import sys
import os
import time
import RPi.GPIO as GPIO
import subprocess
print ("Audiophonics initialisation script starting...")
print ("Asserting pins : ")
print ("SoftShutDown : GPIO04=out, Low")
print ("BootOK : GPIO22=out, High")
GPIO.setmode(GPIO.BCM)
print ("Setting SoftShutDown output Low")
GPIO.setup(4, GPIO.OUT)
GPIO.output(4,GPIO.LOW)
print ("Waiting for MoOde Availability")
print ("Condition is checked out every 5 seconds")
option= "-q"
sqlSelect="select value from cfg_system where param='wrkready'"
while True:
result=subprocess.check_output(['/usr/local/bin/moodeutl',option,sqlSelect])
if result == b'1\n': #python3 binary value usage
#if result[0] == "1": #python2 string value usage
print ("Setting BootOK output High")
GPIO.setup(22, GPIO.OUT)
GPIO.output(22,GPIO.HIGH)
break
time.sleep(5)
sys.exit()
Regards,
Juan