API Command to switch off Raspberry PI

Support for Air Player desktop on ARM devices, like the Raspberry Pi.

Moderators: russ, Ralph

Message
Author
User avatar
PapaLima
Posts: 60
Joined: Fri Jan 05, 2018 10:49 am

Re: API Command to switch off Raspberry PI

#11 Post by PapaLima »

Very cool feature ! Thanks 8-)

bmcmullan
Posts: 23
Joined: Sat Sep 02, 2017 2:33 pm
Location: Louisville, KY USA
Contact:

Re: API Command to switch off Raspberry PI

#12 Post by bmcmullan »

Hadn't looked at this thread since March 2018. Corjan, looks like in April 2018 something was implemented. However, I run the Pi with only a monitor connected so can't click or keystroke on anything. And, after probably 1000 times of just pulling the power over the last 15 months, the raspberry's SD card got corrupted the other day so I needed to make something graceful.

For those in same situation, here's what I did - created a simple remote shutdown that works from Windows with a single click. Here's how: Get putty from https://www.chiark.greenend.org.uk/~sgt ... atest.html. I used the full .msi installer and it installs to c:\Program Files\Putty. Then, I created a simple batch file "shutPI.bat" on Windows desktop and put the following commands in there***. Double-click the batch file on desktop to run it (and/or assign a shortcut icon on desktop to it like "Shut SIM & PI"). One click in Windows XPlane host and the PI shutsdown gracefully then {if you want} Windows shuts down.

192.168.2.23 is address of my raspberrypi. I set my router to give it that address (reservation) every time so it stays consistent; change your script to match YOUR raspberry's IP address (The Air Manager desktop shows the PIs address: click Device tab, then the specific Air Player, then in right pane you'll see Running on Raspberry Pi at x.x.x.x IP address).

shutPI.bat
@rem install putty from https://www.chiark.greenend.org.uk/~sgt ... atest.html
@rem shutdown Air Manager remotely (change IP address as needed)
@echo Shutting down Raspberry PI on 192.168.2.23
c:
cd c:\Program Files\putty
@rem plink -ssh pi@192.168.2.23 -pw raspberry "sudo reboot"
plink -ssh pi@192.168.2.23 -pw raspberry "sudo shutdown -h now"
@echo Shutting down Windows
%windir%\System32\shutdown.exe /s /t 1 /c "Shutting down Windows"


*** Just in case you don't know how to "make a batch file": easy, right-click on desktop and select New, then click Text Document. You'll get file on desktop "New Text Document.txt". Open it in notepad, copy and paste the above commands in it from first @rem line to last %windir% line. Save it, then rename "New Text Document.txt" to shutPI.bat.

If you don't want to shut down Windows too, just delete or put @rem in front of the last line (%windir%). Note: the first time you run plink command, plink will ask if you want to save the computers key, type Y for yes, thereafter it won't ask you again.
FSX/P3D/XP11 - i7@5Ghz, GTX1080, 4 screens + Air Manager screen + custom hardware & Avionics COM, GPS, Radios, XPOND, AP (www.simav8.com)

KrustyFM
Posts: 7
Joined: Sun Dec 17, 2017 11:14 am

Re: API Command to switch off Raspberry PI

#13 Post by KrustyFM »

Hi bmcmullan,

that little thing did the trick!
I was looking for scripts and tools online but your simple batch script beats the internet :D

Now I just created a shortcut to this script on my Win machine in order to connect it to a fixed key stroke, have assigned this key stroke via my Arcaze Board to a hardware button in my sim and tadaaaaa: The pi shuts down perfectly just by pressing a button.

Post Reply