From 44f2a2a9521ee295acbe44cf0d2a5dedd179fd37 Mon Sep 17 00:00:00 2001 From: Kevin O'Connor Date: Fri, 16 Jun 2017 13:57:11 -0400 Subject: 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 --- src/command.h | 22 +++++++++++++--------- 1 file changed, 13 insertions(+), 9 deletions(-) (limited to 'src/command.h') diff --git a/src/command.h b/src/command.h index f2d90ee4..148f47be 100644 --- a/src/command.h +++ b/src/command.h @@ -1,6 +1,7 @@ #ifndef __COMMAND_H #define __COMMAND_H +#include // va_list #include #include // uint8_t #include "ctr.h" // DECL_CTR @@ -20,11 +21,11 @@ // Send an output message (and declare a static message type for it) #define output(FMT, args...) \ - _sendf(_DECL_OUTPUT(FMT) , ##args ) + command_sendf(_DECL_OUTPUT(FMT) , ##args ) // Declare a message type and transmit it. #define sendf(FMT, args...) \ - _sendf(_DECL_ENCODER(FMT) , ##args ) + command_sendf(_DECL_ENCODER(FMT) , ##args ) // Shut down the machine (also declares a static string to transmit) #define shutdown(msg) \ @@ -32,13 +33,6 @@ #define try_shutdown(msg) \ sched_try_shutdown(_DECL_STATIC_STR(msg)) -// command.c -struct command_encoder; -void _sendf(const struct command_encoder *ce, ...); -int8_t command_find_block(char *buf, uint8_t buf_len, uint8_t *pop_count); -void command_dispatch(char *buf, uint8_t msglen); - -// out/compile_time_request.c (auto generated file) struct command_encoder { uint8_t msg_id, max_size, num_params; const uint8_t *param_types; @@ -52,6 +46,16 @@ enum { PT_uint32, PT_int32, PT_uint16, PT_int16, PT_byte, PT_string, PT_progmem_buffer, PT_buffer, }; + +// command.c +uint8_t command_encodef(char *buf, uint8_t buf_len + , const struct command_encoder *ce, va_list args); +void command_sendf(const struct command_encoder *ce, ...); +void command_add_frame(char *buf, uint8_t msglen); +int8_t command_find_block(char *buf, uint8_t buf_len, uint8_t *pop_count); +void command_dispatch(char *buf, uint8_t msglen); + +// out/compile_time_request.c (auto generated file) extern const struct command_parser command_index[]; extern const uint8_t command_index_size; extern const uint8_t command_identify_data[]; -- cgit v1.2.3-70-g09d2