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