Shutdown and restart
Lothar (3292) 134 posts |
Since the Pi has no reset button – if something goes wrong, and it needs to be restarted, only option is the power plug. But if the machine does not hang yet – shutdown from Desktop offers a restart option. But when working headless, it would be good to also have a CLI shutdown restart option – similar to Linux. Would it be a big effort to modify *ShutDown command to take a -restart option? |
Stuart Painting (5389) 714 posts |
TaskManager_Shutdown is your friend. One line of BASIC will do the trick:
If you want to avoid Message_PreQuit, that becomes |
Alan Adams (2486) 1149 posts |
While working on some assembler, which tended to crash the pi, I soldered a 2-pin header to the pi (there are pads provided for this) and plugged a reset button in to that.
Would that avoid the message about files in RAM? If so, it gets round a problem I had to solve first by creating a file in RAM (in case there wasn’t one), then *deleting the contents of RAM, then restarting. |
John WILLIAMS (8368) 495 posts |
Would the Wipe command not have served instead, or X Delete to avoid errors in case of there being no file? Or have I misunderstood? |
Raik (463) 2061 posts |
All Pi are support a hardware reset button but the jumper are different. If you can use a starcommand, you use a keyboard? |
Stuart Painting (5389) 714 posts |
No, you’d have to resort to OS_Reset which is something of a “cut everything off at the knees” command. EDIT: Ninja’d by Raik… sorry! |
Chris Hall (132) 3558 posts |
The advantage of SYS “TaskManager_Shutdown”,160 is that RISC is shut down tidily, exactly as if you had used CTRL-SHIFT-f12, i.e. saving CMOS etc. before restarting. With hardware power control it is the tidiest way to switch off under software control. Use 162 if there is no keyboard, mouse or monitor. |
Alan Adams (2486) 1149 posts |
It could be me that misunderstood. The issue I had was that I could not find a command which would delete all files from RAM, and not issue an error if there were no files there. It was a while ago but I’m sure I tested *delete and *wipe. In the end I created a file, then did a delete (or possibly a wipe) of all, before shutting down. The code I use is below. I see that I’m already using 162 (actually 34 – does bit 7 ‘Skip running of PostDesk scripts’ stop the messages?), and it doesn’t suppress the message. I see I found a way to avoid the error message without needing to create a file first. DEF PROCshutdown(restart%) LOCAL flags% flags%=1 + (1<<1) REM wipe discs, force, no verbose, X to suppress "EMPTY" error SYS "XOS_FSControl",27,"RAM::RamDisc0.$.*",,flags% TO ;flags% REM don't send pre-quit flags%=1<<1 IF restart% THEN flags% += (1<<5) REM don't use flag bit 6, power off, as it silently fails to shut down if REM the hardware doesn't allow it. SYS "XTaskManager_Shutdown",flags% TO ;flags% ENDPROC |
Paolo Fabio Zaino (28) 1882 posts |
@ Alan Adams
If that’s the issue you had then you could have used: IfThere RAM::RamDisc0.$.* Then wipe RAM::RamDisc0.$.* FR~C~V That should do exactly what you want and if there are no files or directories in the RAM disc then it won’t do anything. Just my 0.5.c, hope this helps! |
John WILLIAMS (8368) 495 posts |
As would the simpler
which was my point somewhat earlier, where the X form suppresses any error if there is |