diff options
author | Kevin O'Connor <kevin@koconnor.net> | 2017-06-16 13:57:11 -0400 |
---|---|---|
committer | Kevin O'Connor <kevin@koconnor.net> | 2017-06-29 13:33:58 -0400 |
commit | 44f2a2a9521ee295acbe44cf0d2a5dedd179fd37 (patch) | |
tree | 6bbfa1dba60ab005667c8334cc8cfdf6fab90bea /src/command.h | |
parent | 292453d3060abf81e13aeb7bc7d76d3c3709da79 (diff) | |
download | kutter-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.h')
-rw-r--r-- | src/command.h | 22 |
1 files changed, 13 insertions, 9 deletions
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 <stdarg.h> // va_list #include <stddef.h> #include <stdint.h> // 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[]; |