View Single Post
  #9   Spotlight this post!  
Unread 12-02-2016, 14:22
JesseK's Avatar
JesseK JesseK is offline
Expert Flybot Crasher
FRC #1885 (ILITE)
Team Role: Mentor
 
Join Date: Mar 2007
Rookie Year: 2005
Location: Reston, VA
Posts: 3,685
JesseK has a reputation beyond reputeJesseK has a reputation beyond reputeJesseK has a reputation beyond reputeJesseK has a reputation beyond reputeJesseK has a reputation beyond reputeJesseK has a reputation beyond reputeJesseK has a reputation beyond reputeJesseK has a reputation beyond reputeJesseK has a reputation beyond reputeJesseK has a reputation beyond reputeJesseK has a reputation beyond repute
Re: Shutting Down a Robot-Mounted Pi

I don't know the RoboRIO ecosystem, but I do know Linux and Java.

Code:
ssh user:password@rpihost 'sudo shutdown -h now'
You're possibly better off putting the shutdown command into a shell script so you can attempt to kill the processes 'nicely' first, then issue the shutdown - all within the script. The script would live on the raspberry pi, so your RoboRIO code doesn't have to care how the R-PI stuff shuts down, ever.

Add this when you detect end of match presuming you go the script route:
Code:
java.lang.ProcessBuilder processBuilder = new java.lang.ProcessBuilder("ssh", "user:password@rpihost","/path/to/script.bash");
java.lang.Process p = pb.start();
p.waitFor(); // WARNING - will block this thread.  Also, will only block this thread.
System.out.println("R-PI shutdown executed");
__________________

Drive Coach, 1885 (2007-present)
CAD Library Updated 5/1/16 - 2016 Curie/Carver Industrial Design Winner
GitHub