Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Compilation error when using add_event_detect() #52

Closed
mbaenfer opened this issue Feb 10, 2022 · 2 comments
Closed

Compilation error when using add_event_detect() #52

mbaenfer opened this issue Feb 10, 2022 · 2 comments

Comments

@mbaenfer
Copy link

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:

compilation_error

Does anyone know how to fix this?

Greetings
Marcel

@pjueon
Copy link
Owner

pjueon commented Feb 10, 2022

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?

@mbaenfer
Copy link
Author

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants