eclipse / mraa

Linux Library for low speed IO Communication in C with bindings for C++, Python, Node.js & Java. Supports generic io platforms, as well as Intel Edison, Intel Joule, Raspberry Pi and many more.
http://mraa.io
MIT License
1.36k stars 613 forks source link

Explicit object cleanup for garbage-collecting languages #1044

Closed jan-kiszka closed 3 years ago

jan-kiszka commented 3 years ago

Looking for something put into the close handler of https://github.com/node-red/node-red-nodes/blob/master/hardware/intel/mraa-gpio-dout.js#L31. That shall stops that mraa nodes keep GPIOs open until the JS garbage collector finally decides to clean up. But I suppose there is nothing in the mraa API so far, is there?

And this issue should not be limited to GPIOs, correct?

How about other languages that do not support some "delete object"`, thus controlled invocation of the destructors?

tingleby commented 3 years ago

So the language bindings are based on the CPP headers, when an object is destroyed, https://iotdk.intel.com/docs/master/mraa/gpio_8h.html#ac18f83fc915a25f06513dbd8ea0d4bad should be called. But yeah, I think maybe extra care needs to be taken in some environments.

jan-kiszka commented 3 years ago

We are currently trying https://github.com/siemens/meta-iot2050/commit/633a77eaa49bc87d1e33c4b96f3023ca2465c115#diff-efeb60c6a49d15c96eeef5e011f89bfd8f22df93a33ecdb012407d7b5a609e7a (plus https://github.com/siemens/meta-iot2050/commit/37ca6cfd9c652c25070debb0a058df2d3ddaa3e3#diff-eec4e82a3f9112c200a581affc24bc44fa75f056ed893b3c9cda6fae2171ce28) on a customer setup, hoping that this fixes the sporadic issues seen there. If that works, I'll send an PR for that mraa patch (eventually also for the board, but that needs more work).