Compilation error when using add_event_detect()
mbaenfer opened this issue · 2 comments
Hi,
I'm trying to use this library on Jetson Xavier with JetPack 4.6 and ROS-Melodic. It works fine, but...
When I add the function add_event_detection()
to my code I always get compilation errors. Even with your example "button_interrupt.cpp".
So I made a new small test code:
#include <iostream>
#include <string>
#include <JetsonGPIO.h>
#include <signal.h>
bool shutdown = false;
void signalHandler(int s)
{
shutdown = true;
}
void callback_fn(const std::string& channel)
{
std::cout << "Callback called from channel " << channel<< std::endl;
}
int main()
{
signal(SIGINT, signalHandler);
GPIO::setmode(GPIO::BOARD);
GPIO::setup(12, GPIO::IN);
GPIO::add_event_detect(12, GPIO::RISING, callback_fn); // also tried GPIO::Edge::RISING
while(!shutdown)
{
//
}
GPIO::remove_event_detect(12);
GPIO::cleanup();
return 0;
}
When I remove add_event_detection(...)
I can compile and run the program without errors. Here is a screenshot of the compilation error message:
Does anyone know how to fix this?
Greetings
Marcel
From your error:
static_assert(... "Callback return type: void, argument type: int");
The callback argument type changed in the latest version (1.2.0).
(old version: int, latest version: const std::string&)
I'm assuming that you installed an old version, and trying the new example code.
Could you re-install the library and try it agian?
Yeah, thank you! That was the problem.
I was using Version v1.0.1, installed it some weeks ago. Now updated to v1.2.0 I can run and compile my code.
Greetings
Marcel