summaryrefslogtreecommitdiffstats
path: root/pressure_control/firmware
diff options
context:
space:
mode:
authorMichael Buesch <mb@bu3sch.de>2009-11-22 14:34:06 +0100
committerMichael Buesch <mb@bu3sch.de>2009-11-22 14:34:06 +0100
commitf6e560e764e4315c8d50ce26b4894da680efb43a (patch)
tree17b2f225f25a1791b6fbf47e4a17e7f2d459d57d /pressure_control/firmware
parent9c025d4fbc0630c2caf12caf67770ad62b0843b7 (diff)
downloadcnc-f6e560e764e4315c8d50ce26b4894da680efb43a.tar.xz
cnc-f6e560e764e4315c8d50ce26b4894da680efb43a.zip
pressure_control: Reduce message size
Signed-off-by: Michael Buesch <mb@bu3sch.de>
Diffstat (limited to 'pressure_control/firmware')
-rw-r--r--pressure_control/firmware/remote.c6
-rw-r--r--pressure_control/firmware/remote.h17
2 files changed, 11 insertions, 12 deletions
diff --git a/pressure_control/firmware/remote.c b/pressure_control/firmware/remote.c
index 1945ef4..7863b55 100644
--- a/pressure_control/firmware/remote.c
+++ b/pressure_control/firmware/remote.c
@@ -111,7 +111,7 @@ static void handle_received_message(void)
memset(&reply, 0, sizeof(reply));
- switch (rx_msg.id) {
+ switch (rx_msg.id & MSG_ID_MASK) {
case MSG_PING:
reply.id = MSG_PONG;
send_message(&reply);
@@ -256,7 +256,7 @@ static void handle_received_message(void)
}
out:
- if (rx_msg.flags & (1 << MSG_FLAG_REQ_ERRCODE)) {
+ if (rx_msg.id & MSG_FLAG_REQ_ERRCODE) {
memset(&reply, 0, sizeof(reply));
reply.id = MSG_ERROR;
reply.error.code = err;
@@ -460,7 +460,7 @@ static void usart_init(void)
void remote_init(void)
{
/* The remote tool depends on the exact size (and layout). */
- BUILD_BUG_ON(sizeof(struct remote_message) != 12);
+ BUILD_BUG_ON(sizeof(struct remote_message) != 7);
usart_init();
}
diff --git a/pressure_control/firmware/remote.h b/pressure_control/firmware/remote.h
index c587782..944dc43 100644
--- a/pressure_control/firmware/remote.h
+++ b/pressure_control/firmware/remote.h
@@ -27,6 +27,10 @@ enum remote_message_id {
MSG_RESTARTED,
MSG_SHUTDOWN,
MSG_TURNON,
+
+
+ MSG_ID_MASK = 0x7F,
+ MSG_FLAG_REQ_ERRCODE = 0x80,
};
enum remote_message_error {
@@ -37,24 +41,19 @@ enum remote_message_error {
MSG_ERR_INVAL, /* Invalid argument */
};
-enum remote_message_flags {
- MSG_FLAG_REQ_ERRCODE = 0,
-};
-
enum remote_message_config_flags {
CFG_FLAG_AUTOADJUST_ENABLE = 0,
};
struct remote_message {
uint8_t id;
- uint8_t flags;
union {
struct {
uint8_t code;
} __attribute__((packed)) error;
struct {
- char str[8];
+ char str[4];
} __attribute__((packed)) logmessage;
struct {
uint16_t mbar[2];
@@ -64,11 +63,11 @@ struct remote_message {
uint16_t mbar;
} __attribute__((packed)) setpressure;
struct {
- uint32_t flags[2];
+ uint8_t flags[2];
} __attribute__((packed)) config;
struct {
uint8_t island; /* Valve island */
- uint32_t flags;
+ uint8_t flags;
} __attribute__((packed)) setconfig;
struct {
uint8_t island; /* Valve island */
@@ -76,7 +75,7 @@ struct remote_message {
uint8_t state;
} __attribute__((packed)) valve;
- uint8_t __padding[8];
+ uint8_t __padding[4];
} __attribute__((packed));
uint16_t crc;
bues.ch cgit interface