01d2ebd3a1
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 |
||
---|---|---|
examples | ||
src | ||
test | ||
.eslintrc.js | ||
.gitignore | ||
.npmignore | ||
.travis.yml | ||
package.json | ||
readme.md |
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 */
};
};
};
};