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 get started, try running 'node blinkled.js' on a BeagleBone.
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
Support for other distributions is a work in progress.
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.
- attic: Stuff not to throw away, but not in a good state
- demo: Examples showing how to use the BoneScript library
- etc: Configuration files to be placed in target distro
- node_modules: Library code
- systemd: Configuration files for systemd to start services
- test: Automated test code
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.
- analogRead(pin, [callback]) -> value
- analogWrite(pin, value, [freq], [callback])
- attachInterrupt(pin, handler, mode, [callback])
- detachInterrupt(pin, [callback])
- digitalRead(pin, [calback]) -> value
- digitalWrite(pin, value, [callback])
- getEeproms([callback]) -> eeproms
- pinMode(pin, direction, [mux], [pullup], [slew], [callback])
- getPinMode(pin, [callback]) -> pinMode
- shiftOut(dataPin, clockPin, bitOrder, val, [callback])
- serialOpen(port, options, [callback])
- serialWrite(port, data, [callback])
- i2cOpen(port, address, options, [callback])
- i2cScan(port, [callback])
- i2cWriteByte(port, byte, [callback])
- i2cWriteBytes(port, command, bytes, [callback])
- i2cReadByte(port, [callback])
- i2cReadBytes(port, command, length, [callback])
- i2cStream(port, command, length, [callback])
- bitRead(value, bitnum)
- bitWrite(value, bitnum, bitdata)
- bitSet(value, bitnum)
- bitClear(value, bitnum)
- min(x, y)
- max(x, y)
- constrain(x, a, b)
- map(value, fromLow, fromHigh, toLow, toHigh)
- pow(x, y)
- random([min], max)
- Enabling multiple loops and analyzing them to determine if they can be off- loaded to a PRU. This will be the primary mechanism for providing real-time servicing of the IOs.
- Providing higher-order services that utilize the standard peripherals for
their intended use:
- Serial drivers for I2C, SPI, UARTs, etc.
- analogWrite for PWMs using hardware PWMs, timers, kernel GPIO drivers, etc.
- Adding real-time patches to the kernel
- The state of the ARM Linux kernel with regards to handling loading drivers using devicetree is still in a lot of flux. Many of the interfaces Bonescript utilizes are being rewritten and refactored.