lib/transport/scriptable-serial-terminal.js
function onData(rawData){

        // strip delimiter sequence from array
        const input = rawData.toString(_encoding);

        // response data object - default no response data
        const data = {
            echo: input,
            response: null
        };

        // response found ? split echo and response
        const splitIndex = input.indexOf('\n');
        if (splitIndex > 0){
            data.echo = input.substr(0, splitIndex).trim();
            data.response = input.substr(splitIndex + 1).trim();
        }

        // process waiting for input ?
        if (_waitingForInput !== null){
            const resolver = _waitingForInput;
            _waitingForInput = null;
            resolver(data);
        }else{
            _inputbuffer.push(data);
        }
    }
function onData(rawData){

        // strip delimiter sequence from array
        const input = rawData.toString(_encoding);

        // response data object - default no response data
        const data = {
            echo: input,
            response: null
        };

        // response found ? split echo and response
        const splitIndex = input.indexOf('\n');
        if (splitIndex > 0){
            data.echo = input.substr(0, splitIndex).trim();
            data.response = input.substr(splitIndex + 1).trim();
        }

        // process waiting for input ?
        if (_waitingForInput !== null){
            const resolver = _waitingForInput;
            _waitingForInput = null;
            resolver(data);
        }else{
            _inputbuffer.push(data);
        }
    }
function onData ( rawData ) { // strip delimiter sequence from array const input = rawData . toString ( _encoding ) ; // response data object - default no response data const data = { echo : input , response : null } ; // response found ? split echo and response const splitIndex = input . indexOf ( '\n' ) ; if ( splitIndex > 0 ) { data . echo = input . substr ( 0 , splitIndex ) . trim ( ) ; data . response = input . substr ( splitIndex + 1 ) . trim ( ) ; } // process waiting for input ? if ( _waitingForInput !== null ) { const resolver = _waitingForInput ; _waitingForInput = null ; resolver ( data ) ; } else { _inputbuffer . push ( data ) ; } }
listen on incoming data
listen on incoming data