Module Specifically for Raspberry Pi. Interrupted gpio pin are connect to socket(s) that can push UCI packets when interrupts happen (like when mcp ports chain interrupt from expander pin)
 
Go to file
David Kebler 01d2ebd3a1 0.2.22
interrupts class
extends base on interrupts class
change collection of individual interrupts to a Map
method: listenReset, for setting handler for emitted reset of each single interrupt
method: addInterSocket, to add identical consumer socket to each interrupt
interrupt class
add resetEnabled option
switch default edge to 'both'
refactor status method
refactor reset method
No hook by default, registerHook without argument sets the default hook
refactored examples

update deps
2019-11-21 10:06:24 -08:00
examples 0.2.22 2019-11-21 10:06:24 -08:00
src 0.2.22 2019-11-21 10:06:24 -08:00
test added interrupts class as multiple extension of Interrupt 2018-03-04 15:10:34 -08:00
.eslintrc.js working rpi gpio interrupt with packet socket 2018-02-23 21:32:13 -08:00
.gitignore 0.2.14 refactor to using on/off with epoll, retiring pigipo. Readme now has some explanation on getting hardware prepared 2019-03-14 10:43:25 -07:00
.npmignore 0.2.14 refactor to using on/off with epoll, retiring pigipo. Readme now has some explanation on getting hardware prepared 2019-03-14 10:43:25 -07:00
.travis.yml initial commit 2017-01-11 15:56:25 -08:00
package.json 0.2.22 2019-11-21 10:06:24 -08:00
readme.md 0.2.22 2019-11-21 10:06:24 -08:00

readme.md

uCOMmandIt Interrupt Package for SBC GPio Pins

This module creates an UCI Packect Interrupt classes for a single or multiple gpio pin(s) supporting interrupt via epoll (kernel gpio/export). By extending the UCI base class it allows communication to/from other processes

By default there are NO sockets created. You can create them as you need. Every interrupt thown will emit a packet as well as send and push that UCI packet if any sockets are associated with that interrupt.

You can pass a custom packet to push via the options and/or ammend the basic packet via a hook you provide.

By default the packet will send and packet.cmd='interrupt' but you can customize that via either passing .cmd in the .packet option or passing .pushCmd

UCI tcp and pipe transports sockets support an initial connection packet sent to connecting consumers by by passing .conPacket= { } or .resetCmd= to instance. This allows one to take some initial action related to interrupt (e.g. an mcp chip can reset it's interrupt connect to a sbc gpio pin)

Set up hardware GPio bus pins as interrupts for use with UCI Interrupt

Enable access to GPios

make sure your user is in the gpio group

Give gpio group permission to reading/writing from/to pins. On raspbien installs this should already work for pi user. For other distros and other hardware the following rule put in a file in /etc/udev/rules.d/ should work.

SUBSYSTEM=="gpio*", PROGRAM="/bin/sh -c 'find -L /sys/class/gpio/ -maxdepth 2 -exec chown root:gpio {} \; -exec chmod 770 {} \; || true'"

if you get permission errors then likely this rule is not effective. Take a look at /sys/class/gpio folder and see if gpio group has been added appropriately (e.g. to /export and /unexport).

Set hardware pull

Will need to do this with DTOs device tree overlays (except for Rasberry Pi)

Raspberry Pi

For raspberry pi with recent distro/kernel (e.g. Ubuntu 18.04,mainline 4.15) you can use add a line to config.txt in /boot or subdir therein. Add a line like this

gpio=9,10,24=pd

The pin defaults can be seen in Table 6-31 on pages 102 and 103 of the BCM2835 ARM Peripherals documentation.

Other possible settings are

      ip - Input
      op - Output
      a0-a5 - Alt0-Alt5
      dh - Driving high (for outputs)
      dl - Driving low (for outputs)
      pu - Pull up
      pd - Pull down
      pn/np - No pull

Other SBC GPio buses

For other SBCs with a gpio bus you'll need to consult the manufactuer docs/forum but you should be able to create and add device tree blobs to set the gpio pins. It may involve enabling device tree overlays and installing the dto package, etc. Here is a How to for the Raspberry Pi which of course is not necessary (see above) but will give you a start on other hardware

Example dts file for raspberry pi

/dts-v1/;
/plugin/;

/ {
    compatible = "brcm,bcm2708";

    fragment@0 {
        target = <&gpio>;
        __overlay__ {
            pinctrl-names = "default";
            pinctrl-0 = <&my_pins>;

            my_pins: my_pins {
                brcm,pins = <7 8 9>;     /* gpio no. */
                brcm,function = <0 0 0>; /* 0:in, 1:out */
                brcm,pull = <1 1 2>;     /* 2:up 1:down 0:none */
            };
        };
    };
};