orangepizero wrote on Tuesday, August 01, 2017:
Hello. In this code it is not possible to print correctly the data on each task. I can not understand the reason. The output of the program is below. How do I get the HELLO_WORLD string in each of the tasks in the output?
Using the parameter transfer.
Thank you.
#include <string.h>
#include "freertos/FreeRTOS.h"
#include "freertos/task.h"
#include "freertos/event_groups.h"
#include "esp_system.h"
#include "esp_event_loop.h"
#include "esp_log.h"
#include "nvs_flash.h"
const size_t stack_size = 4096;
static void task1(void *pvParameters)
{
ESP_LOGE("TASK", "TASK CORE_1: %s", (char *)pvParameters);
vTaskDelete(NULL);
}
static void task_main(void *pvParameters)
{
char *data = (char *)pvParameters;
while(1)
{
ESP_LOGI("TASK", "TASK CORE_0: %s", data);
vTaskDelay(1000 / portTICK_RATE_MS);
xTaskCreatePinnedToCore(&task1, "task1", stack_size, (void*)&data, 2, NULL, 1);
}
vTaskDelete(NULL);
}
void app_main()
{
char data[12] = "HELLO_WORLD";
xTaskCreatePinnedToCore(&task_main, "task_main", stack_size, (void*)&data, 1, NULL, 0);
}
OUTPUT:
E (264246) TASK: TASK CORE_1: ��?
I (265246) TASK: TASK CORE_0:
E (265246) TASK: TASK CORE_1: ��?
I (266246) TASK: TASK CORE_0:
E (266246) TASK: TASK CORE_1: ��?
I (267246) TASK: TASK CORE_0:
E (267246) TASK: TASK CORE_1: ��?
I (268246) TASK: TASK CORE_0:
E (268246) TASK: TASK CORE_1: ��?
I (269246) TASK: TASK CORE_0:
E (269246) TASK: TASK CORE_1: ��?
I (270246) TASK: TASK CORE_0:
E (270246) TASK: TASK CORE_1: ��?