Page 1 of 1

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

Posted: Wed Jul 01, 2020 10:24 pm
by azz-zza
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);
 

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

Posted: Thu Jul 02, 2020 2:18 am
by boarchuz

Code: Select all

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

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

Posted: Thu Jul 02, 2020 4:44 am
by azz-zza
ohhh.. (facepalm)....

Thank you so much.

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

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

Posted: Thu Jul 02, 2020 9:03 am
by ESP_Sprite
Use NULL (any other value will technically work as well, as your task ignores it anyway) instead of the parameter.

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

Posted: Thu Jul 02, 2020 12:46 pm
by azz-zza
Thank you very much. Works perfectly.
The issue was not in the the xTaskCreate, but rather that callback procedure should have parameter.