Thursday, 27 April 2017

Raspberry Pi 3b can write but not able to read while use Node.js serialport

the code runs successfully

and result turns out that the 'ls' is sended but don't echo anything in RPi.

so Why? Any help would be much appreciated!

Thanks a lot! (PS: plz don't mind with my English because I'm a foreigner :))

var serialport = require("serialport");
var SerialPort = serialport;
var sp = new SerialPort("/dev/ttyS0", {
baudrate:9600,
databits: 8,
parity: 'none',
stopBits: 1,
flowControl: false,
parser: serialport.parsers.readline("\n"),
});

sp.on('open', function() {
console.log('open');
sp.on('data', function(data) {
console.log('data received: ' + data);

});

sp.write("ls", function(err, results) {
   console.log('err ' + err);
   console.log('results ' + results);
});

});



via Bryan Dieber

No comments:

Post a Comment