blob: 474398a6a6f519d5edc0012d7e14c01d1df32615 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
|
#include "protocol.h"
#ifdef __cplusplus
extern "C" {
#endif
size_t cd_cmd_sizeof(uint8_t data[CD_SERIAL_READ_BUFFER_SIZE], uint8_t data_length) {
cd_cmd_opcode_t opcode = data[0];
if (CD_CMD_HANDLERS_SIZE[opcode] > 0) return CD_CMD_HANDLERS_SIZE[opcode];
cd_s_bin *copy = cd_bin_s_alloc(data_length, data);
size_t length = (*CD_CMD_HANDLERS_SIZEOF[opcode])(copy);
free(copy);
return length;
}
#define CD_DYN_MEMBER_SIZEOF(struct_t, length_byte, trailing_type) \
sizeof(struct_t) + \
(data->bytes > length_byte ? (sizeof(trailing_type) * data->data[length_byte]) : 0)
size_t cd_cmd_response_sizeof(cd_s_bin* data) {
(void) data; // unused variable TODO: implement this
return 0;
}
#ifdef __cplusplus
}
#endif
|