mirror of
https://github.com/akuker/RASCSI.git
synced 2024-12-21 08:29:59 +00:00
Added reboot support (#696)
This commit is contained in:
parent
7290803ace
commit
f5f5c002aa
@ -164,18 +164,25 @@ void SCSIDEV::BusFree()
|
||||
|
||||
// When the bus is free RaSCSI or the Pi may be shut down
|
||||
switch(shutdown_mode) {
|
||||
case RASCSI:
|
||||
case STOP_RASCSI:
|
||||
LOGINFO("RaSCSI shutdown requested");
|
||||
exit(0);
|
||||
break;
|
||||
|
||||
case PI:
|
||||
case STOP_PI:
|
||||
LOGINFO("Raspberry Pi shutdown requested");
|
||||
if (system("init 0") == -1) {
|
||||
LOGERROR("Raspberry Pi shutdown failed: %s", strerror(errno));
|
||||
}
|
||||
break;
|
||||
|
||||
case RESTART_PI:
|
||||
LOGINFO("Raspberry Pi restart requested");
|
||||
if (system("init 6") == -1) {
|
||||
LOGERROR("Raspberry Pi restart failed: %s", strerror(errno));
|
||||
}
|
||||
break;
|
||||
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
@ -29,8 +29,9 @@ public:
|
||||
|
||||
enum rascsi_shutdown_mode {
|
||||
NONE,
|
||||
RASCSI,
|
||||
PI
|
||||
STOP_RASCSI,
|
||||
STOP_PI,
|
||||
RESTART_PI
|
||||
};
|
||||
|
||||
// Internal data definition
|
||||
|
@ -27,9 +27,10 @@
|
||||
// uint8_t second; // 0-59
|
||||
// } mode_page_datetime;
|
||||
//
|
||||
// 2. STOP UNIT shuts down RaSCSI or the Raspberry Pi
|
||||
// 2. START/STOP UNIT shuts down RaSCSI or shuts down/reboots the Raspberry Pi
|
||||
// a) !start && !load (STOP): Shut down RaSCSI
|
||||
// b) !start && load (EJECT): Shut down the Raspberry Pi
|
||||
// c) start && load (LOAD): Reboot the Raspberry Pi
|
||||
//
|
||||
|
||||
#include "controllers/scsidev_ctrl.h"
|
||||
@ -77,15 +78,23 @@ void HostServices::StartStopUnit(SCSIDEV *controller)
|
||||
}
|
||||
|
||||
if (load) {
|
||||
controller->ScheduleShutDown(SCSIDEV::rascsi_shutdown_mode::PI);
|
||||
controller->ScheduleShutDown(SCSIDEV::rascsi_shutdown_mode::STOP_PI);
|
||||
}
|
||||
else {
|
||||
controller->ScheduleShutDown(SCSIDEV::rascsi_shutdown_mode::RASCSI);
|
||||
controller->ScheduleShutDown(SCSIDEV::rascsi_shutdown_mode::STOP_RASCSI);
|
||||
}
|
||||
|
||||
controller->Status();
|
||||
return;
|
||||
}
|
||||
else {
|
||||
if (load) {
|
||||
controller->ScheduleShutDown(SCSIDEV::rascsi_shutdown_mode::RESTART_PI);
|
||||
|
||||
controller->Status();
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
controller->Error(ERROR_CODES::sense_key::ILLEGAL_REQUEST, ERROR_CODES::asc::INVALID_FIELD_IN_CDB);
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user