src/spm.js
function enhanceSpm (comName, checkSignature, fn) {
  var sp = new SerialPort(comName)
    , open = false;

  sp.writable = true;
  sp.on('open', function() {
    open = true;
    if (checkSignature)
      getSignature(sp, function(e, sig) {
        fn(e, sp, sig);
      });
    else
      fn(null, sp, null);
  });

  sp.once('error', function(e) {
    console.log('ERROR', e, comName);
    if (!open)
      fn(e);
  });
}
function enhanceSpm (comName, checkSignature, fn) {
  var sp = new SerialPort(comName)
    , open = false;

  sp.writable = true;
  sp.on('open', function() {
    open = true;
    if (checkSignature)
      getSignature(sp, function(e, sig) {
        fn(e, sp, sig);
      });
    else
      fn(null, sp, null);
  });

  sp.once('error', function(e) {
    console.log('ERROR', e, comName);
    if (!open)
      fn(e);
  });
}
function enhanceSpm ( comName , checkSignature , fn ) { var sp = new SerialPort ( comName ) , open = false ; sp . writable = true ; sp . on ( 'open' , function ( ) { open = true ; if ( checkSignature ) getSignature ( sp , function ( e , sig ) { fn ( e , sp , sig ) ; } ) ; else fn ( null , sp , null ) ; } ) ; sp . once ( 'error' , function ( e ) { console . log ( 'ERROR' , e , comName ) ; if ( ! open ) fn ( e ) ; } ) ; }
Main function to be exported. It exposes a
better serialport.
@param  {[type]}   comName the comName
returned from the
port listing
@param  {Function} fn      callback function
to be called with
(err|sp|signature)
Main function to be exported . It exposes a better serialport .