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

Python 3 gpio isr method's "args" do not work #341

Open
hansmosh opened this issue Oct 27, 2015 · 2 comments
Open

Python 3 gpio isr method's "args" do not work #341

hansmosh opened this issue Oct 27, 2015 · 2 comments

Comments

@hansmosh
Copy link
Contributor

I'm using the isr functionality with python 3 and the "args" are not being passed to my callback function properly.
http://iotdk.intel.com/docs/master/mraa/python/mraa.html#mraa.Gpio.isr

Using the example here:
https://github.com/intel-iot-devkit/mraa/blob/master/examples/python/hello_isr.py
If you print(args) inside of test then it is just a random integer. I want to be able to pass something and then actually use it.

I have tried modifying gpio.c line 243 with some success. What do you think?

-            arglist = Py_BuildValue("(i)", dev->isr_args);
+            arglist = Py_BuildValue("(O)", dev->isr_args);

This works with simple things like passing an integer, but I would love to pass self and then have my callback function be a method in my class.

@arfoll
Copy link
Contributor

arfoll commented Oct 28, 2015

That would actually be better - do you want to do a PR for this or do you want me to do it?

Passing self should be do-able with this method, or maybe something very close, I'd love to investigate but don't have the time. If someone is willing to spend time doing this I'd be happy to include this.

@hansmosh
Copy link
Contributor Author

Copying this over from #343. It mostly fixes this issue but you still can't pass self as args.

class Gpio():

  def __init__(self):
    ...
    pin.isr(mraa.EDGE_BOTH, callback, self)

  def callback(self):
    print("we did it")

Note: someone can create a new issue for this if they feel it is appropriate to close this one out.

pylbert pushed a commit to pylbert/mraa that referenced this issue Feb 12, 2018
defect eclipse#341

Signed-off-by: Jon Trulson <jtrulson@ics.com>
Signed-off-by: Mihai Tudor Panu <mihai.tudor.panu@intel.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment