Problem Description
One of my task(task0) uses:
xStreamBufferReceive(xStream, &buf, 1, portMAX_DELAY);
to block indefinitely until new serial data arrives.
Meanwhile, an interrupt (ISR0
) uses:
xStreamBufferSendFromISR(xStream, p, len, NULL);
to send incoming serial data into the stream buffer.
However, after running for a certain period of time, I observed that task0
enters the Suspended state and never resumes, even though data continues to arrive.
Debug Content
In a separate task (task1
), I periodically call eTaskGetState()
to monitor the state of task0
. Under normal conditions, it reports eBlocked
, as expected. However, after the issue occurs, the task unexpectedly switches to eSuspended
and stays there permanently.
In ISR0
, I also check the stream buffer status using xStreamBufferBytesAvailable()
. Normally, the available byte count remains near zero because task0
reads data as it arrives. But once the problem occurs, the byte count keeps increasing until the stream is full. Note that ISR0
is triggered every few seconds and typically sends a few to a few dozen bytes each time.
Relevant FreeRTOSConfig.h Settings
#define INCLUDE_vTaskPrioritySet 1
#define INCLUDE_uxTaskPriorityGet 1
#define INCLUDE_vTaskDelete 1
#define INCLUDE_vTaskCleanUpResources 0
#define INCLUDE_vTaskSuspend 1
#define INCLUDE_vTaskDelayUntil 1
#define INCLUDE_vTaskDelay 1
#define INCLUDE_xTaskGetSchedulerState 1
#define INCLUDE_xTimerPendFunctionCall 1
#define INCLUDE_xQueueGetMutexHolder 1
#define INCLUDE_uxTaskGetStackHighWaterMark 1
#define INCLUDE_xTaskGetCurrentTaskHandle 1
#define INCLUDE_eTaskGetState 1
My Questions
- Has anyone encountered a situation where
xStreamBufferReceive(..., portMAX_DELAY)
never returns, even though data is being sent viaxStreamBufferSendFromISR()
? - What are the possible causes that could lead to the task moving from Blocked to Suspended without an explicit call to
vTaskSuspend()
? - What debugging methods would you recommend to investigate why the task is not being returned to the Ready state when data is available in the stream buffer?
Any guidance or insight would be greatly appreciated!