Flush the LUT every 30 seconds to prevent broken entires from causing incontrollable robot

This commit is contained in:
2026-03-04 04:59:21 -05:00
parent 9cd7cbac3b
commit 5f6b5cc940
2 changed files with 63 additions and 1 deletions

View File

@@ -46,7 +46,8 @@ static const uint16_t crc16_table[256] = {
#define ASYNC_QUEUE_WAIT_TICKS 100
#define SEQUENCE_NUM_MAP_MUTEX_MAX_WAIT_MS 50
#define MAX_RX_QUEUE_SIZE 100
#define CONTROL_FRAME_LUT_SIZE 15 // Maximum number of control frames cached in the receiver-side LFU LUT
#define CONTROL_FRAME_LUT_SIZE 15 // Maximum number of control frames cached in the receiver-side LFU LUT
#define LUT_FLUSH_INTERVAL_MS 30000 // Flush (invalidate) the entire control-frame LUT every 30 seconds
/**
* @brief Class to represent the Data Link Layer
@@ -223,8 +224,19 @@ class DataLinkManager{
*/
void lut_insert(uint32_t hash, const uint8_t* message, size_t message_len, const FrameHeader& header);
/**
* @brief Flush (invalidate) all entries in the control-frame LUT.
*/
void lut_flush();
/**
* @brief Periodic task that flushes the control-frame LUT every LUT_FLUSH_INTERVAL_MS milliseconds.
*/
[[noreturn]] static void lut_flush_task(void* args);
ControlFrameLutEntry control_frame_lut[CONTROL_FRAME_LUT_SIZE];
SemaphoreHandle_t control_frame_lut_mutex;
TaskHandle_t lut_flush_task_handle = NULL;
};
struct frame_scheduler_args {