Hello All;
I apologize for starting a new thread, but I seem to have lost the last one L
Basically, after some “Google-ing” I realized that I have to wait for the serial port to be open before reading from or writing to it.
This is because it communicates asynchronously.
So here is my new code, and naturally a new error:
var data
var serialPort, sp;
var serialPort = require(“serialport”).SerialPort;
var sp = new serialPort("/dev/ttyO1", { baudrate: 9600 });
sp.on(“open”,function(){
console.log(“Hello World the Comm Port is Open”);
});
function sp_write(data){
sp.on(“open”, function () {
sp.write(“ls\n”, function(err, results) {
console.log('err ’ + err);
console.log('results ’ + results);
});
});
}
togglepin();
function togglepin(){
// High and low parts of the frame length (not counting checksum)
sp_write(“Hello Again”);
//sp_write(0x0);
//sp_write(0x10);
}
Hello World the Comm Port is Open
err undefined
results 3
I still need some help L
Bill
“No one could make a greater mistake than he who did nothing because he could do only a little.”
“All that is necessary for the triumph of evil is that good men do nothing” Edmond Burke (1729 - 1797)
http://www.packtpub.com/building-a-home-security-system-with-beaglebone/book