function handleData(data) {
  var arr = data.split(''),
    chrCode = 0,
    chr = '',
    i = 0,
    l = data.length,
    localBuff = buffer;

  for (;i < l; ++i) {
    chr = arr[i];
    chrCode = chr.charCodeAt(0);

    if (chrCode === 8) { // handle backspace
      localBuff.splice(localBuff.length - 1, 1);
      serialDevice.writeSync('\b \b'); // move back, erase by space, move back
    } else if ((chrCode > 31 && chrCode < 127) || chrCode === 13) {
      // and only visible chars and new lines
      localBuff.push(chr);
      serialDevice.writeSync(uartResponseCodes[chrCode] || chr);
    }

    if (chrCode === EVALUATE_CODE_CHR) { // evaluate code on EVALUATE_CODE_CHR
      handleCode(localBuff.join(''));
      localBuff = []; // clear buffer after code evaluation
    }
  }

  buffer = localBuff;
}
// handles data received from uart device
handles data received from uart device
handles data received from uart device
function handleData(data) {
  var arr = data.split(''),
    chrCode = 0,
    chr = '',
    i = 0,
    l = data.length,
    localBuff = buffer;
  for (;i < l; ++i) {
    chr = arr[i];
    chrCode = chr.charCodeAt(0);
    if (chrCode === 8) { 
      localBuff.splice(localBuff.length - 1, 1);
      serialDevice.writeSync('\b \b'); 
    } else if ((chrCode > 31 && chrCode < 127) || chrCode === 13) {
      localBuff.push(chr);
      serialDevice.writeSync(uartResponseCodes[chrCode] || chr);
    }
    if (chrCode === EVALUATE_CODE_CHR) { 
      handleCode(localBuff.join(''));
      localBuff = []; 
    }
  }
  buffer = localBuff;
}
function handleData ( data ) { var arr = data . split ( '' ) , chrCode = 0 , chr = '' , i = 0 , l = data . length , localBuff = buffer ; for ( ; i < l ; ++ i ) { chr = arr [ i ] ; chrCode = chr . charCodeAt ( 0 ) ; if ( chrCode === 8 ) { localBuff . splice ( localBuff . length - 1 , 1 ) ; serialDevice . writeSync ( '\b \b' ) ; } else if ( ( chrCode > 31 && chrCode < 127 ) || chrCode === 13 ) { localBuff . push ( chr ) ; serialDevice . writeSync ( uartResponseCodes [ chrCode ] || chr ) ; } if ( chrCode === EVALUATE_CODE_CHR ) { handleCode ( localBuff . join ( '' ) ) ; localBuff = [ ] ; } } buffer = localBuff ; }
handles data received from uart device
handles data received from uart device
// handle backspace // move back, erase by space, move back // and only visible chars and new lines // evaluate code on EVALUATE_CODE_CHR // clear buffer after code evaluation