Coder Social home page Coder Social logo

node-rpio's Introduction

node-rpio

This is a high performance node.js addon which provides access to the Raspberry Pi and SunXi (Allwinner V40) GPIO interfaces, supporting regular GPIO as well as i²c, PWM, and SPI.

NPM version Node.js version NPM downloads Build Status License: ISC License: GPL v2 Donations

Compatibility

  • Raspberry Pi Models: A, B, A+, B+, 2, 3, 4, 400, Compute Module, Zero.
  • SunXi (Allwinner V40) Models: Orange Pi Zero, Banana Pi M2 Zero / Berry.
  • Node.js Versions: 0.8, 0.10, 0.12, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14.

Currently only basic GPIO is supported on the SunXi chipsets.

Newer versions of node.js require you to install the GCC 4.8 packages for C++11 support. If you see compilation problems related to C++11, this is the likely cause.

Due to node-tap requirements the test suite only works on node.js version 6 or above.

Install

Install the latest using npm:

$ npm install rpio

Important System Requirements

This module will only interface with hardware on Linux, but should compile on any other platform, where it will run in mock mode by default.

Disable GPIO interrupts

If running a newer Raspbian release, you will need to add the following line to /boot/config.txt and reboot:

dtoverlay=gpio-no-irq

Without this you may see crashes with newer kernels when trying to poll for pin changes.

Enable /dev/gpiomem access

By default the module will use /dev/gpiomem when using simple GPIO access. To access this device, your user will need to be a member of the gpio group, and you may need to configure udev with the following rule (as root):

$ cat >/etc/udev/rules.d/20-gpiomem.rules <<EOF
SUBSYSTEM=="bcm2835-gpiomem", KERNEL=="gpiomem", GROUP="gpio", MODE="0660"
EOF

For access to i²c, PWM, and SPI, or if you are running an older kernel which does not have the bcm2835-gpiomem module, you will need to run your programs as root for access to /dev/mem.

Quickstart

All these examples use the physical numbering (P01-P40) and assume that the example is started with:

var rpio = require('rpio');

Read a pin

Setup pin P15 / GPIO22 for read-only input and print its current value:

rpio.open(15, rpio.INPUT);
console.log('Pin 15 is currently ' + (rpio.read(15) ? 'high' : 'low'));

Blink an LED

Blink an LED attached to P16 / GPIO23 a few times:

/*
 * Set the initial state to low.  The state is set prior to the pin
 * being actived, so is safe for devices which require a stable setup.
 */
rpio.open(16, rpio.OUTPUT, rpio.LOW);

/*
 * The sleep functions block, but rarely in these simple programs does
 * one care about that.  Use a setInterval()/setTimeout() loop instead
 * if it matters.
 */
for (var i = 0; i < 5; i++) {
        /* On for 1 second */
        rpio.write(16, rpio.HIGH);
        rpio.sleep(1);

        /* Off for half a second (500ms) */
        rpio.write(16, rpio.LOW);
        rpio.msleep(500);
}

Poll a button switch for events

Configure the internal pullup resistor on P15 / GPIO22 and watch the pin for pushes on an attached button switch:

rpio.open(15, rpio.INPUT, rpio.PULL_UP);

function pollcb(pin)
{
        /*
         * Wait for a small period of time to avoid rapid changes which
         * can't all be caught with the 1ms polling frequency.  If the
         * pin is no longer down after the wait then ignore it.
         */
        rpio.msleep(20);

        if (rpio.read(pin))
                return;

        console.log('Button pressed on pin P%d', pin);
}

rpio.poll(15, pollcb, rpio.POLL_LOW);

A collection of example programs are also available in the examples directory.

Features

There are lots of GPIO modules available for node.js. Why use this one?

Performance

It's very fast. Part of the module is a native addon which links against Mike McCauley's bcm2835 library, providing direct access to the hardware via /dev/mem and /dev/gpiomem.

Most alternative GPIO modules use the slower /sys file system interface.

How much faster? Here is a simple test which calculates how long it takes to switch a pin on and off 1 million times:

  • rpi-gpio (using /sys): 701.023 seconds
  • rpio (using /dev/*mem): 0.684 seconds

So rpio can be anywhere up to 1000x faster than the alternatives.

Hardware support

While /sys provides a simple interface to GPIO, not all hardware features are supported, and it's not always possible to handle certain types of hardware, especially when employing an asynchronous model. Using the /dev/*mem interface means rpio can support a lot more functionality:

  • rpio supports sub-millisecond access, with features to support multiple reads/writes directly with hardware rather than being delayed by the event loop.

  • Output pins can be configured with a default state prior to being enabled, required by some devices and not possible to configure via /sys.

  • Internal pullup/pulldown registers can be configured.

  • Hardware i²c, PWM, and SPI functions are supported.

Simple programming

rpio tries to make it simple to program devices, rather than having to jump through hoops to support an asynchronous workflow. Some parts of rpio block, but that is intentional in order to provide a simpler interface, as well as being able to support time-sensitive devices.

The aim is to provide an interface familiar to Unix programmers, with the performance to match.

API

Start by requiring the addon.

var rpio = require('rpio');

GPIO

General purpose I/O tries to follow a standard open/read/write/close model.

Some useful constants are provided for use by all supporting functions:

  • rpio.HIGH: pin high/1/on
  • rpio.LOW: pin low/0/off

These can be useful to avoid magic numbers in your code.

rpio.init([options])

Initialise the library. This will be called automatically by .open() using the default option values if not called explicitly. The default values are:

var options = {
        gpiomem: true,          /* Use /dev/gpiomem */
        mapping: 'physical',    /* Use the P1-P40 numbering scheme */
        mock: undefined,        /* Emulate specific hardware in mock mode */
        close_on_exit: true,    /* On node process exit automatically close rpio */
}
gpiomem

There are two device nodes for GPIO access. The default is /dev/gpiomem which, when configured with gpio group access, allows users in that group to read/write directly to that device. This removes the need to run as root, but is limited to GPIO functions.

For non-GPIO functions (i²c, PWM, SPI) the /dev/mem device is required for full access to the Broadcom peripheral address range and the program needs to be executed as the root user (e.g. via sudo). If you do not explicitly call .init() when using those functions, the library will do it for you with gpiomem: false.

You may also need to use gpiomem: false if you are running on an older Linux kernel which does not support the gpiomem module.

rpio will throw an exception if you try to use one of the non-GPIO functions after already opening with /dev/gpiomem, as well as checking to see if you have the necessary permissions.

Valid options:

  • true: use /dev/gpiomem for non-root but GPIO-only access
  • false: use /dev/mem for full access but requires root
mapping

There are two naming schemes when referring to GPIO pins:

  • By their physical header location: Pins 1 to 26 (A/B) or Pins 1 to 40 (A+/B+)
  • Using the Broadcom hardware map: GPIO 0-25 (B rev1), GPIO 2-27 (A/B rev2, A+/B+)

Confusingly however, the Broadcom GPIO map changes between revisions, so for example P3 maps to GPIO0 on Model B Revision 1 models, but maps to GPIO2 on all later models.

This means the only sane default mapping is the physical layout, so that the same code will work on all models regardless of the underlying GPIO mapping.

