command: Support 2-byte message ids
Allow command ids, response ids, and output ids to be either 1 or 2 bytes long. This increases the total number of message types from 128 to 16384. Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
This commit is contained in:
@@ -57,11 +57,13 @@
|
||||
#define MESSAGE_SYNC 0x7E
|
||||
|
||||
struct command_encoder {
|
||||
uint8_t msg_id, max_size, num_params;
|
||||
uint16_t encoded_msgid;
|
||||
uint8_t max_size, num_params;
|
||||
const uint8_t *param_types;
|
||||
};
|
||||
struct command_parser {
|
||||
uint8_t msg_id, num_args, flags, num_params;
|
||||
uint16_t encoded_msgid;
|
||||
uint8_t num_args, flags, num_params;
|
||||
const uint8_t *param_types;
|
||||
void (*func)(uint32_t *args);
|
||||
};
|
||||
@@ -72,6 +74,7 @@ enum {
|
||||
|
||||
// command.c
|
||||
void *command_decode_ptr(uint32_t v);
|
||||
uint_fast16_t command_parse_msgid(uint8_t **pp);
|
||||
uint8_t *command_parsef(uint8_t *p, uint8_t *maxend
|
||||
, const struct command_parser *cp, uint32_t *args);
|
||||
uint_fast8_t command_encode_and_frame(
|
||||
@@ -86,7 +89,7 @@ int_fast8_t command_find_and_dispatch(uint8_t *buf, uint_fast8_t buf_len
|
||||
|
||||
// out/compile_time_request.c (auto generated file)
|
||||
extern const struct command_parser command_index[];
|
||||
extern const uint8_t command_index_size;
|
||||
extern const uint16_t command_index_size;
|
||||
extern const uint8_t command_identify_data[];
|
||||
extern const uint32_t command_identify_size;
|
||||
const struct command_encoder *ctr_lookup_encoder(const char *str);
|
||||
|
||||
Reference in New Issue
Block a user