The following code uses the SerialPort module to listen to data from a Bluetooth connection.
I expect to see the data stream in hexadecimal format printed on the console. But the console just shows some weird characters. I want to know how I can decode and display data in the console.
var serialPort = new SerialPort("/dev/tty.EV3-SerialPort", { parser: SP.parsers.raw }, false); // this is the openImmediately flag [default is true] serialPort.open(function () { console.log('open'); serialPort.on('data', function(data) { var buff = new Buffer(data, 'utf8'); //no sure about this console.log('data received: ' + buff.toString()); }); });
GingerJim Sep 18 '13 at 18:40 2013-09-18 18:40
source share