Closed vaishnavachath closed 6 years ago
Note that I'm still of the opinion that for pinmux and gpio functions the use of callbacks should be avoided and explicitly deprecated, hence I don't endorse further complicating the code by supporting new-style callbacks for those functions.
Only functions which can actually block should support callbacks.
All functions need callbacks to be supported via the RPC mechanism. The math functions are expected to be done locally, so they don't need callbacks. Ideally, bonescript.js would be updated to include the math functions locally.
I do support sending out deprecation messages and updating the bone101 demo code to use new callback styles that are consistent... I just want to continue to test against the old code for a while and work with the old-style for a while to give folks a chance to migrate.
Ew, bonescript is also used via rpc from the browser instead of just locally as a nodejs library? That sounds... ehm... fast, efficient, and secure? ;-)
Before I merge, please:
The BoneScript RPC mechanism was meant as a hardware development tutorial system. Totally insecure today, but this project should eventually get it a very small amount of authentication security. From an absolute-newb perspective, I believe it adds some value to learn both the API as well as general things about hardware interfacing. Further, the huge library of web-based visualization tools provides a very rapid prototyping environment.
https://makezine.com/2014/01/14/5-easy-javascript-tricks-you-can-teach-your-beaglebone/
I will work on the suggestions and make the neccessary changes soon
Here's some code to test the RPC server. This should also provide some test framework for adding the verification.
https://github.com/jadonk/bonescript/commit/47454f7046ce573970789193d1b5e5561b33673f
I have made the recommended changes, can you please review it.
support both styles of callback based on the callback arguments length (as suggested by @mvduin) https://github.com/beagleboard/bonescript/issues/38
test script based on bone101 examples : https://gist.github.com/vaishnav98/bda1c2e0355e584830e8c6daf8730f93