index.js
function chainSerialPorts(clientPort, serverPort) {
    var observer = new OpenEventObserver(clientPort, serverPort);

    function serverPortWrite(data) {
        try {
            debug('writing to serverPort', data);
            if (! Buffer.isBuffer(data)) {
                data = new Buffer(data);
            }
            serverPort.write(data);
        }
        catch (ex) {
            debug('error reading message', ex);
        }
    }

    function clientPortWrite(data) {
        try {
            debug('writing to clientPort', data);
            if (! Buffer.isBuffer(data)) {
                data = new Buffer(data);
            }
            clientPort.write(data);
        }
        catch (ex) {
            debug('error reading message', ex);
        }
    }

    observer.once('open', function (data) {
        serverPort.on('data', function (data) {
            clientPortWrite(data);
        });

        clientPort.on('data', function (data) {
            serverPortWrite(data);
        });
    });
}
function chainSerialPorts(clientPort, serverPort) {
    var observer = new OpenEventObserver(clientPort, serverPort);

    function serverPortWrite(data) {
        try {
            debug('writing to serverPort', data);
            if (! Buffer.isBuffer(data)) {
                data = new Buffer(data);
            }
            serverPort.write(data);
        }
        catch (ex) {
            debug('error reading message', ex);
        }
    }

    function clientPortWrite(data) {
        try {
            debug('writing to clientPort', data);
            if (! Buffer.isBuffer(data)) {
                data = new Buffer(data);
            }
            clientPort.write(data);
        }
        catch (ex) {
            debug('error reading message', ex);
        }
    }

    observer.once('open', function (data) {
        serverPort.on('data', function (data) {
            clientPortWrite(data);
        });

        clientPort.on('data', function (data) {
            serverPortWrite(data);
        });
    });
}
function chainSerialPorts ( clientPort , serverPort ) { var observer = new OpenEventObserver ( clientPort , serverPort ) ; function serverPortWrite ( data ) { try { debug ( 'writing to serverPort' , data ) ; if ( ! Buffer . isBuffer ( data ) ) { data = new Buffer ( data ) ; } serverPort . write ( data ) ; } catch ( ex ) { debug ( 'error reading message' , ex ) ; } } function clientPortWrite ( data ) { try { debug ( 'writing to clientPort' , data ) ; if ( ! Buffer . isBuffer ( data ) ) { data = new Buffer ( data ) ; } clientPort . write ( data ) ; } catch ( ex ) { debug ( 'error reading message' , ex ) ; } } observer . once ( 'open' , function ( data ) { serverPort . on ( 'data' , function ( data ) { clientPortWrite ( data ) ; } ) ; clientPort . on ( 'data' , function ( data ) { serverPortWrite ( data ) ; } ) ; } ) ; }
Helper function to chain Serial Port objects
Helper function to chain Serial Port objects