chipKIT® Development Platform

Inspired by Arduino™

calling createTask in a library

Created Thu, 04 Feb 2016 15:51:00 +0000 by GastonLagaffe


GastonLagaffe

Thu, 04 Feb 2016 15:51:00 +0000

Salut,

can you point me to an example on how to call createTask in a library? When I define a task within the library it is declared like

void MyClass::myisr(int id, void * tptr) {}

I would then call it in the constructor this way

task_id = createTask(myisr, 200, TASK_ENABLE, &task_var);

but that gets me an error code:

argument of type 'void (MyClass::)(int, void*)' does not match 'void (*)(int, void*)'

I may well overlook something. Any hint is welcome

Ciao, Mathias


majenko

Thu, 04 Feb 2016 16:03:38 +0000

This is a common problem in C++ - how do you pass a member function to something that doesn't expect a member function.

Basically, you can't. It's all to do with how c++ handles member functions.

Instead you either have to wrap the call to your member function in a normal function, or use a static member function which is seen as just a normal function.

Sent from my SM-T555 using Tapatalk


GastonLagaffe

Thu, 04 Feb 2016 17:02:58 +0000

Salut Matt,

will test, but for the moment pic32-tools seems to be broken: I got an update today and it stops installing at 16% [Update] fixed pic32-tools issue by unacking the deb package by hand (Total Commander plugin under windows)[/Update]

Ciao, Mathias