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

Cannot use add_event_detect #51

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

Cannot use add_event_detect #51

DanielGM279 opened this issue Feb 10, 2022 · 2 comments

Comments

@DanielGM279
Copy link

DanielGM279 commented Feb 10, 2022

Hello, I'm trying to use the add_event_detect with a callback function defined as follows:

void cb_fcn(const std::string& channel){
    cout << "Inside callback" << endl;
}

my_class::my_class(int new_pinPWMA, int new_Freq)
    :p(createPWM(new_pinPWMA, new_Freq))
{
    p.start(0);
    pulse = 0;
    add_event_detect(pinEncA,RISING, cb_fcn);
}

However I get the following error when I run the code:

terminate called after throwing an instance of 'std::runtime_error'
what(): [Exception] Channel 127 is invalid (catched from: GPIO::add_event_detect())

I followed the interrupt sample but can get my implementation to work, I hope you can help me.

Thank you for your time.

@pjueon
Copy link
Owner

pjueon commented Feb 10, 2022

Could you tell us these information?

  • your jetson model
  • the value of pinEncA in your code
  • the numbering mode you're using

@DanielGM279
Copy link
Author

Hello, I solved the problem already. Turns out the issue was with the order in which I was instantiating the object, which initiated before assigning a value to the pin number, resulting in a trash value.

Thanks for the support.

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