Thank you for your donation!


Thread Rating:
  • 1 Vote(s) - 5 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Howto Power management for Audiophonics I-Sabre ES9023 V3
#1
1 / Installation of WiringPi:

You’ll need WiringPi to communicate withe the GPIO pins on the Pi.
To do so you’ll need to install gcc:

Code:
sudo apt-get install gcc

now on to wiringPi:

Code:
cd /home/pi
git clone git://git.drogon.net/wiringPi
cd wiringPi
./build


If all goes well you can now get an overview of the GPIO pins by typing 

Code:
gpio readall




2 / Creating the script for the command from the power button:
First we need to go back to /home/pi

Code:
cd /home/pi

Then we can get the script

Code:
wget https://raw.githubusercontent.com/audiophonics/Raspberry-pwr-management/master/sds.sh


3 / Add the script button at startup: Editing the startup file:
Now edit rc.local. This will make the script run at startup.

Code:
sudo nano /etc/rc.local

Add this line before "exit 0”. Don’t delete or change anything else in this file, just add the extra line.

Code:
sudo bash /home/pi/sds.sh &



4 / Creating command scripts for moOde restart and shutdown:
softshutdown recovery script:

Code:
sudo wget https://raw.githubusercontent.com/audiophonics/Raspberry-pwr-management/master/softshutdown.sh

softreboot recovery script:

Code:
sudo wget https://raw.githubusercontent.com/audiophonics/Raspberry-pwr-management/master/softreboot.sh

I don’t know if the scripts need to be executable, but I don’t think it can hurt to do so:

Code:
sudo chmod +x sds.sh
sudo chmod +x softshutdown.sh
sudo chmod +x softreboot.sh


5 / Make moOde work with the scripts.
First make a backup of the original worker.php file in case you mess things up:

Code:
cd /var/www/command
sudo cp worker.php worker.sav


We can now edit the original:

Code:
sudo nano worker.php

Search for ‘reboot’ until you find the part that reads this:
     
Code:
case 'reboot':
         sysCmd('mpc stop');
         sysCmd('systemctl stop nginx');
         sysCmd('reboot');
         break;
      case 'poweroff':
         sysCmd('mpc stop');
         sysCmd('systemctl stop nginx');
         sysCmd('poweroff');
         break;


Here we will replace the reboot and poweroff commands with the scripts that now reside in /home/pi.
Change the text so it reads:

Code:
      case 'reboot':
         sysCmd('mpc stop');
         sysCmd('systemctl stop nginx');
         sysCmd('sudo bash /home/pi/softreboot.sh');
         break;
      case 'poweroff':
         sysCmd('mpc stop');
         sysCmd('systemctl stop nginx');
         sysCmd('sudo bash /home/pi/softshutdown.sh');
         break;


Reboot the Pi and if all goes well your LED should stop blinking and you should be able to power down with the button as well as through the moOde web UI.


[video=youtube]https://youtu.be/HsJU91o_yHw[/video]
Reply
#2
Hi rikardo1979,

I followed your howto, thank you very much for this clear document.
a couple of points:
Bash files (if you open then, you see they start with #!/bin/bash or similar, indeed need to be executable, so the chmod +x is indeed mandatory.

As for the worker.php file: i started with a clean Moode 4.1 setup. Since Moode 4.0 it seems these reboot/poweroff script parts are in:
/var/local/commandw/restart.sh

should be even easier. ;-)
Code is now:
Code:
case 'reboot':
         mpc stop
         systemctl stop nginx
         /home/pi/softreboot.sh
         break;
      case 'poweroff':
         mpc stop
         systemctl stop nginx
         /home/pi/softshutdown.sh
         break;
Reply
#3
Would this script be for Ver 4.x only ?
Or would it be backward compatible ?

Thanks.
Reply
#4
(05-01-2018, 08:41 PM)rikardo1979 Wrote: Reboot the Pi and if all goes well your LED should stop blinking and you should be able to power down with the button as well as through the moOde web UI.

Works like a charm! Thx, Rikardo!

One question though…
I assume this will be overwritten again with every new version of moOde? If so, isn't it possible to kinda automate this? Like putting it all in one script and then execute this script?

Johan
I swear your honor, I have no idea where that knife came from....
Reply
#5
(06-08-2018, 08:12 PM)hifix Wrote: Would this script be for Ver 4.x only ?
Or would it be backward compatible ?

Thanks.

As far as I remember it was a bit different on previous versions
Reply
#6
(06-13-2018, 07:59 PM)JST1963 Wrote:
(05-01-2018, 08:41 PM)rikardo1979 Wrote: Reboot the Pi and if all goes well your LED should stop blinking and you should be able to power down with the button as well as through the moOde web UI.

Works like a charm! Thx, Rikardo!

One question though…
I assume this will be overwritten again with every new version of moOde? If so, isn't it possible to kinda automate this? Like putting it all in one script and then execute this script?

Johan

To be honest I do not know answer for this as I have not tried any updates :Smilevery time I do a fresh install of system when testing new releases to be sure there is no 'mess' left behind 

Regarding the automated install script, I am pretty sure it would be possible. Unfortunately this is beyond my knowledge. Maybe somebody clever with coding skills can do it Wink
Reply
#7
This script works fine on the Sabre 9023 where the on/off button was connected directly to the DAC board.

When using a ES9038Q2M DAC a little power management board Pi-SPC II is used to connect the on/off button. And unfortunately this script doesn't work in that case.... Angry

Johan
I swear your honor, I have no idea where that knife came from....
Reply


Forum Jump: