RetroPie forum home
    • Recent
    • Tags
    • Popular
    • Home
    • Docs
    • Register
    • Login

    About the RetroFlag cases! Surprise surprise.... They can cut off power!

    Scheduled Pinned Locked Moved General Discussion and Gaming
    nespi case +safe shutdown
    52 Posts 15 Posters 17.1k Views
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • I
      iLackIQ
      last edited by

      Sorry for what seem like a stupid question, but does it save metadata? Also I already have installed RetroFlag's "safe shutdown" from their github, do I need to remove that before installing this? Thanks

      1 Reply Last reply Reply Quote 0
      • C
        cloudlink
        last edited by

        How would I modify it to shut down my fan of it is on GPIO pin 17?

        1 Reply Last reply Reply Quote 0
        • cyperghostC
          cyperghost @matchaman
          last edited by cyperghost

          @matchaman said in About the NESPi+ case! Surprise surprise.... It can cut off power!:

          What inconvenience? This is excellent! Thanks!

          No problem, @gollumer was my testing site - so thank him for his patience. It is nearly impossible to write working scripts without having the device here for testing... so I decided to buy one and voila, just a quick shot.

          @iLackIQ No not at all. If you are happy with the python way you can of course use that. But it won't provide "safe shutdown" but I also wrote a working python script (based on the retroflags one) that provides safe shutdowns, too. So you decide.

          @cloudlink GPIO17=GPIO17 and Pin17 is Pin17. So you are talking about the 3,3V Pin and mean the pyhsical pin 17 on the header. With a total cut off power this pin looses voltage and your fan is powered down. So the script name in point 6 is a bit misleading I agree. It should named gpio-poweroff, but it doesn't change the behaviour.

          1 Reply Last reply Reply Quote 0
          • I
            iLackIQ
            last edited by

            What I'm asking is, I have a raspberry pi 3 B+ and a NESPi + case. I wanted to know if I can use this for a safe and complete shutfown? And can I use this as a standalone or do I need to have the retroflag scripts installed as well? Finally is there a way to make the reset button restart emulation station or just exit the current running game, instead of restarting the entire system? Thanks

            cyperghostC 1 Reply Last reply Reply Quote 0
            • cyperghostC
              cyperghost @iLackIQ
              last edited by cyperghost

              @ilackiq Yes safe shutdown is possible.
              With the bash script posted here ... you have all the features you mentioned. Power on power off, reset ends running emulators, reset inside emulationstation restarts emulationstation only (NO REBOOT!). All with safe shutdown!
              But then you have to disable uninstall your python script!

              But you can also use the modified python script that I already posted to you, there you need just to follow instructions and do not need to disable the python script, you exchange it with the one I gave you link. This provides also safe shutdown of course. With this script you just restart emulationstation with reset button... feel free to extend this, if you want - that's also easily possible.

              O 1 Reply Last reply Reply Quote 1
              • L
                lininjim
                last edited by

                Cyperghost this is just superb. I have registered now to thank you for this. I'll be installing it on my setup shortly. Again. Thank you.

                1 Reply Last reply Reply Quote 1
                • L
                  lininjim
                  last edited by

                  Hmm didn't work for me, Stretch install, pi 4.4, NesPi+ case and Pi 3B+. Installed script, powered off moved switch to On, booted up and led is now off, reset button doesn't do anything, not tried power button yet, time to snoop on my system.

                  cyperghostC 1 Reply Last reply Reply Quote 0
                  • cyperghostC
                    cyperghost @lininjim
                    last edited by cyperghost

                    @lininjim Well, did you start the script via autostart or made it executable?
                    Is raspi-gpio installed? It is working, believe me ;) If the LED is off, then the script is not active!

                    I think I will write an installer script.

                    Welcome on board!

                    1 Reply Last reply Reply Quote 1
                    • L
                      lininjim
                      last edited by

                      @cyperghost said in About the NESPi+ case! Surprise surprise.... It can cut off power!:

                      /home/pi/RetroPie/scripts/multi_switch.sh --nespi+ &

                      Thank you mate, I had not even looked at your script, just installed it etc, when I did I noticed this - # NESPIplus! Install raspi-gpio via "sudo apt install raspi-gpio", no sudo needed, reset, poweroff
                      So hang my head in shame haha, installed it, re-ran the script and BINGO. You are a superstar sir. Many thanks. I love it.

                      1 Reply Last reply Reply Quote 0
                      • D
                        diablo
                        last edited by

                        I am so close to having this working but I am missing something that to you guys is probably glaringly obvious.

                        First: install raspi-gpio with sudo apt install raspi-gpio (done, all seemed fine there)

                        Second: install shutdown_fan script as descriped in point 6 (again I think thats ok)
                        Today (03/05/18) I got a NESPi+ case so I was able to elaborate the issue. Thanks to @gollumer for your patince!

                        Set NESPi+ case switch to safe shutdown ON. (done)
                        Login with SSH
                        Type in commands mkdir /home/pi/RetroPie/scripts && cd /home/pi/RetroPie/scripts (again seemed to go ok)

                        This is where I think I have drifted off target.

                        DL: wget https://raw.githubusercontent.com/crcerror/ES-generic-shutdown/master/multi_switch.sh && chmod +x multi_switch.sh ( i thought I did it right, but not sure now)

                        3.1 If there is an older version please remove this one with rm multi_switch.sh (there is definitely a multi_switch file there somewhere, but I cant see it. But if i run with the above dl again its gets renamed to .1/.2 etc. So its there. But if i ssh in and go to the scripts directory I cant see anything there.)
                        3.2 Otherwise the current downloaded version will get a .sh.1 filename! (Yep, thats happening alright)

                        Now edit ES autostart with nano /opt/retropie/configs/all/autostart.sh and add script to like .... (Not a 100 percent sure what you meant there, did you mean to say look like?)
                        Anyway, after edit my autostart looks exactly like this now

                        /home/pi/RetroPie/scripts/multi_switch.sh --nespi+ &
                        emulationstatio #auto

                        (In theory, could I have stopped now, if it had gone right for me, and come back to do the fan aspect later? I only ask out of interest, trying go learn on the fly here)

                        Install fan_shutdown script: cd /lib/systemd/system-shutdown/ && sudo wget https://raw.githubusercontent.com/crcerror/ES-generic-shutdown/master/shutdown_fan && sudo chmod +x shutdown_fan
                        6.1 The shutdown_fan is setted to GPIO4 as standard
                        6.2 Therefore you might edit with sudo nano /lib/systemd/system-shutdown/shutdown_fan (again, if I had stayed with the way the nespi+ default setup, would I even need to to this bit?)

                        i think my whole issue is the 'not being able to see/access the script file. Something the pi is sharing with me as it cant see it either. The fact that the download adds another version kind of suggests that the original file is there. During my failed attempts to work things out I have seen it deny access to those renamed download files (.2 and .3 before realising I was chasing my tail)

                        I really like the idea of having things set up as you have done them. But I am stuck now. After hours of trying I am at the point where I either asked for help, or just gave up and installed the default 'nespi+' script.

                        I did read in a follow up, that the question of automatic or executable came into play. Thats a definite level above my capabilities at this moment as I jave no idea which it should be, or how to even change it if its wrong.

                        Sorry for asking, but I am totally stuck now and my fumbling around is liable to do more damage than good.

                        cyperghostC 1 Reply Last reply Reply Quote 0
                        • cyperghostC
                          cyperghost @diablo
                          last edited by cyperghost

                          @diablo No problem.... Maybe I should provide an installer later. That makes these things automatic.

                          Good: raspi-gpio is needed

                          What do you mean with: "there is definitely a multi_switch file there somewhere, but I cant see it". Do you use WINSCP and it's command interface? If yes you should press the reload button, and then the files will appear. But all in all prefer the use of putty or kitty. But step by step

                          If you type in: mkdir /home/pi/RetroPie/scripts && cd /home/pi/RetroPie/scripts are folders created and are you in this folder with command prompt?

                          Now next: if you type in wget https://raw.githubusercontent.com/crcerror/ES-generic-shutdown/master/multi_switch.sh && chmod +x multi_switch.sh after that you can use ls command to list the directory. There the file should appear.

                          Yes... the autostart is also correct. So it should be a proper setup.

                          The GPIO bit to shutoff the fan in the second script needs no change by default! It's just a hint if someone want to rewire the NESPi enclosure.

                          What is the output of: ls /home/pi/RetroPie/scripts
                          Or can you even execute the multi_switch.sh itself?
                          So what is the output of: /home/pi/RetroPie/scripts/multi_switch.sh

                          To make something executable means to use chmod +x command. The script is simple a text file and needs to be made excutable, so it can be called by the command line. But you will see it if you execute the script via command line. That's it :)

                          BTW: Are other scripts running? Maybe the original from retroflag? You should disable them by removing the call from rc.local therefore sudo nano /etc/rc.localand remove the sudo python ..... entry or set a # before to comment it out.

                          D 1 Reply Last reply Reply Quote 0
                          • C
                            cloudlink
                            last edited by

                            Is there a line I can put into a shell script that will restart EmulationStation, saving metadata?

                            cyperghostC 1 Reply Last reply Reply Quote 0
                            • D
                              diablo @cyperghost
                              last edited by

                              @cyperghost am not at home as I write this so not in range of my gear. But I wanted to say thank you for the response asap. I will get into it later. All looks logical and easy to follow (at this stage thats needed). A couple of things i can confirm are that I am using putty, and I didnt install any retroflag stuff. the directories are there. Its just the multiswitch that seemed to be awol. Again thanks, will check it out asap.

                              1 Reply Last reply Reply Quote 0
                              • cyperghostC
                                cyperghost @cloudlink
                                last edited by cyperghost

                                @cloudlink yes multi_switch.sh --es-restart
                                Therefore I wrote the script...
                                For more help type multi_switch.sh --help

                                @diablo You are welcome

                                C 1 Reply Last reply Reply Quote 1
                                • D
                                  diablo
                                  last edited by

                                  cyperghost, you are a legend. When I first asked the question I had a few doubts about how I had done things. Something had happened with mine that kicked it off track though. I should have added that I am using a pi 3b. Anyway, following your instructions (to the letter), showed that the file structure was correct, though no multiswitch file (sorry for spelling it wrong, but i need to write this fast as i am needed elsewhere in twenty mins). Running the wget https bit gave me a newly created multiswitch.1 file. So it was definitely saving it.

                                  Ls of the scripts folder still showed nothing there.

                                  Backtracking through the hierarchy though I discovered both multiswitch and its newly created ms.1 version were both in the 'home' folder. Not where they should have been obviously.

                                  A quick google on how to move a file within putty (told you i was new to all this) and i moved ms to the scripts folder.

                                  Ls confirmed the move was good.

                                  Rechecked the ES autostart details, all looked good.

                                  Restarted the pi, finally seeing a flicker from the led then eventually lit solid.with ES fully loaded. Tried a game, pressed reset and it jumped back to game selection. Hit the power button and a second or three later it shut down. A number of test shutdowns and resets later and Basically, its working perfectly now (albeit without a fan as the one I had fitted sounds like a 747 taking off, so no idea about fan script working or not, though I have no reason to think it wont now the rest is ok.

                                  So again, cyperghost, thank you. Your 'fault finding' was used, albeit in a different manner, but its now working as intended thanks to your input. Greatly appreciated.

                                  I know a lot of people think the nespi has been done to death, but with the + sat next to my c64 and snes minis, and knowing its abilities, the pi is awesome to me now. It just looks'right'.

                                  1 Reply Last reply Reply Quote 0
                                  • C
                                    cloudlink @cyperghost
                                    last edited by cloudlink

                                    @cyperghost said in About the NESPi+ case! Surprise surprise.... It can cut off power!:

                                    multi_switch.sh --es-restart

                                    It worked!
                                    Thank you so much!

                                    1 Reply Last reply Reply Quote 0
                                    • O
                                      OhOhOne @cyperghost
                                      last edited by OhOhOne

                                      @cyperghost said in About the NESPi+ case! Surprise surprise.... It can cut off power!:

                                      @ilackiq Yes safe shutdown is possible.
                                      With the bash script posted here ... you have all the features you mentioned. Power on power off, reset ends running emulators, reset inside emulationstation restarts emulationstation only (NO REBOOT!). All with safe shutdown!
                                      But then you have to disable uninstall your python script!

                                      But you can also use the modified python script that I already posted to you, there you need just to follow instructions and do not need to disable the python script, you exchange it with the one I gave you link. This provides also safe shutdown of course. With this script you just restart emulationstation with reset button... feel free to extend this, if you want - that's also easily possible.

                                      cyperhost, I tried following your directions for replacing the stock RetroFlag script with your python script (as I had already installed the stock one), but it's not working for me, the red light just blinks indefinitely and never turns off. What did I do wrong? How can I disable or uninstall the python script so I can switch you your bash script and use that instead, since the reset button seems so much more useful on your bash script?

                                      Thanks.

                                      cyperghostC 1 Reply Last reply Reply Quote 0
                                      • cyperghostC
                                        cyperghost @OhOhOne
                                        last edited by cyperghost

                                        @OhOhOne
                                        Did you installed the original script by retroflag?
                                        Can you check if multi_switch.sh is executable and is located into cd /opt/RetroFlag folder?
                                        Is the python script exchanged by the one given in the thread?

                                        If you decide to install the bash script then you have to remove the installed python script first. Type sudo nano /etc/rc.local and remove or comment with # the line with the python code.

                                        Btw: You can easily extend the python with an el-if branch to just restart emulators if they are running.... I just give an example how script can be invoked into other languages. So the bash and the python script function equally.

                                        O 1 Reply Last reply Reply Quote 0
                                        • O
                                          OhOhOne @cyperghost
                                          last edited by OhOhOne

                                          @cyperghost
                                          I double checked everything and its still not working.
                                          I installed the original script by retroflag. It was working fine, but I wanted something that would save metadata, so I followed your directions posted in the other thread for replacing the original script with your own python scripts. But ever since then the power button just blinks red when I push it to off, and the reset switch doesn't do anything at all. I double checked and multi_switch.sh is there in /opt/RetroFlag and is executable, and I deleted the original python script and replaced it with yours (again, just to be sure). But its still not working.

                                          Am I missing something? Did I skip a step?

                                          EDIT: this is what I get when I type sudo nano rc.local:
                                          GNU nano 2.2.6 File: rc.local

                                          By default this script does nothing.

                                          Print the IP address

                                          _IP=$(hostname -I) || true
                                          if [ "$_IP" ]; then
                                          printf "My IP address is %s\n" "$_IP"
                                          fi

                                          /etc/switch.sh &
                                          /etc/switch.sh &
                                          sudo python3 /opt/RetroFlag/SafeShutdown.py &
                                          exit 0

                                          cyperghostC 1 Reply Last reply Reply Quote 0
                                          • cyperghostC
                                            cyperghost @OhOhOne
                                            last edited by

                                            @ohohone Why double /etc/switch.sh? Try to remove this first.
                                            You can also remove the sudo from the python3 call. etc.local is already root

                                            O 1 Reply Last reply Reply Quote 0
                                            • First post
                                              Last post

                                            Contributions to the project are always appreciated, so if you would like to support us with a donation you can do so here.

                                            Hosting provided by Mythic-Beasts. See the Hosting Information page for more information.