jadonk / bonescript

Scripting tools for BeagleBone and PocketBeagle
http://beagleboard.org
MIT License
514 stars 158 forks source link

Support nodestyle callbacks #174

Closed vaishnavachath closed 6 years ago

vaishnavachath commented 6 years ago

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

coveralls commented 6 years ago

Coverage Status

Coverage increased (+8.4%) to 45.789% when pulling 0e15de4069de6ee9ca073c1bdd0b8498209df3f8 on vaishnav98:master into 47454f7046ce573970789193d1b5e5561b33673f on jadonk:master.

mvduin commented 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.

jadonk commented 6 years ago

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.

mvduin commented 6 years ago

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? ;-)

jadonk commented 6 years ago

Before I merge, please:

jadonk commented 6 years ago

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/

vaishnavachath commented 6 years ago

I will work on the suggestions and make the neccessary changes soon

jadonk commented 6 years ago

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

vaishnavachath commented 6 years ago

I have made the recommended changes, can you please review it.