I am using multi threading to execute multiple tasks which are available in the queue one by one. After one task ends, I execute another task but while executing the second task in queue, I am facing error.
E (18470) FreeRTOS: FreeRTOS Task "taskTwo" should not return, Aborting now!
Here is my code,
QueueHandle_t priorityTwoQue;
TaskHandle_t thTwo;
void receiveTaskDataFromSomeFunction() {
dataholder = (struct DataHolder *)malloc(sizeof(struct DataHolder));
extractData(jsonBuffer, dataholder);
jsonBuffer.clear();
SerialDebug.print("Requst Sending To Que");
xQueueSend(priorityTwoQue, &dataholder, portMAX_DELAY);
processQueue();
}
void processQueue() {
delay(100);
SerialDebug.println("Creating Task Prio 2");
xTaskCreate(taskPriorityTwo, "TaskTwo", 5000, NULL, 2, &thTwo);
}
void taskPriorityTwo(void * paramter) {
SerialDebug.println("Task Initiated");
threadTask(priorityTwoQue, "task2");
vTaskDelete(thTwo);
}
void threadTask(QueueHandle_t priorityQue, String taskName) {
struct DataHolder *taskdataholder;
xQueueReceive(priorityQue, &taskdataholder, portMAX_DELAY);
SerialDebug.print("Executing Task");
executeHttpRequest(taskdataholder);
requestInProgress = false;
processQueue();
}
In the above code receiveTaskDataFromSomeFunction() is called whenever new task request is received, how ever in my case 4 requests are received one by one with an interval of 1 second. Hence i am putting them into the queue. Each request is executed as an http request which takes 5 seconds to compelete.
This code executes the first request without any issue but on executing the second request i get the error which i have mentioned above.
My question is how can i resolve this issue of executing the tasks which are available in queue one by one.