Octalbonescript serial port Read

42 views
Skip to first unread message

Michael Dalby

unread,
May 6, 2017, 3:07:55 AM5/6/17
to BeagleBoard
Hi All,

I'm using Node-Red on a BBB and want to do some serial messaging. I am using a  node-red function block calling Octalbonescript ( https://github.com/theoctal/octalbonescript/wiki/Serial-Port)  to do a serial write function this works okay (i.e. sends data out of the serial port)


var b = context.global.octalbonescript;

b.serial.open('/dev/ttyO2', {baudRate: 115200}, function(data){
  console.log(data);
}, function(err){
  if(err){
    console.error(err.message);
  }
});

var path='/dev/ttyO2';

//msg.payload is passed from the previous block as "hello World"
var buffer = msg.payload +'\r';

b.serial.write(path, buffer);

return msg;

Now, I want to try and get the serial read working, but I don't fully understand the operation and wondered if anyone can help (an example would be tops).  The documentation defines the serial.open as:

serial.open(path, options, handler[data], callback[err|null, serialPort])

 so I take it that the incoming serial data is passed into the handler[data]. Do I need to keep calling this function to check for any data or do I just do it once and it gets handled in the background??

Best regards 

Michael


Reply all
Reply to author
Forward
0 new messages