You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Although there is no kernel interface for completion events, we can still poll the state with an interval timer. It would be relatively easy to register a setInterval callback that polls the necessary properties and resolves promises as needed. The three big considerations are:
It should use one universal timer which handles any and all pending promises
The timer should only be running when needed
Any promise library that is used must work in the version of Node that can run on the EV3
The text was updated successfully, but these errors were encountered:
I have decided to put this on hold until we have a real way of receiving event notifications from the kernel. To make a generic version of this API work, every motor start call would need to initiate a polling apparatus just in case the user decided to .then() on the promise. That's just too much overhead for the embedded processor to handle.
For now, I have implemented a polling system that lets the user register a predicate and callback on any generic Device instance. This API can be used if events are required.
@WasabiFan, how can I use the polling system you refer? I can't seem to find the corresponding commit. How can I register the predicate and specify the callback? Thanks.
These changes are on the develop branch and have been released in a beta release. If you haven't already installed it, you can do so by running (command untested but should work):
npm install ev3dev-lang@beta
I published this release as a beta because the documentation generator I use was having problems; this has since been resolved, so I plan to publish a full release and then update it for the most recent kernel soon. This version of the library supports the -10-ev3dev kernel. The newest kernel, -11-ev3dev, is not yet supported (sorry about that!) but it was only released a few days ago.
The diff of the addition of the polling feature can be found here. Primarily, the functions that you are looking for are registerEventCallback and registerEventPromise; you can look at their signatures in the source code to see what you need to pass them. I also have an example of the callback-based version of the function here. Note that, to use the promise-based version, you need to install bluebird from npm.
Although there is no kernel interface for completion events, we can still poll the state with an interval timer. It would be relatively easy to register a
setInterval
callback that polls the necessary properties and resolves promises as needed. The three big considerations are:The text was updated successfully, but these errors were encountered: