aboutsummaryrefslogtreecommitdiffstats
path: root/src/command.c
diff options
context:
space:
mode:
authorKevin O'Connor <kevin@koconnor.net>2017-06-16 13:57:11 -0400
committerKevin O'Connor <kevin@koconnor.net>2017-06-29 13:33:58 -0400
commit44f2a2a9521ee295acbe44cf0d2a5dedd179fd37 (patch)
tree6bbfa1dba60ab005667c8334cc8cfdf6fab90bea /src/command.c
parent292453d3060abf81e13aeb7bc7d76d3c3709da79 (diff)
downloadkutter-44f2a2a9521ee295acbe44cf0d2a5dedd179fd37.tar.gz
kutter-44f2a2a9521ee295acbe44cf0d2a5dedd179fd37.tar.xz
kutter-44f2a2a9521ee295acbe44cf0d2a5dedd179fd37.zip
command: Move low-level sendf transmission into board code
Export a new console_sendf() function from the board code instead of console_get_output() and console_push_output(). This enables more flexibility in how the board specific code produces output. Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
Diffstat (limited to 'src/command.c')
-rw-r--r--src/command.c16
1 files changed, 5 insertions, 11 deletions
diff --git a/src/command.c b/src/command.c
index 709e75c4..62db0bfd 100644
--- a/src/command.c
+++ b/src/command.c
@@ -105,7 +105,7 @@ error:
}
// Encode a message
-static uint8_t
+uint8_t
command_encodef(char *buf, uint8_t buf_len
, const struct command_encoder *ce, va_list args)
{
@@ -169,7 +169,7 @@ error:
}
// Add header and trailer bytes to a message block
-static void
+void
command_add_frame(char *buf, uint8_t msglen)
{
buf[MESSAGE_POS_LEN] = msglen;
@@ -184,7 +184,7 @@ static uint8_t in_sendf;
// Encode and transmit a "response" message
void
-_sendf(const struct command_encoder *ce, ...)
+command_sendf(const struct command_encoder *ce, ...)
{
if (readb(&in_sendf))
// This sendf call was made from an irq handler while the main
@@ -192,17 +192,11 @@ _sendf(const struct command_encoder *ce, ...)
return;
writeb(&in_sendf, 1);
- uint8_t buf_len = READP(ce->max_size);
- char *buf = console_get_output(buf_len);
- if (!buf)
- goto done;
va_list args;
va_start(args, ce);
- uint8_t msglen = command_encodef(buf, buf_len, ce, args);
+ console_sendf(ce, args);
va_end(args);
- command_add_frame(buf, msglen);
- console_push_output(msglen);
-done:
+
writeb(&in_sendf, 0);
return;
}