Closed xjjak closed 7 months ago
Look into EventGroups. This seems to be the proper way to handle events through flags.
This could indeed be fixed by using an xEventGroup
with the bit at index 0
indicating whether the buffers should be reset or not.
void task_fifo_reset(void *flag) {
const TickType_t xTicksToWait = 100 / portTICK_PERIOD_MS;
for(;;){
if (xEventGroupWaitBits(FifoResetEventGroup, BIT_0, pdFALSE, pdTRUE, xTicksToWait) == pdPASS){
reset_all_bufs();
xEventGroupClearBits(FifoResetEventGroup, BIT_0);
} else {
Serial.println("Something went wrong waiting for events");
}
}
}
The task code now looks like this and utilizes xEventGroupWaitBits
to wait for the 0-bit to change, with a timeout of 100ms, which may need more consideration in the future.
Accessing the
void*
parameters in the task callback works:Setting the flag back to false however doesn't work as expected as
task_reset_fifos_flag
remains true.*(bool*)flag = false;
needs to be fixed.