From 64e774876f2c689583d31f8f67bd696ba9a9d1a7 Mon Sep 17 00:00:00 2001 From: Michael Buesch Date: Sun, 13 Jun 2010 22:18:57 +0200 Subject: pressure_control: Don't allow changing parameters on disabled device Signed-off-by: Michael Buesch --- pressure_control/firmware/main.c | 5 +++++ pressure_control/firmware/main.h | 1 + pressure_control/firmware/remote.c | 20 ++++++++++++++++++++ 3 files changed, 26 insertions(+) (limited to 'pressure_control/firmware') diff --git a/pressure_control/firmware/main.c b/pressure_control/firmware/main.c index 177adef..8e824d4 100644 --- a/pressure_control/firmware/main.c +++ b/pressure_control/firmware/main.c @@ -289,6 +289,11 @@ void prepare_shutdown(void) state.device_enabled = 0; } +bool device_is_enabled(void) +{ + return state.device_enabled; +} + int main(void) { uint8_t mcucsr; diff --git a/pressure_control/firmware/main.h b/pressure_control/firmware/main.h index ecfbf45..cbe52dd 100644 --- a/pressure_control/firmware/main.h +++ b/pressure_control/firmware/main.h @@ -68,6 +68,7 @@ void set_pressure_config(struct pressure_config *xy, void get_pressure_state(struct pressure_state *state); void prepare_turn_on(void); void prepare_shutdown(void); +bool device_is_enabled(void); struct valves; diff --git a/pressure_control/firmware/remote.c b/pressure_control/firmware/remote.c index 172c5d0..d15ff99 100644 --- a/pressure_control/firmware/remote.c +++ b/pressure_control/firmware/remote.c @@ -225,6 +225,11 @@ static void handle_received_message(void) case MSG_SET_DESIRED_PRESSURE: { struct pressure_config xy, z; + if (!device_is_enabled()) { + err = MSG_ERR_BUSY; + goto out; + } + irq_disable(); get_pressure_config(&xy, &z); if (rx_msg.setpressure.island == 0) @@ -238,6 +243,11 @@ static void handle_received_message(void) case MSG_SET_HYSTERESIS: { struct pressure_config xy, z; + if (!device_is_enabled()) { + err = MSG_ERR_BUSY; + goto out; + } + irq_disable(); get_pressure_config(&xy, &z); if (rx_msg.setpressure.island == 0) @@ -252,6 +262,11 @@ static void handle_received_message(void) struct pressure_config xy, z; bool flag; + if (!device_is_enabled()) { + err = MSG_ERR_BUSY; + goto out; + } + irq_disable(); get_pressure_config(&xy, &z); flag = !!(rx_msg.setconfig.flags & (1 << CFG_FLAG_AUTOADJUST_ENABLE)); @@ -276,6 +291,11 @@ static void handle_received_message(void) struct pressure_config xy, z; struct valves *v; + if (!device_is_enabled()) { + err = MSG_ERR_BUSY; + goto out; + } + get_pressure_config(&xy, &z); if (rx_msg.valve.island == 0) { if (xy.autoadjust_enable) { -- cgit v1.2.3