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 7b8d5d7552 0.3.3 Bug fix - Make sure that the number key for the interrupts map is ALWAYS a number even if string is passed 2020-07-27 14:10:47 -07:00
examples 0.3.3 Bug fix - Make sure that the number key for the interrupts map is ALWAYS a number even if string is passed 2020-07-27 14:10:47 -07:00
src 0.3.3 Bug fix - Make sure that the number key for the interrupts map is ALWAYS a number even if string is passed 2020-07-27 14:10:47 -07:00
test added interrupts class as multiple extension of Interrupt 2018-03-04 15:10:34 -08:00
.eslintrc.js 0.2.23 Rework interrupts - remove listen methods and automatically send and emit on any one individual interrupt/reset emit 2019-12-23 14:21:12 -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
nodemon.json 0.3.3 Bug fix - Make sure that the number key for the interrupts map is ALWAYS a number even if string is passed 2020-07-27 14:10:47 -07:00
package.json 0.3.3 Bug fix - Make sure that the number key for the interrupts map is ALWAYS a number even if string is passed 2020-07-27 14:10:47 -07: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 */
            };
        };
    };
};