xTaskCreate: invalid conversion from 'void (*)()' to 'TaskFunction_t {aka void (*)(void*)}'

azz-zza
Posts: 45
Joined: Tue Sep 17, 2019 2:58 am

xTaskCreate: invalid conversion from 'void (*)()' to 'TaskFunction_t {aka void (*)(void*)}'

Postby azz-zza » Wed Jul 01, 2020 10:24 pm

Hello,
i can not figure out what am i doing incorrectly here. Please advise.

Code: Select all

void publish_data() {
 ....
}


void setup () {
....
TaskHandle_t xHandle = NULL;
BaseType_t  xReturned = xTaskCreate(&publish_data, (const char*) "Task", 4048, 	(void*)	 1, NULL, &xHandle);
.....

src/main.cpp: In function 'void setup()':
src/main.cpp:125:109: error: invalid conversion from 'void (*)()' to 'TaskFunction_t {aka void (*)(void*)}' [-fpermissive]
   BaseType_t  xReturned = xTaskCreate(&publish_data, (const char*) "Task", 4048,  (void*)  1, NULL, &xHandle);
 

boarchuz
Posts: 606
Joined: Tue Aug 21, 2018 5:28 am

Re: xTaskCreate: invalid conversion from 'void (*)()' to 'TaskFunction_t {aka void (*)(void*)}'

Postby boarchuz » Thu Jul 02, 2020 2:18 am

Code: Select all

void publish_data(void *you_need_this) {
 ....
}

azz-zza
Posts: 45
Joined: Tue Sep 17, 2019 2:58 am

Re: xTaskCreate: invalid conversion from 'void (*)()' to 'TaskFunction_t {aka void (*)(void*)}'

Postby azz-zza » Thu Jul 02, 2020 4:44 am

ohhh.. (facepalm)....

Thank you so much.

and how do i call the createTask if i do not need any params passed to the procedure?

ESP_Sprite
Posts: 9739
Joined: Thu Nov 26, 2015 4:08 am

Re: xTaskCreate: invalid conversion from 'void (*)()' to 'TaskFunction_t {aka void (*)(void*)}'

Postby ESP_Sprite » Thu Jul 02, 2020 9:03 am

Use NULL (any other value will technically work as well, as your task ignores it anyway) instead of the parameter.

azz-zza
Posts: 45
Joined: Tue Sep 17, 2019 2:58 am

Re: xTaskCreate: invalid conversion from 'void (*)()' to 'TaskFunction_t {aka void (*)(void*)}'

Postby azz-zza » Thu Jul 02, 2020 12:46 pm

Thank you very much. Works perfectly.
The issue was not in the the xTaskCreate, but rather that callback procedure should have parameter.

Who is online

Users browsing this forum: No registered users and 98 guests