summaryrefslogtreecommitdiffstats
path: root/pressure_control/firmware
diff options
context:
space:
mode:
authorMichael Buesch <mb@bu3sch.de>2010-06-13 22:18:57 +0200
committerMichael Buesch <mb@bu3sch.de>2010-06-13 22:18:57 +0200
commit64e774876f2c689583d31f8f67bd696ba9a9d1a7 (patch)
tree78c7bc70af839c4dae395aa09039634e3fe3cd67 /pressure_control/firmware
parent2aff70cc25aaea697a29c746677c2e3d68b65b41 (diff)
downloadcnc-64e774876f2c689583d31f8f67bd696ba9a9d1a7.tar.xz
cnc-64e774876f2c689583d31f8f67bd696ba9a9d1a7.zip
pressure_control: Don't allow changing parameters on disabled device
Signed-off-by: Michael Buesch <mb@bu3sch.de>
Diffstat (limited to 'pressure_control/firmware')
-rw-r--r--pressure_control/firmware/main.c5
-rw-r--r--pressure_control/firmware/main.h1
-rw-r--r--pressure_control/firmware/remote.c20
3 files changed, 26 insertions, 0 deletions
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) {
bues.ch cgit interface