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:

 

 

From: https://www.npmjs.org/package/serialport

 

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

 

<sigh>

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/boo
k>
http://www.packtpub.com/building-a-home-security-system-with-beaglebone/book

 

-- 
For more options, visit http://beagleboard.org/discuss
--- 
You received this message because you are subscribed to the Google Groups 
"BeagleBoard" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
For more options, visit https://groups.google.com/d/optout.

Reply via email to