Physical computing library for embedded Linux
BoneScript is a node.js library for physical computing on embedded Linux, starting with support for BeagleBone.
Information on the language is available at http://nodejs.org.
To check the version and to see if BoneScript is in your path, try running:
node -pe "require('bonescript').getPlatform().bonescript"
Additional documentation is available at http://beagleboard.org/bonescript.
BoneScript comes installed on your BeagleBone. To update to the latest revision or install it on another distribution, use 'npm':
TERM=none npm install -g bonescript
opkg updateopkg install python-misc python-modules
Debian and Ubuntu prerequisites:
sudo apt-get install -y build-essential g++ python-setuptools python2.7-devwget -c https://raw.github.com/RobertCNelson/tools/master/pkgs/dtc.shchmod +x dtc.sh./dtc.sh
Some steps to consider:
cp bonescript/etc/default/node /etc/default/nodecp bonescript/etc/profile.d/node.sh /etc/profile.d/node.shcp bonescript/systemd/\* /lib/systemd/systemsystemctl enable bonescript.socketsystemctl enable bonescript-autorun.service
To have your applications launch on startup, simply drop them into the /var/lib/cloud9/autorun folder. Moving them out of that folder will kill the processes. You are expected to only drop in already bug-free apps into this folder as there isn't a good way to perform debug on them.
There's still a lot of development going on, so be sure to check back on a frequent basis. Many of the fancier peripherals aren't yet supported except through performing file I/O.
For a Bonescript application, you must currently manually 'require' the bonescript library. Functions are then referenced through the object provided back from require.
Here's an example:
var b = require'bonescript';bpinMode'P8_12' bINPUT;bpinMode'P8_13' bOUTPUT;setIntervalcopyInputToOutput 100;bdigitalRead'P8_12' writeToOutput;bdigitalWrite'P8_13' xvalue;
The 'P8_12' and 'P8_13' are pin names on the board and the above example would copy the input value at P8_12 to the output P8_13 every 100 ms.
When a callback is provided, the functions will behave asynchronously. Without a callback provided, the functions will synchronize and complete before returning.