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:
Kevin O'Connor
2024-06-05 21:37:57 -04:00
parent 36b8831c7e
commit 589bd64ce0
4 changed files with 90 additions and 49 deletions

View File

@@ -141,7 +141,7 @@ do_dispatch(uint8_t *buf, uint32_t msglen)
uint8_t *msgend = &buf[msglen-MESSAGE_TRAILER_SIZE];
while (p < msgend) {
// Parse command
uint_fast8_t cmdid = *p++;
uint_fast16_t cmdid = command_parse_msgid(&p);
const struct command_parser *cp = &SHARED_MEM->command_index[cmdid];
if (!cmdid || cmdid >= SHARED_MEM->command_index_size
|| cp->num_args > ARRAY_SIZE(SHARED_MEM->next_command_args)) {