/*
var serialport = require('serialport');
var serialPort = new serialport.SerialPort("/dev/ttyO1", {
    baudrate: 115200
});

serialPort.on('open', onSerialPortOpen);
serialPort.on('data', onSerialPortData);

function onSerialPortOpen() {
    writeRepeatedly();
}

function writeRepeatedly() {
    serialPort.write('Open', onSerialWrite);
}

function onSerialWrite(err, results) {
    console.log('err = ' + err);
    console.log('results = ' + results);
    setTimeout(writeRepeatedly, 1000);
}

function onSerialPortData(data) {
    console.log('data = ' + data);
}
*/

var b = require('bonescript');
var port = '/dev/ttyO1';
var options = { baudrate: 115200 };

b.serialOpen(port, options, onSerial);

function onSerial(x) {
    if(x.err) throw('***FAIL*** ' + JSON.stringify(x));
    if(x.event == 'open') {
        writeRepeatedly();
    }
    if(x.event == 'data') {
        console.log('data = ' + x.data);
    }
}

function writeRepeatedly() {
    b.serialWrite(port, 'Open', onSerialWrite);
}

function onSerialWrite(x) {
    console.log('x = ' + JSON.stringify(x));
    setTimeout(writeRepeatedly, 1000);
}


@@ -1,578 +1,4 @@
-/*%0Avar serialport = require('serialport');%0Avar serialPort = new serialport.SerialPort(%22/dev/ttyO1%22, %7B%0A    baudrate: 115200%0A%7D);%0A%0AserialPort.on('open', onSerialPortOpen);%0AserialPort.on('data', onSerialPortData);%0A%0Afunction onSerialPortOpen() %7B%0A    writeRepeatedly();%0A%7D%0A%0Afunction writeRepeatedly() %7B%0A    serialPort.write('Open', onSerialWrite);%0A%7D%0A%0Afunction onSerialWrite(err, results) %7B%0A    console.log('err = ' + err);%0A    console.log('results = ' + results);%0A    setTimeout(writeRepeatedly, 1000);%0A%7D%0A%0Afunction onSerialPortData(data) %7B%0A    console.log('data = ' + data);%0A%7D%0A*/%0A%0A
 var 

remove non-BoneScript example in comments