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

Event Callbacks Contain Unusable Parameters #143

Open
maxxboehme opened this issue Feb 8, 2022 · 3 comments
Open

Event Callbacks Contain Unusable Parameters #143

maxxboehme opened this issue Feb 8, 2022 · 3 comments
Assignees

Comments

@maxxboehme
Copy link
Collaborator

maxxboehme commented Feb 8, 2022

Original discussion on NI's forms.

DAQmx's event callback signatures include a Task ID and callbackData parameters even though there currently isn't a way to get a task object from a Task ID or be able to pass in user provided callbackData (register_every_n_samples_acquired_into_buffer_event passes None as the data.)

Having to specify these to parameters in the signature even though they are not usable is confusing the users.

These are 2 ideas on how to improve this.

  • Provide a way to pass in user provided data and get a task object from a Task ID.
  • Make the callback signature that users provide not have to specify those and wrap their callback in an internal one to the event register functions.
    • Might also be able to pass reference to task object that referenced it by passing self from internal_callback wrapper.
@maxxboehme maxxboehme changed the title Event callbacks are clunky Event Callbacks Contain Unusable Parameters Feb 8, 2022
@maxxboehme maxxboehme added the api label Feb 24, 2022
@joshSonera
Copy link

Is there really no way to pass user variables in for callback_data? That would be unfortunate.

@maxxboehme
Copy link
Collaborator Author

You can reference variables in the callback by creating an inner function (also called nested function) and Python allows you to reference variables from the enclosing function. You can see this being done in the every_n_samples_event.py example with the "callback" inner function referencing "samples" from the enclosed function.

@joshSonera
Copy link

Ahh I see, thank you very much!

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

No branches or pull requests

3 participants