rpi-gpio.js
function listen(channel, onChange) {
        var pin = getPinForCurrentMode(channel);

        if (!exportedInputPins[pin] && !exportedOutputPins[pin]) {
            throw new Error('Channel %d has not been exported', channel);
        }

        debug('listen for pin %d', pin);
        var poller = new Epoll(function(err, innerfd, events) {
            if (err) throw err
            clearInterrupt(innerfd);
            onChange(channel);
        });

        var fd = fs.openSync(PATH + '/gpio' + pin + '/value', 'r+');
        clearInterrupt(fd);
        poller.add(fd, Epoll.EPOLLPRI);
        // Append ready-to-use remove function
        pollers[pin] = function() {
            poller.remove(fd).close();
        }
    }
function listen(channel, onChange) {
        var pin = getPinForCurrentMode(channel);

        if (!exportedInputPins[pin] && !exportedOutputPins[pin]) {
            throw new Error('Channel %d has not been exported', channel);
        }

        debug('listen for pin %d', pin);
        var poller = new Epoll(function(err, innerfd, events) {
            if (err) throw err
            clearInterrupt(innerfd);
            onChange(channel);
        });

        var fd = fs.openSync(PATH + '/gpio' + pin + '/value', 'r+');
        clearInterrupt(fd);
        poller.add(fd, Epoll.EPOLLPRI);
        // Append ready-to-use remove function
        pollers[pin] = function() {
            poller.remove(fd).close();
        }
    }
function listen ( channel , onChange ) { var pin = getPinForCurrentMode ( channel ) ; if ( ! exportedInputPins [ pin ] && ! exportedOutputPins [ pin ] ) { throw new Error ( 'Channel %d has not been exported' , channel ) ; } debug ( 'listen for pin %d' , pin ) ; var poller = new Epoll ( function ( err , innerfd , events ) { if ( err ) throw err clearInterrupt ( innerfd ) ; onChange ( channel ) ; } ) ; var fd = fs . openSync ( PATH + '/gpio' + pin + '/value' , 'r+' ) ; clearInterrupt ( fd ) ; poller . add ( fd , Epoll . EPOLLPRI ) ; // Append ready-to-use remove function pollers [ pin ] = function ( ) { poller . remove ( fd ) . close ( ) ; } }
Listen for interrupts on a channel

@param {number}      channel The channel to watch
@param {function}    cb Callback which receives the channel's err
Listen for interrupts on a channel