diff --git a/board/can_definitions.h b/board/can_definitions.h index e0b075961e..2ef8c7e84b 100644 --- a/board/can_definitions.h +++ b/board/can_definitions.h @@ -14,7 +14,7 @@ typedef struct { unsigned char data[CANPACKET_DATA_SIZE_MAX]; } __attribute__((packed, aligned(4))) CANPacket_t; -#define CANPACKET_HEAD_SIZE (sizeof(CANPacket_t) - (CANPACKET_DATA_SIZE_MAX / 8)) +#define CANPACKET_HEAD_SIZE 5U #define GET_BUS(msg) ((msg)->bus) #define GET_LEN(msg) (dlc_to_len[(msg)->data_len_code]) diff --git a/board/main_comms.h b/board/main_comms.h index e8b1930a63..f715bf168b 100644 --- a/board/main_comms.h +++ b/board/main_comms.h @@ -58,9 +58,10 @@ asm_buffer can_write_overflow = {.ptr = 0U, .tail_size = 0U}; bool add_magic = true; -// read out as many CAN messages as we can fit in a max_len chunk, -// including partial messages, which will be continued in the -// beginning of the next chunk. +// for CAN read and send, we write out a buffer consisting of: +// CAN_TRANSACTION_MAGIC + (N * CANPacket_t) +// comms_can_read will output this buffer into chunks of size max_len. +this buffer is split into chunks output by the comms_can_xxx functions. int comms_can_read(uint8_t *data, uint32_t max_len) { uint32_t pos = 0U; // count of bytes written bool added_magic = false;