title: serialport node.js read issue with buffer
body: <p><strong>Objective</strong> <br> 
  I need to fetch data over serial port for a batch of commands like <br> 
  <br>
  <strong>write to Serial</strong>: 'command'
  <br>
  <strong>expected response from Serial receiver</strong>: HEX Value</p>
  
  <p>and I used the <a href="https://www.npmjs.com/package/serialport" rel="nofollow noreferrer">Serial Port</a> 
  package.</p>
  
  <p><br>
  <strong><em>serial.js</em></strong></p>
  
  <pre><code>var serialport = require('serialport');
  var Readline = serialport.parsers.Readline; // make instance of Readline parser
  var parser = new Readline(); // make a new parser to read ASCII lines
  
  
  // list serial ports:
  serialport.list(function (err, ports) {
      ports.forEach(function (port) {
          console.log("Serial Device: " + port.comName);
      });
  });
  
  // get port name from the command line:
  var path = '/dev/cu.SLAB_USBtoUART' ;
  
  var myPort = new serialport(path ,{
      baudRate: 230400,
  });
  
  // Read Line Parser
  myPort.pipe(parser); // pipe the serial stream to the parser
  
  
  // Handling Events
  myPort.on('open', showPortOpen);
  // Calling with set interval
  setInterval(writeToSerial, 2000);
  myPort.on('data', readSerialData);
  myPort.on('close', showPortClose);
  myPort.on('error', showError);
  
  // Callback Functions
  function showPortOpen() {
      console.log('port open. Data rate: ' + myPort.baudRate);
  }
  
  
  function writeToSerial() {
      myPort.write('?1VB');
  }
  
  function readSerialData(data) {
      buff = data;
      console.log(data);
  }
  
  function showPortClose() {
      console.log('port closed.');
  }
  
  function showError(error) {
      console.log('Serial port error: ' + error);
  }
  </code></pre>
  
  <p>The above code is basically setting up the port and writing data to the serial port using setInterval(function(){}, time) followed by a read data event and its callback function. The read data event is working fine but the data received is in the form of buffer and it while reading the data it breaks into chunks. Here is the output attached <a href="https://i.stack.imgur.com/OyN5j.png" rel="nofollow noreferrer">Output</a> </p>
  
  <p>Please help me to receive the full buffer data instead of random bytes.</p>