src/spm.js
function getSignature (sp, fn) {
  var start = null
    , sig = ''
    , timer;

  var handleSignature = function(data) {
    if (data)
      sig += data.toString() || '';

    clearTimeout(timer);

    if (!start && data) {
      start = Date.now();
    } else if (Date.now() - start > 100) {
      sp.removeListener('data', handleSignature);
      return fn(null, sig.trim());
    }

    timer = setTimeout(handleSignature, 100);
  };

  sp.on('data', handleSignature);
}
function getSignature (sp, fn) {
  var start = null
    , sig = ''
    , timer;

  var handleSignature = function(data) {
    if (data)
      sig += data.toString() || '';

    clearTimeout(timer);

    if (!start && data) {
      start = Date.now();
    } else if (Date.now() - start > 100) {
      sp.removeListener('data', handleSignature);
      return fn(null, sig.trim());
    }

    timer = setTimeout(handleSignature, 100);
  };

  sp.on('data', handleSignature);
}
function getSignature ( sp , fn ) { var start = null , sig = '' , timer ; var handleSignature = function ( data ) { if ( data ) sig += data . toString ( ) || '' ; clearTimeout ( timer ) ; if ( ! start && data ) { start = Date . now ( ) ; } else if ( Date . now ( ) - start > 100 ) { sp . removeListener ( 'data' , handleSignature ) ; return fn ( null , sig . trim ( ) ) ; } timer = setTimeout ( handleSignature , 100 ) ; } ; sp . on ( 'data' , handleSignature ) ; }
Given a SerialPort obj, tries to get the
signature emitted from the device.
@param  {Object}   sp sp
@param  {Function} fn callback fn. Resolves
with (err | serialport |
signature) when ready.
Given a SerialPort obj tries to get the signature emitted from the device .