var serialport = require('serialport');
// serialPort.list(function (err, ports) {
//   ports.forEach(function(port) {
//     console.log(port.comName);
//     //console.log(port.pnpId);
//     //console.log(port.manufacturer);
//   });
// });
var SerialPort = require('serialport').SerialPort;
var port = new SerialPort('COM3', {
  baudrate: 9600,
  parser: serialport.parsers.readline('=')
}, false);

port.open(function (err) {
  if (err) {
    return console.log('Error opening port: ', err.message);
  }
  // errors will be emitted on the port since there is no callback to write
  port.write('W');
  port.on('data', function (data) {
    console.log(data.toString());
});
});
