aboutsummaryrefslogtreecommitdiffstats
path: root/src/pru/main.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/pru/main.c')
-rw-r--r--src/pru/main.c17
1 files changed, 15 insertions, 2 deletions
diff --git a/src/pru/main.c b/src/pru/main.c
index cebcaa26..d906b1ad 100644
--- a/src/pru/main.c
+++ b/src/pru/main.c
@@ -131,7 +131,7 @@ console_task(void)
DECL_TASK(console_task);
// Return an output buffer that the caller may fill with transmit messages
-char *
+static char *
console_get_output(uint8_t len)
{
if (len > sizeof(SHARED_MEM->send_data[0].data))
@@ -144,7 +144,7 @@ console_get_output(uint8_t len)
}
// Accept the given number of bytes added to the transmit buffer
-void
+static void
console_push_output(uint8_t len)
{
uint32_t send_push_pos = SHARED_MEM->send_push_pos;
@@ -154,6 +154,19 @@ console_push_output(uint8_t len)
(send_push_pos + 1) % ARRAY_SIZE(SHARED_MEM->send_data));
}
+// Encode and transmit a "response" message
+void
+console_sendf(const struct command_encoder *ce, va_list args)
+{
+ uint8_t buf_len = ce->max_size;
+ char *buf = console_get_output(buf_len);
+ if (!buf)
+ return;
+ uint8_t msglen = command_encodef(buf, buf_len, ce, args);
+ command_add_frame(buf, msglen);
+ console_push_output(msglen);
+}
+
/****************************************************************
* Allocator