If you prefer to use the Broadcom GPIO scheme for whatever reason (e.g. to use the P5 header pins on the Raspberry Pi 1 revision 2.0 model which aren't currently mapped to the physical layout), you can set mapping to gpio to switch to the GPIOxx naming.

Valid options:

  • gpio: use the Broadcom GPIOxx naming
  • physical: use the physical P01-P40 header layout

Examples:

rpio.init({gpiomem: false});    /* Use /dev/mem for i²c/PWM/SPI */
rpio.init({mapping: 'gpio'});   /* Use the GPIOxx numbering */
mock

Mock mode is a dry-run environment where everything except pin access is performed. This is useful for testing scripts, and can also be used on systems which do not support GPIO at all.

If rpio is executed on unsupported hardware it will automatically start up in mock mode, and a warn event is emitted. By default the warn event is handled by a simple logger to stdout, but this can be overridden by the user creating their own warn handler.

The user can also explicitly request mock mode, where the argument is the type of hardware they wish to emulate. The currently available options are:

  • 26-pin Raspberry Pi models
    • raspi-b-r1 (early rev 1 model)
    • raspi-a
    • raspi-b
  • 40-pin Raspberry Pi models
    • raspi-a+
    • raspi-b+
    • raspi-2
    • raspi-3
    • raspi-zero
    • raspi-zero-w (zero with wireless)

The default unsupported hardware emulation is raspi-3.

Examples:

/*
 * Explicitly request mock mode to avoid warnings when running on known
 * unsupported hardware, or to test scripts in a different hardware
 * environment (e.g. to check pin settings).
 */
rpio.init({mock: 'raspi-3'});

/* Override default warn handler to avoid mock warnings */
rpio.on('warn', function() {});
close_on_exit

Rpio automatically unmaps and clears all memory maps when the node process exits. If you need to add hooks for your own cleanup routines during process exit then set close_on_exit: false. Make sure to call rpio.exit() in your exit hook.

Example:

rpio.init({close_on_exit: false});

process.on('exit', function() {
        /* Insert any custom cleanup code here. */
        rpio.exit();
});

rpio.exit()

Shuts down the rpio library, unmapping and clearing all memory maps. By default this will happen automatically. This method is provided to allow explicit shutdown when using close_on_exit: false and a custom exit handler.

Example:

rpio.init({close_on_exit: false});

process.on('exit', function() {
        /* Insert any custom cleanup code here. */
        rpio.exit();
});

rpio.open(pin, mode[, option])

Open a pin for input or output. Valid modes are:

  • rpio.INPUT: pin is input (read-only).
  • rpio.OUTPUT: pin is output (read-write).
  • rpio.PWM: configure pin for hardware PWM (see PWM section below).

For input pins, option can be used to configure the internal pullup or pulldown resistors using options as described in the .pud() documentation below.

For output pins, option defines the initial state of the pin, rather than having to issue a separate .write() call. This can be critical for devices which must have a stable value, rather than relying on the initial floating value when a pin is enabled for output but hasn't yet been configured with a value.

Examples:

/* Configure P15 as input with the internal pulldown resistor enabled */
rpio.open(15, rpio.INPUT, rpio.PULL_DOWN);

/* Configure P16 as output with the initiate state set high */
rpio.open(16, rpio.OUTPUT, rpio.HIGH);

/* Configure P18 as output, but leave it in its initial undefined state */
rpio.open(18, rpio.OUTPUT);

rpio.mode(pin, mode[, option])

Switch a pin that has already been opened in one mode to a different mode. This is provided primarily for performance reasons, as it avoids some of the setup work done by .open().

Example:

/* Switch P15 to output mode */
rpio.mode(15, rpio.OUTPUT);

/* Switch P16 to input mode with the internal pullup resistor enabled */
rpio.mode(16, rpio.INPUT, rpio.PULL_UP);

rpio.read(pin[, mode])

Read the current value of pin, returning either 1 (high) or 0 (low).

If mode is non-zero, perform a switch to input mode before reading. This can help with timing-critical code where the JavaScript function call overhead of calling rpio.mode() first is enough to miss input data. Altering the pullup state is not supported, as on many devices this requires a delay to activate, defeating the point of this feature.

Example:

console.log('Pin 16 = %d', rpio.read(16));

rpio.readbuf(pin, buffer[, length[, mode]])

Read length bits from pin into buffer as fast as possible.

If length isn't specified it defaults to buffer.length.

If mode is non-zero, perform a switch to input mode before reading. This can help with timing-critical code where the JavaScript function call overhead of calling rpio.mode() first is enough to miss input data. Altering the pullup state is not supported, as on many devices this requires a delay to activate, defeating the point of this feature.

This is useful for devices which send out information faster than the JavaScript function call overhead can handle, e.g. if you need microsecond accuracy. See dht11.js for an example which uses this to pull data from a DHT11 temperature/humidity sensor.

Example:

var buf = new Buffer(10000);

/*
 * Set pin 16 low, then switch pin 16 to input mode and read its value 10,000
 * times, storing each bit value in buf.
 */
rpio.write(16, rpio.LOW);
rpio.readbuf(16, buf, buf.length, true);

rpio.write(pin, value)

Set the specified pin either high or low, using either the rpio.HIGH/rpio.LOW constants, or simply 1 or 0.

Example:

rpio.write(13, rpio.HIGH);

rpio.writebuf(pin, buffer[, length])

Write length bits to pin from buffer as fast as possible. If length isn't specified it defaults to buffer.length.

Example:

/* Write 1 0 1 0 1 0 1 0 to Pin 13 */
var buf = new Buffer(8).fill(rpio.LOW);
buf[0] = buf[2] = buf[4] = buf[6] = rpio.HIGH;
rpio.writebuf(13, buf);

rpio.readpad(group)

Read the current state of the GPIO pad control for the specified GPIO group. On current models of Raspberry Pi there are three groups with corresponding defines:

  • rpio.PAD_GROUP_0_27: GPIO0 - GPIO27. Use this for the main GPIO header.
  • rpio.PAD_GROUP_28_45: GPIO28 - GPIO45. Use this to configure the P5 header.
  • rpio.PAD_GROUP_46_53: GPIO46 - GPIO53. Internal, you probably won't need this.

The value returned will be a bit mask of the following defines:

  • rpio.PAD_SLEW_UNLIMITED: 0x10. Slew rate unlimited if set.
  • rpio.PAD_HYSTERESIS: 0x08. Hysteresis is enabled if set.

The bottom three bits determine the drive current:

  • rpio.PAD_DRIVE_2mA: 0b000
  • rpio.PAD_DRIVE_4mA: 0b001
  • rpio.PAD_DRIVE_6mA: 0b010
  • rpio.PAD_DRIVE_8mA: 0b011
  • rpio.PAD_DRIVE_10mA: 0b100
  • rpio.PAD_DRIVE_12mA: 0b101
  • rpio.PAD_DRIVE_14mA: 0b110
  • rpio.PAD_DRIVE_16mA: 0b111

Note that the pad control registers are not available via /dev/gpiomem, so you will need to use .init({gpiomem: false}) and run as root.

Example:

var curpad = rpio.readpad(rpio.PAD_GROUP_0_27);

var slew = ((curpad & rpio.PAD_SLEW_UNLIMITED) == rpio.PAD_SLEW_UNLIMITED);
var hysteresis = ((curpad & rpio.PAD_HYSTERESIS) == rpio.PAD_HYSTERESIS);
var drive = (curpad & 0x7);

console.log('GPIO Pad Control for GPIO0 - GPIO27 is currently set to:');
console.log('\tSlew rate: ' + (slew ? 'unlimited' : 'limited'));
console.log('\tInput hysteresis: ' + (hysteresis ? 'enabled' : 'disabled'));
console.log('\tDrive rate: ' + (drive * 2 + 2) + 'mA');

rpio.writepad(group, control)

Write control settings to the pad control for group. Uses the same defines as above for .readpad().

Example:

/* Disable input hysteresis but retain other current settings. */
var control = rpio.readpad(rpio.PAD_GROUP_0_27);
control &= ~rpio.PAD_HYSTERESIS;
rpio.writepad(rpio.PAD_GROUP_0_27, control);

rpio.pud(pin, state)

Configure the pin's internal pullup or pulldown resistors, using the following state constants:

  • rpio.PULL_OFF: disable configured resistors.
  • rpio.PULL_DOWN: enable the pulldown resistor.
  • rpio.PULL_UP: enable the pullup resistor.

Examples:

rpio.pud(15, rpio.PULL_UP);
rpio.pud(16, rpio.PULL_DOWN);

rpio.poll(pin, cb[, direction])

Watch pin for changes and execute the callback cb() on events. cb() takes a single argument, the pin which triggered the callback.

The optional direction argument can be used to watch for specific events:

  • rpio.POLL_LOW: poll for falling edge transitions to low.
  • rpio.POLL_HIGH: poll for rising edge transitions to high.
  • rpio.POLL_BOTH: poll for both transitions (the default).

Due to hardware/kernel limitations we can only poll for changes, and the event detection only says that an event occurred, not which one. The poll interval is a 1ms setInterval() and transitions could come in between detecting the event and reading the value. Therefore this interface is only useful for events which transition slower than approximately 1kHz.

To stop watching for pin changes, call .poll() again, setting the callback to null (or anything else which isn't a function).

Example:

function nuke_button(pin)
{
        console.log('Nuke button on pin %d pressed', pin);

        /* No need to nuke more than once. */
        rpio.poll(pin, null);
}

function regular_button(pin)
{
        /* Watch pin 15 forever. */
        console.log('Button event on pin %d, is now %d', pin, rpio.read(pin));
}

/*
 * Pin 15 watches for both high and low transitions.  Pin 16 only watches for
 * high transitions (e.g. the nuke button is pushed).
 */
rpio.poll(15, regular_button);
rpio.poll(16, nuke_button, rpio.POLL_HIGH);

rpio.close(pin[, reset])

Indicate that the pin will no longer be used, and clear any poll events associated with it.

The optional reset argument can be used to configure the state that pin will be left in after close:

  • rpio.PIN_RESET: return pin to rpio.INPUT and clear any pullup/pulldown resistors. This is the default.
  • rpio.PIN_PRESERVE: leave pin in its currently configured state.

Examples:

rpio.close(15);
rpio.close(16, rpio.PIN_RESET);
rpio.close(13, rpio.PIN_PRESERVE);

GPIO demo

The code below continuously flashes an LED connected to pin 15 at 100Hz.

var rpio = require('rpio');

/* Configure P15 as an output pin, setting its initial state to low */
rpio.open(15, rpio.OUTPUT, rpio.LOW);

/* Set the pin high every 10ms, and low 5ms after each transition to high */
setInterval(function() {
        rpio.write(15, rpio.HIGH);
        setTimeout(function() {
                rpio.write(15, rpio.LOW);
        }, 5);
}, 10);

i²c

i²c is primarily of use for driving LCD displays, and makes use of pins 3 and 5 (GPIO0/GPIO1 on Rev 1, GPIO2/GPIO3 on Rev 2 and newer). The library automatically detects which Raspberry Pi revision you are running, so you do not need to worry about which i²c bus to configure.

To get started call .i2cBegin() which assigns pins 3 and 5 to i²c use. Until .i2cEnd() is called they won't be available for GPIO use. The pin assignments are:

  • Pin 3: SDA (Serial Data)
  • Pin 5: SCL (Serial Clock)

.i2cBegin() will call .init() if it hasn't already been called, with gpiomem: false set. Hardware i²c support requires /dev/mem access and therefore root.

rpio.i2cBegin();

Configure the slave address. This is between 0 - 0x7f, and it can be helpful to run the i2cdetect program to figure out where your devices are if you are unsure.

rpio.i2cSetSlaveAddress(0x20);

Set the baud rate. You can do this two different ways, depending on your preference. Either use .i2cSetBaudRate() to directly set the speed in hertz, or .i2cSetClockDivider() to set it based on a divisor of the base 250MHz rate.

rpio.i2cSetBaudRate(100000);    /* 100kHz */
rpio.i2cSetClockDivider(2500);  /* 250MHz / 2500 = 100kHz */

Read from and write to the i²c slave. Both functions take a buffer and optional length argument, defaulting to the length of the buffer if not specified.

var txbuf = new Buffer([0x0b, 0x0e, 0x0e, 0x0f]);
var rxbuf = new Buffer(32);

rpio.i2cWrite(txbuf);           /* Sends 4 bytes */
rpio.i2cRead(rxbuf, 16);        /* Reads 16 bytes */

Two specialised functions are available for reading and writing to devices that require a repeated start. For now see the bcm2835 documentation for more information on these.

/*
 * Read len bytes from register into buf after issuing a repeated start,
 * required by e.g. MPL3115A2 pressure and temperature sensor.
 */
rpio.i2cReadRegisterRestart(reg, rbuf, rlen);

/*
 * Write cmdlen commands from cmdbuf to device before issuing a repeated
 * start and reading rlen bytes into rbuf, for e.g. MLX90620.
 */
rpio.i2cWriteReadRestart(cmdbuf, cmdlen, rbuf, rlen);

Finally, turn off the i²c interface and return the pins to GPIO.

rpio.i2cEnd();

i²c demo

The code below writes two strings to a 16x2 LCD.

var rpio = require('rpio');

/*
 * Magic numbers to initialise the i2c display device and write output,
 * cribbed from various python drivers.
 */
var init = new Buffer([0x03, 0x03, 0x03, 0x02, 0x28, 0x0c, 0x01, 0x06]);
var LCD_LINE1 = 0x80, LCD_LINE2 = 0xc0;
var LCD_ENABLE = 0x04, LCD_BACKLIGHT = 0x08;

/*
 * Data is written 4 bits at a time with the lower 4 bits containing the mode.
 */
function lcdwrite4(data)
{
        rpio.i2cWrite(Buffer([(data | LCD_BACKLIGHT)]));
        rpio.i2cWrite(Buffer([(data | LCD_ENABLE | LCD_BACKLIGHT)]));
        rpio.i2cWrite(Buffer([((data & ~LCD_ENABLE) | LCD_BACKLIGHT)]));
}
function lcdwrite(data, mode)
{
        lcdwrite4(mode | (data & 0xF0));
        lcdwrite4(mode | ((data << 4) & 0xF0));
}

/*
 * Write a string to the specified LCD line.
 */
function lineout(str, addr)
{
        lcdwrite(addr, 0);

        str.split('').forEach(function (c) {
                lcdwrite(c.charCodeAt(0), 1);
        });
}

/*
 * We can now start the program, talking to the i2c LCD at address 0x27.
 */
rpio.i2cBegin();
rpio.i2cSetSlaveAddress(0x27);
rpio.i2cSetBaudRate(10000);

for (var i = 0; i < init.length; i++)
        lcdwrite(init[i], 0);

lineout('node.js i2c LCD!', LCD_LINE1);
lineout('npm install rpio', LCD_LINE2);

rpio.i2cEnd();

PWM

Pulse Width Modulation (PWM) allows you to create analog output from the digital pins. This can be used, for example, to make an LED appear to pulse rather than be fully off or on.

The Broadcom chipset supports hardware PWM, i.e. you configure it with the appropriate values and it will generate the required pulse. This is much more efficient and accurate than emulating it in software (by setting pins high and low at particular times), but you are limited to only certain pins supporting hardware PWM:

  • 26-pin models: pin 12
  • 40-pin models: pins 12, 32, 33, 35

Hardware PWM also requires gpiomem: false and root privileges. .open() will call .init() with the appropriate values if you do not explicitly call it yourself.

To enable a PIN for PWM, use the rpio.PWM argument to open():

rpio.open(12, rpio.PWM); /* Use pin 12 */

Set the PWM refresh rate with pwmSetClockDivider(). This is a power-of-two divisor of the base 19.2MHz rate, with a maximum value of 4096 (4.6875kHz).

rpio.pwmSetClockDivider(64);    /* Set PWM refresh rate to 300kHz */

Set the PWM range for a pin with pwmSetRange(). This determines the maximum pulse width.

rpio.pwmSetRange(12, 1024);

Finally, set the PWM width for a pin with pwmSetData().

rpio.pwmSetData(12, 512);

PWM demo

The code below pulses an LED 5 times before exiting.

var rpio = require('rpio');

var pin = 12;           /* P12/GPIO18 */
var range = 1024;       /* LEDs can quickly hit max brightness, so only use */
var max = 128;          /*   the bottom 8th of a larger scale */
var clockdiv = 8;       /* Clock divider (PWM refresh rate), 8 == 2.4MHz */
var interval = 5;       /* setInterval timer, speed of pulses */
var times = 5;          /* How many times to pulse before exiting */

/*
 * Enable PWM on the chosen pin and set the clock and range.
 */
rpio.open(pin, rpio.PWM);
rpio.pwmSetClockDivider(clockdiv);
rpio.pwmSetRange(pin, range);

/*
 * Repeatedly pulse from low to high and back again until times runs out.
 */
var direction = 1;
var data = 0;
var pulse = setInterval(function() {
        rpio.pwmSetData(pin, data);
        if (data === 0) {
                direction = 1;
                if (times-- === 0) {
                        clearInterval(pulse);
                        rpio.open(pin, rpio.INPUT);
                        return;
                }
        } else if (data === max) {
                direction = -1;
        }
        data += direction;
}, interval, data, direction, times);

SPI

SPI switches pins 19, 21, 23, 24 and 26 (GPIO7-GPIO11) to a special mode where you can bulk transfer data at high speeds to and from SPI devices, with the controller handling the chip enable, clock and data in/out functions.

/*
 *  Pin | Function
 * -----|----------
 *   19 |   MOSI
 *   21 |   MISO
 *   23 |   SCLK
 *   24 |   CE0
 *   26 |   CE1
 */

Once SPI is enabled, the SPI pins are unavailable for GPIO use until spiEnd() is called.

Use .spiBegin() to initiate SPI mode. SPI requires gpiomem: false and root privileges. .spiBegin() will call .init() with the appropriate values if you do not explicitly call it yourself.

rpio.spiBegin();           /* Switch GPIO7-GPIO11 to SPI mode */

Choose which of the chip select / chip enable pins to control:

/*
 *  Value | Pin
 *  ------|---------------------
 *    0   | SPI_CE0 (24 / GPIO8)
 *    1   | SPI_CE1 (26 / GPIO7)
 *    2   | Both
 */
rpio.spiChipSelect(0);

Commonly chip enable (CE) pins are active low, and this is the default. If your device's CE pin is active high, use spiSetCSPolarity() to change the polarity.

rpio.spiSetCSPolarity(0, rpio.HIGH);    /* Set CE0 high to activate */

Set the SPI clock speed with spiSetClockDivider(div). The div argument is an even divisor of the base 250MHz rate ranging between 0 and 65536.

rpio.spiSetClockDivider(128);   /* Set SPI speed to 1.95MHz */

Set the SPI Data Mode:

/*
 *  Mode | CPOL | CPHA
 *  -----|------|-----
 *    0  |  0   |  0
 *    1  |  0   |  1
 *    2  |  1   |  0
 *    3  |  1   |  1
 */
rpio.spiSetDataMode(0);         /* 0 is the default */

Once everything is set up we can transfer data. Data is sent and received in 8-bit chunks via buffers which should be the same size.

var txbuf = new Buffer([0x3, 0x0, 0xff, 0xff]);
var rxbuf = new Buffer(txbuf.length);

rpio.spiTransfer(txbuf, rxbuf, txbuf.length);

If you only need to send data and do not care about the data coming back, you can use the slightly faster spiWrite() call:

rpio.spiWrite(txbuf, txbuf.length);

When you're finished call .spiEnd() to release the pins back to general purpose use.

rpio.spiEnd();

SPI demo

The code below reads the 128x8 contents of an AT93C46 serial EEPROM.

var rpio = require('rpio');

rpio.spiBegin();
rpio.spiChipSelect(0);                  /* Use CE0 */
rpio.spiSetCSPolarity(0, rpio.HIGH);    /* AT93C46 chip select is active-high */
rpio.spiSetClockDivider(128);           /* AT93C46 max is 2MHz, 128 == 1.95MHz */
rpio.spiSetDataMode(0);

/*
 * There are various magic numbers below.  A quick overview:
 *
 *   tx[0] is always 0x3, the EEPROM READ instruction.
 *   tx[1] is set to var i which is the EEPROM address to read from.
 *   tx[2] and tx[3] can be anything, at this point we are only interested in
 *     reading the data back from the EEPROM into our rx buffer.
 *
 * Once we have the data returned in rx, we have to do some bit shifting to
 * get the result in the format we want, as the data is not 8-bit aligned.
 */
var tx = new Buffer([0x3, 0x0, 0x0, 0x0]);
var rx = new Buffer(4);
var out;
var i, j = 0;

for (i = 0; i < 128; i++, ++j) {
        tx[1] = i;
        rpio.spiTransfer(tx, rx, 4);
        out = ((rx[2] << 1) | (rx[3] >> 7));
        process.stdout.write(out.toString(16) + ((j % 16 == 0) ? '\n' : ' '));
}
rpio.spiEnd();

Misc

To make code simpler a few sleep functions are supported.

rpio.sleep(n);          /* Sleep for n seconds */
rpio.msleep(n);         /* Sleep for n milliseconds */
rpio.usleep(n);         /* Sleep for n microseconds */

There will be a startup cost when calling these functions, so it is worth performing some initial benchmarks to calculate the latency for your hardware when using the high resolution functions, then factoring that in to your calls.

Community benchmarks suggest that the cost for usleep() is 72 microseconds on raspi-3 and 130 microseconds on raspi-1, with latency reducing significantly after the first call.

Authors and licenses

Mike McCauley wrote src/bcm2835.{c,h} which are under the GPL.

I wrote the rest, which is under the ISC license unless otherwise specified.

node-rpio's People

Contributors

chriskinsman avatar clik86 avatar jperkin avatar mharsch avatar mlongo4290 avatar nickpiggott avatar priyansh1161 avatar richardstefun avatar themikesanto avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

node-rpio's Issues

Access PWM Timings

Hi,

is it possible to access the raw timings of the PWM with node-rpio? At the moment I set up a test with the python library rpio, which works perfectly well using the set_servo method: http://pythonhosted.org/RPIO/pwm_py.html

However, most of my code base is on JavaScript and I don't want to call python for this job.

I haven't looked into your source yet. Do you use DMA for the PWM signal, too?

Thanks!

Feature Request: Reverse Clock Polarity on PWM

Sometimes it is neccessary to create an orthogonal PWM signals which is not easy to solve at high frequencies with inverters.

The reverse clock polarity feature of the BCM would be great to use here. May you extend the PWM at this e.g. that a call to rpio.open(12,PWM, 1) with init = 1 means that the clock is reversed?

example:

void bcm2835_pwm_set_mode(uint8_t channel, uint8_t markspace, uint8_t enabled, uint8_t reversepolarity)
{

...

  if (channel == 0)
    {
     ...
     if (reversepolarity) 
         control |= BCM2835_PWM0_REVPOLAR;
     else
        control &= ~BCM2835_PWM0_REVPOLAR;
    }
  else if (channel == 1)
    {
 ...
     if (reversepolarity) 
         control |= BCM2835_PWM1_REVPOLAR;
     else
        control &= ~BCM2835_PWM1_REVPOLAR;
    }

Problem with install...

When I run sudo npm install rpio I get a slew of failures:

rpio.target.mk:83: recipe for target 'Release/obj.target/rpio/src/rpio.o' failed
make: *** [Release/obj.target/rpio/src/rpio.o] Error 1
make: Leaving directory '/home/pi/node_modules/rpio/build'
gyp ERR! build error
gyp ERR! stack Error: make failed with exit code: 2
gyp ERR! stack at ChildProcess.onExit (/usr/share/node-gyp/lib/build.js:267:23)
gyp ERR! stack at ChildProcess.emit (events.js:98:17)
gyp ERR! stack at Process.ChildProcess._handle.onexit (child_process.js:809:12)
gyp ERR! System Linux 4.4.38-v7+
gyp ERR! command "nodejs" "/usr/bin/node-gyp" "rebuild"
gyp ERR! cwd /home/pi/node_modules/rpio
gyp ERR! node -v v0.10.29
gyp ERR! node-gyp -v v0.12.2
gyp ERR! not ok
npm WARN This failure might be due to the use of legacy binary "node"
npm WARN For further explanations, please read
/usr/share/doc/nodejs/README.Debian

npm ERR! [email protected] install: node-gyp rebuild
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the [email protected] install script.
npm ERR! This is most likely a problem with the rpio package,
npm ERR! not with npm itself.
npm ERR! Tell the author that this fails on your system:
npm ERR! node-gyp rebuild
npm ERR! You can get their info via:
npm ERR! npm owner ls rpio
npm ERR! There is likely additional logging output above.

npm ERR! System Linux 4.4.38-v7+
npm ERR! command "/usr/bin/nodejs" "/usr/bin/npm" "install" "rpio"
npm ERR! cwd /home/pi
npm ERR! node -v v0.10.29
npm ERR! npm -v 1.4.21
npm ERR! code ELIFECYCLE
npm ERR!
npm ERR! Additional logging details can be found in:
npm ERR! /home/pi/npm-debug.log
npm ERR! not ok code 0

I installed gcc per the directions but there's no change to these error messages. I'm sure I'm doing something simple and stupid.

RPIO in browser (run by javascript): Uncaught TypeError: exists is not a function

Hello,
I have to have RPIO in browser so as to control GPIO by javascript but not node.js. To do that, I used browserify. Everything compiled, but after running test html with attached javascript bundle code I got error: bundle.js:880 Uncaught TypeError: exists is not a function at Function.getRoot (bundle.js:880) at bindings (bundle.js:782) at Object.<anonymous> (bundle.js:42) at Object.2._process (bundle.js:720) at s (bundle.js:1) at bundle.js:1 at Object.1.rpio (bundle.js:2) at s (bundle.js:1) at e (bundle.js:1) at bundle.js:1 getRoot @ bundle.js:880 bindings @ bundle.js:782 (anonymous) @ bundle.js:42 2._process @ bundle.js:720 s @ bundle.js:1 (anonymous) @ bundle.js:1 1.rpio @ bundle.js:2 s @ bundle.js:1 e @ bundle.js:1 (anonymous) @ bundle.js:1

I tried to change exists to fs.exists or fs.existsSync but the same error occupied.

Please help.
Thanks in advance.

Pwm not responding after autologin

When running a script with bashrc using "sudo node /home/pi/test.js", node-rpi does not work with autologin. There is no caught error, and the scripts keeps running and responding to other calls, just not node-rpio. When logging in with the same user, but with password-login, the same script works fine.

What is interesting, is that after logging in over ssh using a password after autologin, the script running in the auologin user also becomes responsive.

It does not seem to be a timing issue. I have attempted adding as much as 30 s wait in case there is any hardware or peripherals that needs initializing.

The issue is also the same using /etc/profile.

getting an error with this script

Im trying to test my spi with this loopback script

var rpio = require('rio');
var rxBuffer = rpio.spiTransfer(new Buffer('HELLOSPI'), 8);
for (var i = 0; i <= 7; i++) { 
 process.stdout.write(String.fromCharCode(rxBuffer[i]) + (i == 7 ? '\n' : ' '));
};

but i get this error.

/home/pi/Railway/node_modules/rpio/lib/rpio.js:641
    return binding.spi_transfer(txbuf, rxbuf, len);
                   ^

TypeError: Incorrect arguments
    at TypeError (native)
    at rpio.spiTransfer (/home/pi/Railway/node_modules/rpio/lib/rpio.js:641:17)
    at Object.<anonymous> (/home/pi/Railway/spitest.js:5:21)
    at Module._compile (module.js:434:26)
    at Object.Module._extensions..js (module.js:452:10)
    at Module.load (module.js:355:32)
    at Function.Module._load (module.js:310:12)
    at Function.Module.runMain (module.js:475:10)
    at startup (node.js:117:18)
    at node.js:951:3

How can i implement below code in this library

I want to implement below python code using this library, if it is possible then how to go about it.

import smbus
import time

def getTempC():
    bus = smbus.SMBus(1)
    bus.write_byte(0x40, 0xF3)
    time.sleep(0.3)
    data0 = bus.read_byte(0x40)
    data1 = bus.read_byte(0x40)
    cTemp = ((data0 * 256 + data1) * 175.72 / 65536.0) - 46.85
    print ("Temperature in Celsius is : %.2f C" %cTemp)
    return cTemp

poll forces IRQ to be disabled

Hi,

running the example poll() snippet from #12 works fine, but when starting the program for the first time, I get a kernel message which produces the following dmesg output:

[   50.439526] irq 73: nobody cared (try booting with the "irqpoll" option)
[   50.439571] CPU: 0 PID: 988 Comm: node Not tainted 4.4.8+ #881
[   50.439587] Hardware name: BCM2708
[   50.439661] [<c0016c9c>] (unwind_backtrace) from [<c0013c20>] (show_stack+0x20/0x24)
[   50.439702] [<c0013c20>] (show_stack) from [<c02e2e1c>] (dump_stack+0x20/0x28)
[   50.439749] [<c02e2e1c>] (dump_stack) from [<c005ced8>] (__report_bad_irq+0x34/0xfc)
[   50.439783] [<c005ced8>] (__report_bad_irq) from [<c005d25c>] (note_interrupt+0x244/0x2a4)
[   50.439815] [<c005d25c>] (note_interrupt) from [<c005ab34>] (handle_irq_event_percpu+0x158/0x1f0)
[   50.439848] [<c005ab34>] (handle_irq_event_percpu) from [<c005ac04>] (handle_irq_event+0x38/0x4c)
[   50.439880] [<c005ac04>] (handle_irq_event) from [<c005d990>] (handle_level_irq+0x9c/0x134)
[   50.439910] [<c005d990>] (handle_level_irq) from [<c005a0e4>] (generic_handle_irq+0x30/0x44)
[   50.439939] [<c005a0e4>] (generic_handle_irq) from [<c005a37c>] (__handle_domain_irq+0x58/0xb8)
[   50.439972] [<c005a37c>] (__handle_domain_irq) from [<c0010748>] (handle_IRQ+0x2c/0x30)
[   50.440003] [<c0010748>] (handle_IRQ) from [<c000940c>] (bcm2835_handle_irq+0x3c/0x58)
[   50.440036] [<c000940c>] (bcm2835_handle_irq) from [<c0571d64>] (__irq_svc+0x44/0x5c)
[   50.440053] Exception stack(0xd68bbeb0 to 0xd68bbef8)
[   50.440074] bea0:                                     00000000 0000000a c0887a40 c081cf74
[   50.440101] bec0: 00000000 c085e3e4 00000002 00000000 00000000 b4be53d4 00df36c0 d68bbf44
[   50.440122] bee0: d68bbf00 d68bbf00 c0025264 c0025268 60000113 ffffffff
[   50.440161] [<c0571d64>] (__irq_svc) from [<c0025268>] (__do_softirq+0xb4/0x314)
[   50.440195] [<c0025268>] (__do_softirq) from [<c002581c>] (irq_exit+0xbc/0x11c)
[   50.440229] [<c002581c>] (irq_exit) from [<c005a384>] (__handle_domain_irq+0x60/0xb8)
[   50.440262] [<c005a384>] (__handle_domain_irq) from [<c0010748>] (handle_IRQ+0x2c/0x30)
[   50.440290] [<c0010748>] (handle_IRQ) from [<c000940c>] (bcm2835_handle_irq+0x3c/0x58)
[   50.440318] [<c000940c>] (bcm2835_handle_irq) from [<c0572034>] (__irq_usr+0x54/0x80)
[   50.440335] Exception stack(0xd68bbfb0 to 0xd68bbff8)
[   50.440355] bfa0:                                     b3d0004c 00000010 00000010 00000000
[   50.440379] bfc0: be8b3708 be8b3738 be8b37a8 b4be72c8 00b8c46d b4be53d4 00df36c0 be8b3704
[   50.440401] bfe0: b4bf99d0 be8b36e0 b4be7504 b4be7504 60000010 ffffffff
[   50.440412] handlers:
[   50.440437] [<c030c684>] bcm2835_gpio_irq_handler
[   50.440457] Disabling IRQ #73
[  109.789711] gpiomem-bcm2835 20200000.gpiomem: gpiomem device opened.

Is it possible to circumvent this problem or do I have to add the kernel option irqpoll? I read the manual polling is quite slow compared to real IRQ's, or is this impossible with gpiomem?

Thanks Robert

Precision read of time duration of high pin

Hello,
This works great for a few projects but I'm struggling to get good precision timing of a pin going high with signal from an ultrasonic sensor..
(standard kit HC-SR04 - you send a high value to a trigger pin to tell it to measure the distance and it replies on an echo pin by setting a high value for the number of micro/nano seconds the ultrasound took to rebound off the nearest object). You're supposed to measure the time of the pulse and calculate distance using the speed of sound.

I tried a read loop with simple conditions to catch the edges and get accurate time measurement from process.hrtime but I can't seem to get any level of consistency in results. Have tried readbuf (like the example in the docs) and then try to guess the time between the edges (by measuring the total time to execute readbuf and dividing by buffer length - then multiplying by number of high values in the buffer)... but still can't seem to get reliably repeatable results.

I have some python code that runs on the same hardware which gives repeatable measurements but really wanted to stay in node.

Any suggestions of best way to get precision time measurement of a high pin pulse ?

Many thanks.

PWM units

Hi, I belieave there is an error in units in PWM in documentation. If refresh rate is set to 2048, than the frequecy is 9.375Hz and not 9.375kHz.

How to use this lib with LCD communicated via SPI?

I have a LCD screen communicated with the pi using HDMI and SPI (SPI for touches). Now every time I started to use this lib, it will take control of the SPI ports and the screen will automatically stop working. Any idea I can I leave SPI open for the screen?

usleep

It seems like microsecond sleep is seriously lacking precision. I was able to get much better results, though, still not too good, using node "microsleep" module to measure time in a silly while loop

while
    (
        microtime.now()
    <
        x
    )
    {
    }

Request: Please add option for rpio.poll e.g. debounce, polling Interval

Hello,
This module work very nice, and it's cover almost all use case, easy to install. But sometime rpio.poll call rapidly

(Pin 7 connected to contact relay)

var rpio = require('rpio');

rpio.open(11, rpio.INPUT, rpio.PULL_UP);
rpio.open(7, rpio.OUTPUT, rpio.HIGH);

var output1State = rpio.HIGH;
setInterval(function(){
	console.log("------------")
	output1State = output1State == rpio.HIGH ? rpio.LOW : rpio.HIGH;
	rpio.write(7, output1State);
}, 1000);

function pollcb(pin)
{
    var state = rpio.read(pin) ? 'pressed' : 'released';
    console.log('Button event on P%d (button currently %s)', pin, state);
}
 
rpio.poll(11, pollcb);

OUTPUT

------------
Button event on P11 (button currently pressed)
------------
Button event on P11 (button currently released)
Button event on P11 (button currently released)
Button event on P11 (button currently released)
------------
Button event on P11 (button currently pressed)
------------
Button event on P11 (button currently released)
Button event on P11 (button currently pressed)
Button event on P11 (button currently released)
Button event on P11 (button currently released)

Pi Zero W Compatibility

As the Pi Zero W has a different hardware revision to the Zero, running rpio fails.

9000c1 is the new rev so I believe 0xc1 is what needs to be added! (Adding it manually to rpio.js seems to work)

Cannot open pin in PWM mode

On a Raspberry Pi 3 I cannot open pin 35 in PWM mode.

I even tried changing the permissions on /dev/gpiomem so that pi is the owner, not just group membership, but to no avail.

Every time I try to open:

rpio.open(35, rpio.PWM)

I get a permission denied error:

bcm2835_init: Unable to open /dev/mem: Permission denied
/home/pi/laundry/node_modules/rpio/lib/rpio.js:104
	return bindfunc(optarg);
	       ^

Error: Could not initialize bcm2835 GPIO library
    at bindcall (/home/pi/laundry/node_modules/rpio/lib/rpio.js:104:9)
    at EventEmitter.rpio.init (/home/pi/laundry/node_modules/rpio/lib/rpio.js:460:2)
    at rpio.open (/home/pi/laundry/node_modules/rpio/lib/rpio.js:470:18)
    at initIndicator (/home/pi/laundry/index.js:139:8)

Led pulse not working

Hey,

Running the given example (without any modification) on Raspberry Pi 3 Model B lights the LED and does not pulse it. Using Piscope I see that value of 1 is set for the whole duration - from open to close, no matter what I pass to pwmSetData. I even tried to change Clock Divider values and set different range with no success. Any ideas what could be wrong? I use GPIO18 (pin 12), as used in the example.

Another thing - it would be really nice if one could set duty cycle and forget about setting those other values which I have no idea about yet.
I have managed to pulse the led only with pigpio's (node.js) and RPi.GPIO's (python) duty cycle methods.

Example how to use ultrasonic sensor?

Here is python example:

import RPi.GPIO as GPIO                    #Import GPIO library
import time                                #Import time library
GPIO.setmode(GPIO.BCM)                     #Set GPIO pin numbering 

TRIG = 23                                  #Associate pin 23 to TRIG
ECHO = 24                                  #Associate pin 24 to ECHO

print "Distance measurement in progress"

GPIO.setup(TRIG,GPIO.OUT)                  #Set pin as GPIO out
GPIO.setup(ECHO,GPIO.IN)                   #Set pin as GPIO in

while True:

  GPIO.output(TRIG, False)                 #Set TRIG as LOW
  print "Waitng For Sensor To Settle"
  time.sleep(2)                            #Delay of 2 seconds

  GPIO.output(TRIG, True)                  #Set TRIG as HIGH
  time.sleep(0.00001)                      #Delay of 0.00001 seconds
  GPIO.output(TRIG, False)                 #Set TRIG as LOW

  while GPIO.input(ECHO)==0:               #Check whether the ECHO is LOW
    pulse_start = time.time()              #Saves the last known time of LOW pulse

  while GPIO.input(ECHO)==1:               #Check whether the ECHO is HIGH
    pulse_end = time.time()                #Saves the last known time of HIGH pulse 

  pulse_duration = pulse_end - pulse_start #Get pulse duration to a variable

  distance = pulse_duration * 17150        #Multiply pulse duration by 17150 to get distance
  distance = round(distance, 2)            #Round to two decimal points

  if distance > 2 and distance < 400:      #Check whether the distance is within range
    print "Distance:",distance - 0.5,"cm"  #Print distance with 0.5 cm calibration
  else:
    print "Out Of Range"                   #display out of range

Segmentation fault on binding require

Environment

  • Raspberry Pi Model B Rev. 2 (hardware: BCM2708, revision: 000d)
  • Raspbian Wheezy 7.8
  • Node 0.10.24
  • rpio 0.4.2

Steps to reproduce

  1. npm install [email protected]
  2. The rpio.node build succeeds.
  3. root@host# node
  4. > require('rpio')

Result

Segmentation fault

The segfault is happening at the top of rpio.js while loading the native C binding:

var binding = require('../build/Release/rpio');

I don't know how to debug this any further, but I'd be happy to try to help figure this out.

Supporting Allwinner chips

I understand that this is more like a feature request, because this library is "Raspberry Pi GPIO interface", but I really like this NPM module and I am using quite long time and I am not using only RPI. So I extended this project and implemented the C++ part for Allwinner's H3 and H5 chips (nanopi and orange pi boards). The module finds out what board you are using and uses right code using the same, unchanged node interface. I would like to publish it to NPM, so I am asking all of you guys, do you think that I should publish it under different NPM module name, or just ask for pull request to this original "rpio" NPM module? Thanks a lot.

no gpio group

In case I'm not using default distro supplied with raspi, how should I proceed forward with it since I might have no gpio group.

Has the latest code base in master been deployed to NPM?

I'm looking at the code in the latest npm package version 0.19.9 and this contains hardcoded console log's in the default_read_handler etc.

But looking in master here this code is not present. Could you push the latest code to a new version on NPM please so we don't get these logs?

HOWTO: Software SPI setting

Hi All,

I wants to move my ruby/sinatra project to Node.js, but I'm facing an issue. Because of my hardware design is fixed and SPI wired(read MCP3008) I currently using was config by software SPI. I found here has SPI interface but all the example is for hardware SPI. I'm wondering how to use rpio to write a software SPI interface, thanks!

EEprom

Hi,
I am working with an eeprom 24lc512 memory for the i2c protocol. I would like to know if I can see an example with node-rpio since I have tried it in several ways and it has not been possible.

Use a "mock" mode for non-RPi platforms

It would be nice to add some mock mode for developing apps on other platforms than Raspberry Pi.

E.g. I'm developing and debugging node app on PC (which uses also rpio module for some minor functionality), although in production it will be running on the Raspberry Pi. But, when I want to test the app on PC/Mac (without rpio functionality, of course) I have to comment out all usages of rpio, otherwise app crashes with an error:

fs.js:640
return binding.open(pathModule._makeLong(path), stringToFlags(flags), mode);
^

Error: ENOENT: no such file or directory, open '/proc/cpuinfo'

So my idea is that rpio can detect platform on which is running and on platforms other than Raspberry Pi, it will show some warning message like "Your platform is not compatible with module, RPIO functionality will not be available." instead of causing the node app to crash.

Asynchronous calls with node-rpio

This is not an issue but I'm looking for input and apologize if this is not the correct place to post this. I'm currently working on a project that requires Asynchronous calls to your node-rpio module. To accomplish this, I have written a node class that wraps around the node-rpio module and forks it into a child process when an async call is necessary. Here is an example of one of my classes on git hub. From my testing so far this seems to work very well!

Is this okay? Is there another way or better way to make async calls to node-rpio that I may have overlooked?

RPI 1

I try your code in RaspberryPI 1.
Using mapping = 'gpio' seems does not work.
Reverting to mapping = 'physical' work correctly.

Cannot get switch events (press/release)

I followed the readme instructions to read the status of a switch but there is no output on the console when I press or release the button.

I've installed rpio via npm
I added pi and root users to gpio group
I added the rule as root
I connected the switch between PIN 6 and PIN 15 (GPIO022)
I ran the program as pi as well as root

I never get an output when pressing the button

I logged to the console the rpio object and I got this (it may be useful):
{ domain: null, _events: {}, _maxListeners: 10 }

Can you please help me to start using this library?

Stack Trace Exception on GPIO IR Handler on Raspbian

When we try to use the library, the kernel produces this:

[   22.773531] irq 79: nobody cared (try booting with the "irqpoll" option)
[   22.773550] CPU: 0 PID: 1367 Comm: nodejs Not tainted 4.4.50 #1
[   22.773554] Hardware name: BCM2709
[   22.773580] [<80018734>] (unwind_backtrace) from [<80014044>] (show_stack+0x20/0x24)
[   22.773593] [<80014044>] (show_stack) from [<80323d64>] (dump_stack+0xc8/0x10c)
[   22.773606] [<80323d64>] (dump_stack) from [<80074a38>] (__report_bad_irq+0x3c/0xdc)
[   22.773618] [<80074a38>] (__report_bad_irq) from [<80074e5c>] (note_interrupt+0x29c/0x2ec)
[   22.773629] [<80074e5c>] (note_interrupt) from [<80072084>] (handle_irq_event_percpu+0x1f0/0x258)
[   22.773639] [<80072084>] (handle_irq_event_percpu) from [<80072140>] (handle_irq_event+0x54/0x78)
[   22.773649] [<80072140>] (handle_irq_event) from [<800755c0>] (handle_level_irq+0xb8/0x164)
[   22.773659] [<800755c0>] (handle_level_irq) from [<800714e0>] (generic_handle_irq+0x34/0x44)
[   22.773672] [<800714e0>] (generic_handle_irq) from [<803491c4>] (bcm2836_chained_handle_irq+0x3c/0x50)
[   22.773683] [<803491c4>] (bcm2836_chained_handle_irq) from [<800714e0>] (generic_handle_irq+0x34/0x44)
[   22.773693] [<800714e0>] (generic_handle_irq) from [<800717ec>] (__handle_domain_irq+0x6c/0xc4)
[   22.773703] [<800717ec>] (__handle_domain_irq) from [<80010a10>] (handle_IRQ+0x28/0x2c)
[   22.773714] [<80010a10>] (handle_IRQ) from [<80009534>] (bcm2836_arm_irqchip_handle_irq+0xb8/0xbc)
[   22.773726] [<80009534>] (bcm2836_arm_irqchip_handle_irq) from [<805c114c>] (__irq_usr+0x4c/0x60)
[   22.773732] Exception stack(0xa7e3ffb0 to 0xa7e3fff8)
[   22.773738] ffa0:                                     7efc8c28 00400000 00000002 00000003
[   22.773747] ffc0: 7efc8a90 7efc8af4 7efc8b70 74b3a2ec 3ee04141 0167a4a8 00000001 7efc8a8c
[   22.773754] ffe0: 74b4d170 7efc8a68 74b3a54c 74b3a554 60000010 ffffffff
[   22.773760] handlers:
[   22.773768] [<8034f46c>] bcm2835_gpio_irq_handler
[   22.773774] Disabling IRQ #79

and other devices (like modem) are not working.

rpio.poll(...) callback executed after polling stopped.

function cb() {
  console.log('on poll');
}

rpio.poll(pin, cb);
...
rpio.poll(pin, null);
// The cb() function is often called after we deregister

Would it be possible to prevent callbacks on a pin from being sent if poll is deregistered?

warn against mixing rpio SPI with spi-bcm2835 + spidev

rpio SPI can't coexist with the regular linux SPI kernel module (at least for a given spi bus). Running a rpio SPI script on a system with spi-bcm2835 loaded will corrupt the state of the kernel module and break any subsequent calls to it's interface (silently). We should include a warning in the documentation.

multiple i2c devices

Thank you for an excellent interface to Raspberry PI. Maybe I'm not reading the docs properly but how do you address multiple i2c devices?

Sonny

Is it possible to change polling window?

In the readme it says,

Interrupts aren't supported by the underlying hardware, so events may be missed during the 1ms poll window.

Does this mean that the pin is polling at a frequency of 1kHz i.e. once per 1ms?

Is it possible for me to reduce or increase the sampling frequency?

open with pud option may not be working

Hi,
On a RPi3 (haven't tested earlier versions) we have a range of I/O, both static and polled. One of our polled inputs was acting as if it was floating as we were detecting a simple proximity switch to ground. Any noise (or simply touching the lead) was triggering the poll detect.

rpio.open(7, rpio.INPUT, rpio.PULL_UP);

We found that declaring the input, followed by the pud assignment (no other code changes) has fixed the issue.

rpio.open(7, rpio.INPUT);
rpio.pud(7, rpio.PULL_UP);

Not sure if it's an issue but more in case someone else needs a hand. Will dig further once we get a chance.

Fails to install with npm 3.10.8 on node 6.9.1

Hi!

Getting the following when running 'npm install rpio --save' on my Raspberry PI 3 (OS: Miniban).
Also getting the same error on Ubuntu 16.04 using the same version of Node.js.

> [email protected] install /home/gobban/rpi-nodejs/node_modules/rpio
> node-gyp rebuild

gyp ERR! build error 
gyp ERR! stack Error: not found: make
gyp ERR! stack     at getNotFoundError (/usr/lib/node_modules/npm/node_modules/which/which.js:14:12)
gyp ERR! stack     at F (/usr/lib/node_modules/npm/node_modules/which/which.js:69:19)
gyp ERR! stack     at E (/usr/lib/node_modules/npm/node_modules/which/which.js:81:29)
gyp ERR! stack     at /usr/lib/node_modules/npm/node_modules/which/which.js:90:16
gyp ERR! stack     at /usr/lib/node_modules/npm/node_modules/which/node_modules/isexe/index.js:44:5
gyp ERR! stack     at /usr/lib/node_modules/npm/node_modules/which/node_modules/isexe/access.js:8:5
gyp ERR! stack     at FSReqWrap.oncomplete (fs.js:123:15)
gyp ERR! System Linux 4.4.32-v7+
gyp ERR! command "/usr/bin/nodejs" "/usr/lib/node_modules/npm/node_modules/node-gyp/bin/node-gyp.js" "rebuild"
gyp ERR! cwd /home/gobban/rpi-nodejs/node_modules/rpio
gyp ERR! node -v v6.9.1
gyp ERR! node-gyp -v v3.4.0
gyp ERR! not ok 
npm WARN [email protected] No repository field.
npm ERR! Linux 4.4.32-v7+
npm ERR! argv "/usr/bin/nodejs" "/usr/bin/npm" "install" "rpio" "--save"
npm ERR! node v6.9.1
npm ERR! npm  v3.10.8
npm ERR! code ELIFECYCLE

npm ERR! [email protected] install: `node-gyp rebuild`
npm ERR! Exit status 1
npm ERR! 
npm ERR! Failed at the [email protected] install script 'node-gyp rebuild'.
npm ERR! Make sure you have the latest version of node.js and npm installed.
npm ERR! If you do, this is most likely a problem with the rpio package,
npm ERR! not with npm itself.
npm ERR! Tell the author that this fails on your system:
npm ERR!     node-gyp rebuild
npm ERR! You can get information on how to open an issue for this project with:
npm ERR!     npm bugs rpio
npm ERR! Or if that isn't available, you can get their info via:
npm ERR!     npm owner ls rpio
npm ERR! There is likely additional logging output above.

npm ERR! Please include the following file with any support request:
npm ERR!     /home/gobban/rpi-nodejs/npm-debug.log

npm-debug.log:

0 info it worked if it ends with ok
1 verbose cli [ '/usr/bin/nodejs', '/usr/bin/npm', 'install', 'rpio', '--save' ]
2 info using [email protected]
3 info using [email protected]
4 silly loadCurrentTree Starting
5 silly install loadCurrentTree
6 silly install readLocalPackageData
7 silly fetchPackageMetaData rpio
8 silly fetchNamedPackageData rpio
9 silly mapToRegistry name rpio
10 silly mapToRegistry using default registry
11 silly mapToRegistry registry https://registry.npmjs.org/
12 silly mapToRegistry data Result {
12 silly mapToRegistry   raw: 'rpio',
12 silly mapToRegistry   scope: null,
12 silly mapToRegistry   escapedName: 'rpio',
12 silly mapToRegistry   name: 'rpio',
12 silly mapToRegistry   rawSpec: '',
12 silly mapToRegistry   spec: 'latest',
12 silly mapToRegistry   type: 'tag' }
13 silly mapToRegistry uri https://registry.npmjs.org/rpio
14 verbose request uri https://registry.npmjs.org/rpio
15 verbose request no auth needed
16 info attempt registry request try #1 at 8:19:05 PM
17 verbose request id 75a4a57b253a2da8
18 verbose etag W/"57b6c25a-174e6"
19 verbose lastModified Fri, 19 Aug 2016 08:24:58 GMT
20 http request GET https://registry.npmjs.org/rpio
21 http 304 https://registry.npmjs.org/rpio
22 verbose headers { date: 'Mon, 21 Nov 2016 19:19:05 GMT',
22 verbose headers   via: '1.1 varnish',
22 verbose headers   'cache-control': 'max-age=300',
22 verbose headers   etag: 'W/"57b6c25a-174e6"',
22 verbose headers   age: '0',
22 verbose headers   connection: 'keep-alive',
22 verbose headers   'x-served-by': 'cache-bma7030-BMA',
22 verbose headers   'x-cache': 'HIT',
22 verbose headers   'x-cache-hits': '1',
22 verbose headers   'x-timer': 'S1479755945.321921,VS0,VE25',
22 verbose headers   vary: 'Accept-Encoding' }
23 silly get cb [ 304,
23 silly get   { date: 'Mon, 21 Nov 2016 19:19:05 GMT',
23 silly get     via: '1.1 varnish',
23 silly get     'cache-control': 'max-age=300',
23 silly get     etag: 'W/"57b6c25a-174e6"',
23 silly get     age: '0',
23 silly get     connection: 'keep-alive',
23 silly get     'x-served-by': 'cache-bma7030-BMA',
23 silly get     'x-cache': 'HIT',
23 silly get     'x-cache-hits': '1',
23 silly get     'x-timer': 'S1479755945.321921,VS0,VE25',
23 silly get     vary: 'Accept-Encoding' } ]
24 verbose etag https://registry.npmjs.org/rpio from cache
25 verbose get saving rpio to /home/gobban/.npm/registry.npmjs.org/rpio/.cache.json
26 verbose correctMkdir /home/gobban/.npm correctMkdir not in flight; initializing
27 silly install normalizeTree
28 silly loadCurrentTree Finishing
29 silly loadIdealTree Starting
30 silly install loadIdealTree
31 silly cloneCurrentTree Starting
32 silly install cloneCurrentTreeToIdealTree
33 silly cloneCurrentTree Finishing
34 silly loadShrinkwrap Starting
35 silly install loadShrinkwrap
36 silly loadShrinkwrap Finishing
37 silly loadAllDepsIntoIdealTree Starting
38 silly install loadAllDepsIntoIdealTree
39 silly resolveWithNewModule [email protected] checking installable status
40 silly cache add args [ 'rpio', null ]
41 verbose cache add spec rpio
42 silly cache add parsed spec Result {
42 silly cache add   raw: 'rpio',
42 silly cache add   scope: null,
42 silly cache add   escapedName: 'rpio',
42 silly cache add   name: 'rpio',
42 silly cache add   rawSpec: '',
42 silly cache add   spec: 'latest',
42 silly cache add   type: 'tag' }
43 silly addNamed rpio@latest
44 verbose addNamed "latest" is being treated as a dist-tag for rpio
45 info addNameTag [ 'rpio', 'latest' ]
46 silly mapToRegistry name rpio
47 silly mapToRegistry using default registry
48 silly mapToRegistry registry https://registry.npmjs.org/
49 silly mapToRegistry data Result {
49 silly mapToRegistry   raw: 'rpio',
49 silly mapToRegistry   scope: null,
49 silly mapToRegistry   escapedName: 'rpio',
49 silly mapToRegistry   name: 'rpio',
49 silly mapToRegistry   rawSpec: '',
49 silly mapToRegistry   spec: 'latest',
49 silly mapToRegistry   type: 'tag' }
50 silly mapToRegistry uri https://registry.npmjs.org/rpio
51 verbose addNameTag registry:https://registry.npmjs.org/rpio not in flight; fetching
52 verbose get https://registry.npmjs.org/rpio not expired, no request
53 silly addNameTag next cb for rpio with tag latest
54 silly addNamed [email protected]
55 verbose addNamed "0.9.12" is a plain semver version for rpio
56 silly cache afterAdd [email protected]
57 verbose afterAdd /home/gobban/.npm/rpio/0.9.12/package/package.json not in flight; writing
58 verbose correctMkdir /home/gobban/.npm correctMkdir not in flight; initializing
59 verbose afterAdd /home/gobban/.npm/rpio/0.9.12/package/package.json written
60 silly fetchNamedPackageData bindings
61 silly mapToRegistry name bindings
62 silly mapToRegistry using default registry
63 silly mapToRegistry registry https://registry.npmjs.org/
64 silly mapToRegistry data Result {
64 silly mapToRegistry   raw: 'bindings',
64 silly mapToRegistry   scope: null,
64 silly mapToRegistry   escapedName: 'bindings',
64 silly mapToRegistry   name: 'bindings',
64 silly mapToRegistry   rawSpec: '',
64 silly mapToRegistry   spec: 'latest',
64 silly mapToRegistry   type: 'tag' }
65 silly mapToRegistry uri https://registry.npmjs.org/bindings
66 silly fetchNamedPackageData nan
67 silly mapToRegistry name nan
68 silly mapToRegistry using default registry
69 silly mapToRegistry registry https://registry.npmjs.org/
70 silly mapToRegistry data Result {
70 silly mapToRegistry   raw: 'nan',
70 silly mapToRegistry   scope: null,
70 silly mapToRegistry   escapedName: 'nan',
70 silly mapToRegistry   name: 'nan',
70 silly mapToRegistry   rawSpec: '',
70 silly mapToRegistry   spec: 'latest',
70 silly mapToRegistry   type: 'tag' }
71 silly mapToRegistry uri https://registry.npmjs.org/nan
72 verbose request uri https://registry.npmjs.org/bindings
73 verbose request no auth needed
74 info attempt registry request try #1 at 8:19:05 PM
75 verbose etag W/"580645d3-46f7"
76 verbose lastModified Tue, 18 Oct 2016 15:54:59 GMT
77 http request GET https://registry.npmjs.org/bindings
78 verbose request uri https://registry.npmjs.org/nan
79 verbose request no auth needed
80 info attempt registry request try #1 at 8:19:05 PM
81 verbose etag W/"5818d749-1ce1e"
82 verbose lastModified Tue, 01 Nov 2016 17:56:25 GMT
83 http request GET https://registry.npmjs.org/nan
84 http 304 https://registry.npmjs.org/bindings
85 verbose headers { date: 'Mon, 21 Nov 2016 19:19:05 GMT',
85 verbose headers   via: '1.1 varnish',
85 verbose headers   'cache-control': 'max-age=300',
85 verbose headers   etag: 'W/"580645d3-46f7"',
85 verbose headers   age: '127',
85 verbose headers   connection: 'keep-alive',
85 verbose headers   'x-served-by': 'cache-bma7030-BMA',
85 verbose headers   'x-cache': 'HIT',
85 verbose headers   'x-cache-hits': '1',
85 verbose headers   'x-timer': 'S1479755945.537913,VS0,VE0',
85 verbose headers   vary: 'Accept-Encoding' }
86 silly get cb [ 304,
86 silly get   { date: 'Mon, 21 Nov 2016 19:19:05 GMT',
86 silly get     via: '1.1 varnish',
86 silly get     'cache-control': 'max-age=300',
86 silly get     etag: 'W/"580645d3-46f7"',
86 silly get     age: '127',
86 silly get     connection: 'keep-alive',
86 silly get     'x-served-by': 'cache-bma7030-BMA',
86 silly get     'x-cache': 'HIT',
86 silly get     'x-cache-hits': '1',
86 silly get     'x-timer': 'S1479755945.537913,VS0,VE0',
86 silly get     vary: 'Accept-Encoding' } ]
87 verbose etag https://registry.npmjs.org/bindings from cache
88 verbose get saving bindings to /home/gobban/.npm/registry.npmjs.org/bindings/.cache.json
89 verbose correctMkdir /home/gobban/.npm correctMkdir not in flight; initializing
90 silly resolveWithNewModule [email protected] checking installable status
91 silly cache add args [ 'bindings@*', null ]
92 verbose cache add spec bindings@*
93 silly cache add parsed spec Result {
93 silly cache add   raw: 'bindings@*',
93 silly cache add   scope: null,
93 silly cache add   escapedName: 'bindings',
93 silly cache add   name: 'bindings',
93 silly cache add   rawSpec: '*',
93 silly cache add   spec: '*',
93 silly cache add   type: 'range' }
94 silly addNamed bindings@*
95 verbose addNamed "*" is a valid semver range for bindings
96 silly addNameRange { name: 'bindings', range: '*', hasData: false }
97 silly mapToRegistry name bindings
98 silly mapToRegistry using default registry
99 silly mapToRegistry registry https://registry.npmjs.org/
100 silly mapToRegistry data Result {
100 silly mapToRegistry   raw: 'bindings',
100 silly mapToRegistry   scope: null,
100 silly mapToRegistry   escapedName: 'bindings',
100 silly mapToRegistry   name: 'bindings',
100 silly mapToRegistry   rawSpec: '',
100 silly mapToRegistry   spec: 'latest',
100 silly mapToRegistry   type: 'tag' }
101 silly mapToRegistry uri https://registry.npmjs.org/bindings
102 verbose addNameRange registry:https://registry.npmjs.org/bindings not in flight; fetching
103 verbose get https://registry.npmjs.org/bindings not expired, no request
104 silly addNameRange number 2 { name: 'bindings', range: '*', hasData: true }
105 silly addNameRange versions [ 'bindings',
105 silly addNameRange   [ '0.0.1',
105 silly addNameRange     '0.1.0',
105 silly addNameRange     '0.1.1',
105 silly addNameRange     '0.2.0',
105 silly addNameRange     '0.2.1',
105 silly addNameRange     '0.2.2',
105 silly addNameRange     '0.2.3',
105 silly addNameRange     '0.2.4',
105 silly addNameRange     '0.3.0',
105 silly addNameRange     '0.4.0',
105 silly addNameRange     '1.0.0',
105 silly addNameRange     '1.1.0',
105 silly addNameRange     '1.1.1',
105 silly addNameRange     '1.2.0',
105 silly addNameRange     '1.2.1' ] ]
106 silly addNamed [email protected]
107 verbose addNamed "1.2.1" is a plain semver version for bindings
108 silly cache afterAdd [email protected]
109 verbose afterAdd /home/gobban/.npm/bindings/1.2.1/package/package.json not in flight; writing
110 verbose correctMkdir /home/gobban/.npm correctMkdir not in flight; initializing
111 verbose afterAdd /home/gobban/.npm/bindings/1.2.1/package/package.json written
112 http 304 https://registry.npmjs.org/nan
113 verbose headers { date: 'Mon, 21 Nov 2016 19:19:05 GMT',
113 verbose headers   via: '1.1 varnish',
113 verbose headers   'cache-control': 'max-age=300',
113 verbose headers   etag: 'W/"5818d749-1ce1e"',
113 verbose headers   age: '271',
113 verbose headers   connection: 'keep-alive',
113 verbose headers   'x-served-by': 'cache-bma7031-BMA',
113 verbose headers   'x-cache': 'HIT',
113 verbose headers   'x-cache-hits': '2',
113 verbose headers   'x-timer': 'S1479755945.576695,VS0,VE0',
113 verbose headers   vary: 'Accept-Encoding' }
114 silly get cb [ 304,
114 silly get   { date: 'Mon, 21 Nov 2016 19:19:05 GMT',
114 silly get     via: '1.1 varnish',
114 silly get     'cache-control': 'max-age=300',
114 silly get     etag: 'W/"5818d749-1ce1e"',
114 silly get     age: '271',
114 silly get     connection: 'keep-alive',
114 silly get     'x-served-by': 'cache-bma7031-BMA',
114 silly get     'x-cache': 'HIT',
114 silly get     'x-cache-hits': '2',
114 silly get     'x-timer': 'S1479755945.576695,VS0,VE0',
114 silly get     vary: 'Accept-Encoding' } ]
115 verbose etag https://registry.npmjs.org/nan from cache
116 verbose get saving nan to /home/gobban/.npm/registry.npmjs.org/nan/.cache.json
117 verbose correctMkdir /home/gobban/.npm correctMkdir not in flight; initializing
118 silly resolveWithNewModule [email protected] checking installable status
119 silly cache add args [ 'nan@*', null ]
120 verbose cache add spec nan@*
121 silly cache add parsed spec Result {
121 silly cache add   raw: 'nan@*',
121 silly cache add   scope: null,
121 silly cache add   escapedName: 'nan',
121 silly cache add   name: 'nan',
121 silly cache add   rawSpec: '*',
121 silly cache add   spec: '*',
121 silly cache add   type: 'range' }
122 silly addNamed nan@*
123 verbose addNamed "*" is a valid semver range for nan
124 silly addNameRange { name: 'nan', range: '*', hasData: false }
125 silly mapToRegistry name nan
126 silly mapToRegistry using default registry
127 silly mapToRegistry registry https://registry.npmjs.org/
128 silly mapToRegistry data Result {
128 silly mapToRegistry   raw: 'nan',
128 silly mapToRegistry   scope: null,
128 silly mapToRegistry   escapedName: 'nan',
128 silly mapToRegistry   name: 'nan',
128 silly mapToRegistry   rawSpec: '',
128 silly mapToRegistry   spec: 'latest',
128 silly mapToRegistry   type: 'tag' }
129 silly mapToRegistry uri https://registry.npmjs.org/nan
130 verbose addNameRange registry:https://registry.npmjs.org/nan not in flight; fetching
131 verbose get https://registry.npmjs.org/nan not expired, no request
132 silly addNameRange number 2 { name: 'nan', range: '*', hasData: true }
133 silly addNameRange versions [ 'nan',
133 silly addNameRange   [ '0.3.0-wip',
133 silly addNameRange     '0.3.0-wip2',
133 silly addNameRange     '0.3.0',
133 silly addNameRange     '0.3.1',
133 silly addNameRange     '0.3.2',
133 silly addNameRange     '0.4.0',
133 silly addNameRange     '0.4.1',
133 silly addNameRange     '0.4.2',
133 silly addNameRange     '0.4.3',
133 silly addNameRange     '0.4.4',
133 silly addNameRange     '0.5.0',
133 silly addNameRange     '0.5.1',
133 silly addNameRange     '0.5.2',
133 silly addNameRange     '0.6.0',
133 silly addNameRange     '0.7.0',
133 silly addNameRange     '0.7.1',
133 silly addNameRange     '0.8.0',
133 silly addNameRange     '1.0.0',
133 silly addNameRange     '1.1.0',
133 silly addNameRange     '1.1.1',
133 silly addNameRange     '1.1.2',
133 silly addNameRange     '1.2.0',
133 silly addNameRange     '1.3.0',
133 silly addNameRange     '1.4.0',
133 silly addNameRange     '1.4.1',
133 silly addNameRange     '1.5.0',
133 silly addNameRange     '1.4.2',
133 silly addNameRange     '1.4.3',
133 silly addNameRange     '1.5.1',
133 silly addNameRange     '1.5.2',
133 silly addNameRange     '1.6.0',
133 silly addNameRange     '1.5.3',
133 silly addNameRange     '1.6.1',
133 silly addNameRange     '1.6.2',
133 silly addNameRange     '1.7.0',
133 silly addNameRange     '1.8.0',
133 silly addNameRange     '1.8.1',
133 silly addNameRange     '1.8.2',
133 silly addNameRange     '1.8.3',
133 silly addNameRange     '1.8.4',
133 silly addNameRange     '1.9.0',
133 silly addNameRange     '2.0.0',
133 silly addNameRange     '2.0.1',
133 silly addNameRange     '2.0.2',
133 silly addNameRange     '2.0.3',
133 silly addNameRange     '2.0.4',
133 silly addNameRange     '2.0.5',
133 silly addNameRange     '2.0.6',
133 silly addNameRange     '2.0.7',
133 silly addNameRange     '2.0.8',
133 silly addNameRange     '2.0.9',
133 silly addNameRange     '2.1.0',
133 silly addNameRange     '2.2.0',
133 silly addNameRange     '2.2.1',
133 silly addNameRange     '2.3.0',
133 silly addNameRange     '2.3.1',
133 silly addNameRange     '2.3.2',
133 silly addNameRange     '2.3.3',
133 silly addNameRange     '2.3.4',
133 silly addNameRange     '2.3.5',
133 silly addNameRange     '2.4.0' ] ]
134 silly addNamed [email protected]
135 verbose addNamed "2.4.0" is a plain semver version for nan
136 silly cache afterAdd [email protected]
137 verbose afterAdd /home/gobban/.npm/nan/2.4.0/package/package.json not in flight; writing
138 verbose correctMkdir /home/gobban/.npm correctMkdir not in flight; initializing
139 verbose afterAdd /home/gobban/.npm/nan/2.4.0/package/package.json written
140 silly loadAllDepsIntoIdealTree Finishing
141 silly loadIdealTree Finishing
142 silly currentTree [email protected]
142 silly currentTree ├── [email protected]
142 silly currentTree ├── [email protected]
142 silly currentTree ├── [email protected]
142 silly currentTree ├── [email protected]
142 silly currentTree ├── [email protected]
142 silly currentTree ├── [email protected]
142 silly currentTree ├── [email protected]
142 silly currentTree ├── [email protected]
142 silly currentTree ├── [email protected]
142 silly currentTree ├── [email protected]
142 silly currentTree ├── [email protected]
142 silly currentTree ├── [email protected]
142 silly currentTree ├── [email protected]
142 silly currentTree ├── [email protected]
142 silly currentTree ├── [email protected]
142 silly currentTree ├── [email protected]
142 silly currentTree ├── [email protected]
142 silly currentTree ├── [email protected]
142 silly currentTree ├── [email protected]
142 silly currentTree ├── [email protected]
142 silly currentTree ├── [email protected]
142 silly currentTree ├── [email protected]
142 silly currentTree ├── [email protected]
142 silly currentTree ├── [email protected]
142 silly currentTree ├── [email protected]
142 silly currentTree ├── [email protected]
142 silly currentTree ├── [email protected]
142 silly currentTree ├── [email protected]
142 silly currentTree ├── [email protected]
142 silly currentTree ├── [email protected]
142 silly currentTree ├── [email protected]
142 silly currentTree ├── [email protected]
142 silly currentTree ├── [email protected]
142 silly currentTree ├── [email protected]
142 silly currentTree ├── [email protected]
142 silly currentTree ├── [email protected]
142 silly currentTree ├── [email protected]
142 silly currentTree ├── [email protected]
142 silly currentTree ├── [email protected]
142 silly currentTree ├── [email protected]
142 silly currentTree ├── [email protected]
142 silly currentTree ├── [email protected]
142 silly currentTree ├── [email protected]
142 silly currentTree ├── [email protected]
142 silly currentTree ├── [email protected]
142 silly currentTree ├── [email protected]
142 silly currentTree ├── [email protected]
142 silly currentTree ├── [email protected]
142 silly currentTree ├── [email protected]
142 silly currentTree └── [email protected]
143 silly idealTree [email protected]
143 silly idealTree ├── [email protected]
143 silly idealTree ├── [email protected]
143 silly idealTree ├── [email protected]
143 silly idealTree ├── [email protected]
143 silly idealTree ├── [email protected]
143 silly idealTree ├── [email protected]
143 silly idealTree ├── [email protected]
143 silly idealTree ├── [email protected]
143 silly idealTree ├── [email protected]
143 silly idealTree ├── [email protected]
143 silly idealTree ├── [email protected]
143 silly idealTree ├── [email protected]
143 silly idealTree ├── [email protected]
143 silly idealTree ├── [email protected]
143 silly idealTree ├── [email protected]
143 silly idealTree ├── [email protected]
143 silly idealTree ├── [email protected]
143 silly idealTree ├── [email protected]
143 silly idealTree ├── [email protected]
143 silly idealTree ├── [email protected]
143 silly idealTree ├── [email protected]
143 silly idealTree ├── [email protected]
143 silly idealTree ├── [email protected]
143 silly idealTree ├── [email protected]
143 silly idealTree ├── [email protected]
143 silly idealTree ├── [email protected]
143 silly idealTree ├── [email protected]
143 silly idealTree ├── [email protected]
143 silly idealTree ├── [email protected]
143 silly idealTree ├── [email protected]
143 silly idealTree ├── [email protected]
143 silly idealTree ├── [email protected]
143 silly idealTree ├── [email protected]
143 silly idealTree ├── [email protected]
143 silly idealTree ├── [email protected]
143 silly idealTree ├── [email protected]
143 silly idealTree ├── [email protected]
143 silly idealTree ├── [email protected]
143 silly idealTree ├── [email protected]
143 silly idealTree ├── [email protected]
143 silly idealTree ├── [email protected]
143 silly idealTree ├── [email protected]
143 silly idealTree ├── [email protected]
143 silly idealTree ├── [email protected]
143 silly idealTree ├── [email protected]
143 silly idealTree ├── [email protected]
143 silly idealTree ├── [email protected]
143 silly idealTree ├── [email protected]
143 silly idealTree ├── [email protected]
143 silly idealTree ├── [email protected]
143 silly idealTree ├── [email protected]
143 silly idealTree ├── [email protected]
143 silly idealTree └── [email protected]
144 silly generateActionsToTake Starting
145 silly install generateActionsToTake
146 silly generateActionsToTake Finishing
147 silly diffTrees action count 3
148 silly diffTrees add [email protected]
149 silly diffTrees add [email protected]
150 silly diffTrees add [email protected]
151 silly decomposeActions action count 24
152 silly decomposeActions fetch [email protected]
153 silly decomposeActions extract [email protected]
154 silly decomposeActions test [email protected]
155 silly decomposeActions preinstall [email protected]
156 silly decomposeActions build [email protected]
157 silly decomposeActions install [email protected]
158 silly decomposeActions postinstall [email protected]
159 silly decomposeActions finalize [email protected]
160 silly decomposeActions fetch [email protected]
161 silly decomposeActions extract [email protected]
162 silly decomposeActions test [email protected]
163 silly decomposeActions preinstall [email protected]
164 silly decomposeActions build [email protected]
165 silly decomposeActions install [email protected]
166 silly decomposeActions postinstall [email protected]
167 silly decomposeActions finalize [email protected]
168 silly decomposeActions fetch [email protected]
169 silly decomposeActions extract [email protected]
170 silly decomposeActions test [email protected]
171 silly decomposeActions preinstall [email protected]
172 silly decomposeActions build [email protected]
173 silly decomposeActions install [email protected]
174 silly decomposeActions postinstall [email protected]
175 silly decomposeActions finalize [email protected]
176 silly runTopLevelLifecycles Starting
177 silly executeActions Starting
178 silly install executeActions
179 silly doSerial global-install 0
180 silly doParallel fetch 3
181 verbose correctMkdir /home/gobban/.npm/_locks correctMkdir not in flight; initializing
182 verbose lock using /home/gobban/.npm/_locks/staging-599c1edfb1e1a191.lock for /home/gobban/dev/rpi-nodejs/node_modules/.staging
183 silly doParallel extract 3
184 silly extract [email protected]
185 silly extract [email protected]
186 silly extract [email protected]
187 verbose unbuild node_modules/.staging/bindings-b49f2dda
188 verbose unbuild node_modules/.staging/nan-f0ed3cbb
189 verbose unbuild node_modules/.staging/rpio-52ad64f6
190 silly gentlyRm /home/gobban/dev/rpi-nodejs/node_modules/.staging/bindings-b49f2dda is being purged from base /home/gobban/dev/rpi-nodejs
191 verbose gentlyRm don't care about contents; nuking /home/gobban/dev/rpi-nodejs/node_modules/.staging/bindings-b49f2dda
192 silly gentlyRm /home/gobban/dev/rpi-nodejs/node_modules/.staging/nan-f0ed3cbb is being purged from base /home/gobban/dev/rpi-nodejs
193 verbose gentlyRm don't care about contents; nuking /home/gobban/dev/rpi-nodejs/node_modules/.staging/nan-f0ed3cbb
194 silly gentlyRm /home/gobban/dev/rpi-nodejs/node_modules/.staging/rpio-52ad64f6 is being purged from base /home/gobban/dev/rpi-nodejs
195 verbose gentlyRm don't care about contents; nuking /home/gobban/dev/rpi-nodejs/node_modules/.staging/rpio-52ad64f6
196 verbose tar unpack /home/gobban/.npm/bindings/1.2.1/package.tgz
197 verbose tar unpacking to /home/gobban/dev/rpi-nodejs/node_modules/.staging/bindings-b49f2dda
198 silly gentlyRm /home/gobban/dev/rpi-nodejs/node_modules/.staging/bindings-b49f2dda is being purged
199 verbose gentlyRm don't care about contents; nuking /home/gobban/dev/rpi-nodejs/node_modules/.staging/bindings-b49f2dda
200 verbose tar unpack /home/gobban/.npm/nan/2.4.0/package.tgz
201 verbose tar unpacking to /home/gobban/dev/rpi-nodejs/node_modules/.staging/nan-f0ed3cbb
202 silly gentlyRm /home/gobban/dev/rpi-nodejs/node_modules/.staging/nan-f0ed3cbb is being purged
203 verbose gentlyRm don't care about contents; nuking /home/gobban/dev/rpi-nodejs/node_modules/.staging/nan-f0ed3cbb
204 verbose tar unpack /home/gobban/.npm/rpio/0.9.12/package.tgz
205 verbose tar unpacking to /home/gobban/dev/rpi-nodejs/node_modules/.staging/rpio-52ad64f6
206 silly gentlyRm /home/gobban/dev/rpi-nodejs/node_modules/.staging/rpio-52ad64f6 is being purged
207 verbose gentlyRm don't care about contents; nuking /home/gobban/dev/rpi-nodejs/node_modules/.staging/rpio-52ad64f6
208 silly gunzTarPerm modes [ '775', '664' ]
209 silly gunzTarPerm modes [ '775', '664' ]
210 silly gunzTarPerm modes [ '775', '664' ]
211 silly gunzTarPerm extractEntry package.json
212 silly gunzTarPerm modified mode [ 'package.json', 420, 436 ]
213 silly gunzTarPerm extractEntry package.json
214 silly gunzTarPerm extractEntry package.json
215 silly gunzTarPerm modified mode [ 'package.json', 420, 436 ]
216 silly gunzTarPerm extractEntry README.md
217 silly gunzTarPerm modified mode [ 'README.md', 420, 436 ]
218 silly gunzTarPerm extractEntry bindings.js
219 silly gunzTarPerm modified mode [ 'bindings.js', 420, 436 ]
220 silly gunzTarPerm extractEntry README.md
221 silly gunzTarPerm extractEntry README.md
222 silly gunzTarPerm modified mode [ 'README.md', 420, 436 ]
223 silly gunzTarPerm extractEntry .travis.yml
224 silly gunzTarPerm modified mode [ '.travis.yml', 420, 436 ]
225 silly gunzTarPerm extractEntry include_dirs.js
226 silly gunzTarPerm extractEntry nan_callbacks_pre_12_inl.h
227 silly gunzTarPerm extractEntry CHANGELOG.md
228 silly gunzTarPerm extractEntry LICENSE.md
229 silly gunzTarPerm extractEntry binding.gyp
230 silly gunzTarPerm modified mode [ 'binding.gyp', 420, 436 ]
231 silly gunzTarPerm extractEntry build/Makefile
232 silly gunzTarPerm modified mode [ 'build/Makefile', 420, 436 ]
233 silly gunzTarPerm extractEntry build/Release/.deps/Release/obj.target/rpio/src/bcm2835.o.d
234 silly gunzTarPerm modified mode [ 'build/Release/.deps/Release/obj.target/rpio/src/bcm2835.o.d',
234 silly gunzTarPerm   420,
234 silly gunzTarPerm   436 ]
235 silly gunzTarPerm extractEntry doc/node_misc.md
236 silly gunzTarPerm extractEntry build/Release/.deps/Release/obj.target/rpio/src/rpio.o.d
237 silly gunzTarPerm modified mode [ 'build/Release/.deps/Release/obj.target/rpio/src/rpio.o.d',
237 silly gunzTarPerm   420,
237 silly gunzTarPerm   436 ]
238 silly gunzTarPerm extractEntry doc/asyncworker.md
239 silly gunzTarPerm extractEntry doc/callback.md
240 silly gunzTarPerm extractEntry build/Release/.deps/Release/rpio.node.d
241 silly gunzTarPerm modified mode [ 'build/Release/.deps/Release/rpio.node.d', 420, 436 ]
242 silly gunzTarPerm extractEntry build/Release/obj.target/rpio/src/bcm2835.o
243 silly gunzTarPerm modified mode [ 'build/Release/obj.target/rpio/src/bcm2835.o', 420, 436 ]
244 silly gunzTarPerm extractEntry doc/converters.md
245 silly gunzTarPerm extractEntry doc/errors.md
246 silly gunzTarPerm extractEntry build/Release/obj.target/rpio/src/rpio.o
247 silly gunzTarPerm modified mode [ 'build/Release/obj.target/rpio/src/rpio.o', 420, 436 ]
248 silly gunzTarPerm extractEntry doc/maybe_types.md
249 silly gunzTarPerm extractEntry doc/methods.md
250 silly gentlyRm /home/gobban/dev/rpi-nodejs/node_modules/.staging/bindings-b49f2dda/node_modules is being purged
251 verbose gentlyRm don't care about contents; nuking /home/gobban/dev/rpi-nodejs/node_modules/.staging/bindings-b49f2dda/node_modules
252 silly gunzTarPerm extractEntry doc/new.md
253 silly gunzTarPerm extractEntry build/Release/rpio.node
254 silly gunzTarPerm modified mode [ 'build/Release/rpio.node', 493, 509 ]
255 silly gunzTarPerm extractEntry doc/buffers.md
256 silly gunzTarPerm extractEntry doc/object_wrappers.md
257 silly gunzTarPerm extractEntry build/binding.Makefile
258 silly gunzTarPerm modified mode [ 'build/binding.Makefile', 420, 436 ]
259 silly gunzTarPerm extractEntry doc/persistent.md
260 silly gunzTarPerm extractEntry doc/scopes.md
261 silly gunzTarPerm extractEntry doc/script.md
262 silly gunzTarPerm extractEntry doc/string_bytes.md
263 silly gunzTarPerm extractEntry build/gyp-mac-tool
264 silly gunzTarPerm modified mode [ 'build/gyp-mac-tool', 493, 509 ]
265 silly gunzTarPerm extractEntry build/rpio.target.mk
266 silly gunzTarPerm modified mode [ 'build/rpio.target.mk', 420, 436 ]
267 silly gunzTarPerm extractEntry examples/button.js
268 silly gunzTarPerm modified mode [ 'examples/button.js', 420, 436 ]
269 silly gunzTarPerm extractEntry examples/dht11.js
270 silly gunzTarPerm modified mode [ 'examples/dht11.js', 420, 436 ]
271 silly gunzTarPerm extractEntry examples/i2c-lcd.js
272 silly gunzTarPerm modified mode [ 'examples/i2c-lcd.js', 420, 436 ]
273 silly gunzTarPerm extractEntry examples/padcontrol.js
274 silly gunzTarPerm modified mode [ 'examples/padcontrol.js', 420, 436 ]
275 silly gunzTarPerm extractEntry examples/pwm-led.js
276 silly gunzTarPerm modified mode [ 'examples/pwm-led.js', 420, 436 ]
277 silly gunzTarPerm extractEntry examples/spi-at93c46.js
278 silly gunzTarPerm modified mode [ 'examples/spi-at93c46.js', 420, 436 ]
279 silly gunzTarPerm extractEntry lib/rpio.js
280 silly gunzTarPerm modified mode [ 'lib/rpio.js', 420, 436 ]
281 silly gunzTarPerm extractEntry src/bcm2835.c
282 silly gunzTarPerm modified mode [ 'src/bcm2835.c', 420, 436 ]
283 silly gunzTarPerm extractEntry src/bcm2835.h
284 silly gunzTarPerm modified mode [ 'src/bcm2835.h', 420, 436 ]
285 silly gunzTarPerm extractEntry src/rpio.cc
286 silly gunzTarPerm modified mode [ 'src/rpio.cc', 420, 436 ]
287 silly gunzTarPerm extractEntry doc/v8_internals.md
288 silly gunzTarPerm extractEntry doc/v8_misc.md
289 silly gunzTarPerm extractEntry nan.h
290 silly gunzTarPerm extractEntry nan_callbacks.h
291 silly gunzTarPerm extractEntry nan_callbacks_12_inl.h
292 silly gunzTarPerm extractEntry nan_converters.h
293 silly gunzTarPerm extractEntry nan_converters_43_inl.h
294 silly gunzTarPerm extractEntry nan_converters_pre_43_inl.h
295 silly gunzTarPerm extractEntry nan_implementation_12_inl.h
296 silly gunzTarPerm extractEntry nan_implementation_pre_12_inl.h
297 silly gunzTarPerm extractEntry nan_maybe_43_inl.h
298 silly gunzTarPerm extractEntry nan_maybe_pre_43_inl.h
299 silly gunzTarPerm extractEntry nan_new.h
300 silly gunzTarPerm extractEntry nan_object_wrap.h
301 silly gunzTarPerm extractEntry nan_persistent_12_inl.h
302 silly gunzTarPerm extractEntry nan_persistent_pre_12_inl.h
303 silly gunzTarPerm extractEntry nan_string_bytes.h
304 silly gunzTarPerm extractEntry nan_typedarray_contents.h
305 silly gunzTarPerm extractEntry nan_weak.h
306 silly gunzTarPerm extractEntry tools/package.json
307 silly gunzTarPerm extractEntry tools/README.md
308 silly gunzTarPerm extractEntry tools/1to2.js
309 silly gentlyRm /home/gobban/dev/rpi-nodejs/node_modules/.staging/rpio-52ad64f6/node_modules is being purged
310 verbose gentlyRm don't care about contents; nuking /home/gobban/dev/rpi-nodejs/node_modules/.staging/rpio-52ad64f6/node_modules
311 silly gentlyRm /home/gobban/dev/rpi-nodejs/node_modules/.staging/nan-f0ed3cbb/node_modules is being purged
312 verbose gentlyRm don't care about contents; nuking /home/gobban/dev/rpi-nodejs/node_modules/.staging/nan-f0ed3cbb/node_modules
313 silly doParallel preinstall 3
314 silly preinstall [email protected] /home/gobban/dev/rpi-nodejs/node_modules/.staging/bindings-b49f2dda
315 info lifecycle [email protected]~preinstall: [email protected]
316 silly preinstall [email protected] /home/gobban/dev/rpi-nodejs/node_modules/.staging/nan-f0ed3cbb
317 info lifecycle [email protected]~preinstall: [email protected]
318 silly preinstall [email protected] /home/gobban/dev/rpi-nodejs/node_modules/.staging/rpio-52ad64f6
319 info lifecycle [email protected]~preinstall: [email protected]
320 silly lifecycle [email protected]~preinstall: no script for preinstall, continuing
321 silly lifecycle [email protected]~preinstall: no script for preinstall, continuing
322 silly lifecycle [email protected]~preinstall: no script for preinstall, continuing
323 silly doReverseSerial remove 0
324 silly doSerial move 0
325 silly doSerial finalize 3
326 silly finalize /home/gobban/dev/rpi-nodejs/node_modules/bindings
327 silly finalize /home/gobban/dev/rpi-nodejs/node_modules/nan
328 silly finalize /home/gobban/dev/rpi-nodejs/node_modules/rpio
329 silly doSerial build 3
330 silly build [email protected]
331 info linkStuff [email protected]
332 silly linkStuff [email protected] has /home/gobban/dev/rpi-nodejs/node_modules as its parent node_modules
333 verbose linkBins [email protected]
334 verbose linkMans [email protected]
335 silly build [email protected]
336 info linkStuff [email protected]
337 silly linkStuff [email protected] has /home/gobban/dev/rpi-nodejs/node_modules as its parent node_modules
338 verbose linkBins [email protected]
339 verbose linkMans [email protected]
340 silly build [email protected]
341 info linkStuff [email protected]
342 silly linkStuff [email protected] has /home/gobban/dev/rpi-nodejs/node_modules as its parent node_modules
343 verbose linkBins [email protected]
344 verbose linkMans [email protected]
345 silly doSerial global-link 0
346 silly doParallel update-linked 0
347 silly doSerial install 3
348 silly install [email protected] /home/gobban/dev/rpi-nodejs/node_modules/.staging/bindings-b49f2dda
349 info lifecycle [email protected]~install: [email protected]
350 silly lifecycle [email protected]~install: no script for install, continuing
351 silly install [email protected] /home/gobban/dev/rpi-nodejs/node_modules/.staging/nan-f0ed3cbb
352 info lifecycle [email protected]~install: [email protected]
353 silly lifecycle [email protected]~install: no script for install, continuing
354 silly install [email protected] /home/gobban/dev/rpi-nodejs/node_modules/.staging/rpio-52ad64f6
355 info lifecycle [email protected]~install: [email protected]
356 verbose lifecycle [email protected]~install: unsafe-perm in lifecycle true
357 verbose lifecycle [email protected]~install: PATH: /usr/lib/node_modules/npm/bin/node-gyp-bin:/home/gobban/dev/rpi-nodejs/node_modules/rpio/node_modules/.bin:/home/gobban/dev/rpi-nodejs/node_modules/.bin:/home/gobban/bin:/home/gobban/.local/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games
358 verbose lifecycle [email protected]~install: CWD: /home/gobban/dev/rpi-nodejs/node_modules/rpio
359 silly lifecycle [email protected]~install: Args: [ '-c', 'node-gyp rebuild' ]
360 silly lifecycle [email protected]~install: Returned: code: 1  signal: null
361 info lifecycle [email protected]~install: Failed to exec install script
362 verbose unlock done using /home/gobban/.npm/_locks/staging-599c1edfb1e1a191.lock for /home/gobban/dev/rpi-nodejs/node_modules/.staging
363 silly rollbackFailedOptional Starting
364 silly rollbackFailedOptional Finishing
365 silly runTopLevelLifecycles Finishing
366 silly install printInstalled
367 warn [email protected] No repository field.
368 verbose If you need help, you may report this error at:
368 verbose     <https://github.com/npm/npm/issues>
369 verbose stack Error: [email protected] install: `node-gyp rebuild`
369 verbose stack Exit status 1
369 verbose stack     at EventEmitter.<anonymous> (/usr/lib/node_modules/npm/lib/utils/lifecycle.js:255:16)
369 verbose stack     at emitTwo (events.js:106:13)
369 verbose stack     at EventEmitter.emit (events.js:191:7)
369 verbose stack     at ChildProcess.<anonymous> (/usr/lib/node_modules/npm/lib/utils/spawn.js:40:14)
369 verbose stack     at emitTwo (events.js:106:13)
369 verbose stack     at ChildProcess.emit (events.js:191:7)
369 verbose stack     at maybeClose (internal/child_process.js:877:16)
369 verbose stack     at Process.ChildProcess._handle.onexit (internal/child_process.js:226:5)
370 verbose pkgid [email protected]
371 verbose cwd /home/gobban/dev/rpi-nodejs
372 error Linux 4.4.0-47-generic
373 error argv "/usr/bin/nodejs" "/usr/bin/npm" "install" "rpio" "--save"
374 error node v6.9.1
375 error npm  v3.10.8
376 error code ELIFECYCLE
377 error [email protected] install: `node-gyp rebuild`
377 error Exit status 1
378 error Failed at the [email protected] install script 'node-gyp rebuild'.
378 error Make sure you have the latest version of node.js and npm installed.
378 error If you do, this is most likely a problem with the rpio package,
378 error not with npm itself.
378 error Tell the author that this fails on your system:
378 error     node-gyp rebuild
378 error You can get information on how to open an issue for this project with:
378 error     npm bugs rpio
378 error Or if that isn't available, you can get their info via:
378 error     npm owner ls rpio
378 error There is likely additional logging output above.
379 verbose exit [ 1, true ]

Mock gpio not read value

Hi, I have this code:

rpio.open(7, rpio.OUTPUT,  rpio.HIGH)
console.log(rpio.read(7))

The output always undefined, as this problem can resolved?

Does not work on raspberry pi 3

When run on raspberry pi 3 latest raspbian image throws this error:

Error: /home/pi/rpio/node_modules/rpio/build/Release/rpio.node: invalid ELF header

/home/pi/rpio/node_modules/rpio/node_modules/bindings/bindings.js:83
throw e

aarch64 support?

After using rpio successfully on normal systems for while (thanks for providing it), I tried it on an aarch64 rpi3 board. It failed at setup_board() in lib/rpio.js because /proc/cpuinfo no longer contains a board Revision entry. I added code to look also in /proc/device-tree/model (where it finds "Rev 1.2" on my board) and I use that to set gpiomap to "v2plus" (which is what a plain 32bit system running on the same board sets it to).

That change seems to work OK, however now my app is unable to initialize the bcm2835 library (bcm2835_init: Unable to open /dev/gpiomem: No such file or directory). Evidently a newer version of the bcm2835 library is needed for aarch64. Do you know whether it exists and will you incorporate it any time soon?

Thanks,
chris

Questions to the expert !

Jonathan,

I've just started to find my way out for the last two week as a Rapsberry PI2 beginner. Since most tutorials and a Sunfounder kit are based on either C or Python, and as a NodeJS developer, I am searching for a nodejs module to control the GPIO. I superficially tried with success some of the many node modules I found but I'm still a bit lost to select a reliable, maintained, easy to use and fast one. I realise that speed can be important as I went to this Comparison 2013 of NodeJS GPIO access packages. Yours appears interesting as beeing writen in C and also has support for i²c, PWM, and SPI. Other NodeJS modules I quickly made a test with are : fivdi/onoff, brnt/node-rpio, nebrius/raspi (with raspi-gpio, raspi-io for Johnny-Five and raspi-board), gavinhungry/wpi-gpio and JamesBarwell/rpi-gpio.js.

MY QUESTIONS :

  • Is your module just safe and reliable to use with a Raspberry PI 2?
  • Will it be maintained on the long term? (writing C/C++ was at an ancient time for me…)
  • Can we expect not to have to launch node in sudo mode with rpio?
  • Where would node-rpio compared in the Comparison 2013 of NodeJS GPIO access packages?
  • Do you have advices for me to choose such a module? Or web link to a well made article?
  • What about using raspi-gpio (with raspi-io for Johnny-Five): any experiences?

I hope not to worry you with such questions, so dont hesitate to drop them.

Thank you very much for any advices.
With regards,
Joel

Using more than one SPI device

I am not able to read/write to more than one device using the library, I am using rpio.spiChipSelect(0); within the function to access the first spi device and then rpio.spiChipSelect(1); to access the second chip but this dosnt seem to work.

Do I need to create separate instances of the rpio object for each SPI device?

Unknown PWM channel on Pi Model B

Hi,

I've been trying to run the PWM example from the repo on the RPi Model B and I keep getting the following error --

Unknown PWM channel for pin16

using mode:physical - I'm sure the pin is correct as I can toggle the value between HIGH/LOW with basic write statements
using package version 0.4.4

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.