Arduino-CommandParser icon indicating copy to clipboard operation
Arduino-CommandParser copied to clipboard

Using class member functions as command callback

Open eg321 opened this issue 4 years ago • 0 comments

Hi,

it looks like there is no easy way to "registerCommand" which should call member function of same class.

I've tried in this way: commandParser.registerCommand("help", "", &cmd_displayHelp);

where "cmd_displayHelp" is member of same class.

It fails compilation with error: ISO C++ forbids taking the address of an unqualified or parenthesized non- static member function to form a pointer to member function. Say '&SerialController::cmd_displayHelp' [-fpermissive] commandParser.registerCommand("help", "", &cmd_displayHelp);

Had I forgot something or there is no way to do that with current syntax of "registerCommand"?

Thanks.

eg321 avatar Aug 03 '20 04:08 eg321