mirror of https://github.com/rusefi/bldc.git
Merge pull request #695 from surfdado/shutdown
COMM_SHUTDOWN command for shutdown/restart
This commit is contained in:
commit
25b424c717
|
@ -1621,6 +1621,26 @@ void commands_process_packet(unsigned char *data, unsigned int len,
|
|||
conf_custom_process_cmd(data - 1, len + 1, reply_func);
|
||||
} break;
|
||||
|
||||
|
||||
case COMM_SHUTDOWN: {
|
||||
int ind = 0;
|
||||
int force = data[ind++];
|
||||
if ((fabsf(mc_interface_get_rpm()) > 100) && (force != 1)) {
|
||||
// Don't allow shutdown/restart while riding, unless force == 1
|
||||
break;
|
||||
}
|
||||
|
||||
int is_restart = data[ind++];
|
||||
if (is_restart == 1) {
|
||||
// same as terminal rebootwdt command
|
||||
chSysLock();
|
||||
for (;;) {__NOP();}
|
||||
}
|
||||
else {
|
||||
do_shutdown(false);
|
||||
}
|
||||
} break;
|
||||
|
||||
// Blocking commands. Only one of them runs at any given time, in their
|
||||
// own thread. If other blocking commands come before the previous one has
|
||||
// finished, they are discarded.
|
||||
|
|
|
@ -1094,6 +1094,13 @@ typedef enum {
|
|||
COMM_LOG_DATA_F64 = 151,
|
||||
|
||||
COMM_LISP_RMSG = 152,
|
||||
|
||||
//Placeholders for pinlock commands
|
||||
//COMM_PINLOCK1 = 153,
|
||||
//COMM_PINLOCK2 = 154,
|
||||
//COMM_PINLOCK3 = 155,
|
||||
|
||||
COMM_SHUTDOWN = 156,
|
||||
} COMM_PACKET_ID;
|
||||
|
||||
// CAN commands
|
||||
|
|
|
@ -72,7 +72,7 @@ void shutdown_hold(bool hold) {
|
|||
m_shutdown_hold = hold;
|
||||
}
|
||||
|
||||
static bool do_shutdown(bool resample) {
|
||||
bool do_shutdown(bool resample) {
|
||||
conf_general_store_backup_data();
|
||||
#ifdef USE_LISPBM
|
||||
lispif_process_shutdown();
|
||||
|
@ -223,6 +223,11 @@ void shutdown_hold(bool hold) {
|
|||
(void)hold;
|
||||
}
|
||||
|
||||
bool do_shutdown(bool resample) {
|
||||
(void)resample;
|
||||
return false;
|
||||
}
|
||||
|
||||
static THD_FUNCTION(shutdown_thread, arg) {
|
||||
(void)arg;
|
||||
|
||||
|
|
|
@ -47,5 +47,6 @@ bool shutdown_button_pressed(void);
|
|||
float shutdown_get_inactivity_time(void);
|
||||
void shutdown_set_sampling_disabled(bool disabled);
|
||||
void shutdown_hold(bool hold);
|
||||
bool do_shutdown(bool resample);
|
||||
|
||||
#endif /* SHUTDOWN_H_ */
|
||||
|
|
Loading…
Reference in New Issue