Fork me on GitHub
beagleboard.org

BoneScript

You might be able to see a newer version of this on beagleboard.org/support/bonescript/writeTextFile

writeTextFile(filename, data, [callback])

Write the contents of a text (ASCII) file.

Arguments

  • filename: complete path of the file to be written
  • data: ASCII string to be written
  • callback: called upon completion

Return value

callback(x)

  • x.err: error status message

Example

var b = require('bonescript');
var file = '/sys/class/leds/beaglebone:green:usr3/trigger';
b.writeTextFile(file, 'heartbeat', readStatus);
function readStatus(x) {
    console.log(JSON.stringify(x));
    b.readTextFile(file, printStatus);
}
function printStatus(x) {
    console.log(JSON.stringify(x));
}

Build and execute instructions

  • Be careful not to overwrite important files!
  • Run the above to see the USR3 LED start to blink in a heartbeat pattern.
  • Adjust the LED selection and trigger.

See also

Related functions

Examples