From node-red snap not able to read gpio file

I am using Ubuntu core and installed node-red, when i used the top command it shows that the node-red is running as a root user. The gpio files are also as root user only. But I’m not able access gpio files(/sys/class/gpio). So I tried to create gpio group with gpio path and add node-red user to that gpio group, but not able to add while creating group I am getting

groupadd fails with “cannot lock /etc/group; try again later”

Is there any solution that node-red can access gpio files(I’m creating those gpio file once the ubuntu boots)

If you run snap interfaces node-red you’ll note a selection of interfaces which are not automatically connected:-

pi@raspberrypi:~ $ snap interfaces node-red | grep ^-
-              node-red:bluetooth-control
-              node-red:bluez
-              node-red:camera
-              node-red:gpio
-              node-red:network-observe
-              node-red:removable-media
-              node-red:serial-port

You can connect these to make the resources available to the snap. For example:-

sudo snap connect node-red:gpio

Does that help?

I got the following error when i ran this command
sudo snap connect node-red:gpio

error: snap “core” has no “gpio” interface slots

but for snap interfaces node-red | grep ^-

i got these

  •          node-red:bluetooth-control
    
  •          node-red:bluez
    
  •          node-red:camera
    
  •          node-red:gpio
    
  •          node-red:network-observe
    
  •          node-red:removable-media
    
  •          node-red:serial-port

You can use snap interface gpio to list available GPIO slots on your system.

These are all interfaces coming if enter the commands you mentioned.
root@admin:~# snap interface gpio
name: gpio
summary: allows access to specifc GPIO pin
plugs:
- ccm-wda:cloud-led
- ccm-wda:sku-bit-a
- ccm-wda:sku-bit-b
- ccm-wda:sku-bit-c
- gateway3000-gpio-led8
- node-red
slots:
- caracalla:cloud-led
- caracalla:gpa-sku-gpio0
- caracalla:gpa-sku-gpio1
- caracalla:gpa-sku-gpio2
- caracalla:gpa-sku-gpio3
- caracalla:gpa-sku-gpio4
- caracalla:gpa-sku-gpio5
- caracalla:gpa-sku-gpio6
- caracalla:gpa-sku-gpio7
- caracalla:serial-termination-ioioi1
- caracalla:serial-termination-ioioi2
- caracalla:sku-bit-a
- caracalla:sku-bit-b
- caracalla:sku-bit-c
- caracalla:zig-fwupctrl
- caracalla:zig-rstctrl

So I entered the following command snap connect node-red:ccm-wda:cloud-led node-red:caracalla:gpa-sku-gpio0

I’m getting error: invalid value: “:” (want snap:name or snap)

The syntax is:

snap connect snap:plug snap:slot

So just put a space instead of the colon between the endpoints.

can you give me one example to connect all interface slots and plugins to node-red.
root@admin:~# snap interface gpio
name: gpio
summary: allows access to specifc GPIO pin
plugs:

  • ccm-wda:cloud-led
  • ccm-wda:sku-bit-a
  • ccm-wda:sku-bit-b
  • ccm-wda:sku-bit-c
  • gateway3000-gpio-led8
  • node-red
    slots:
  • caracalla:cloud-led
  • caracalla:gpa-sku-gpio0
  • caracalla:gpa-sku-gpio1
  • caracalla:gpa-sku-gpio2
  • caracalla:gpa-sku-gpio3
  • caracalla:gpa-sku-gpio4
  • caracalla:gpa-sku-gpio5
  • caracalla:gpa-sku-gpio6
  • caracalla:gpa-sku-gpio7
  • caracalla:serial-termination-ioioi1
  • caracalla:serial-termination-ioioi2
  • caracalla:sku-bit-a
  • caracalla:sku-bit-b
  • caracalla:sku-bit-c
  • caracalla:zig-fwupctrl
  • caracalla:zig-rstctrl

You need to do them one-by-one:

snap connect node-red:gpio caracalla:gpa-sku-gpio0

and so on… on the left hand side you have the plug (snap name, colon, plug name on that side), on the right hand side you have the slot (again snap name, this time that holding the slot, colon, slot name on that side).

thank you!! problem solved

Greetings!

I hope this is a better place to ask this. Thanks @ogra for your guidance on forum etiquette. I am new here and honestly haven’t spent a lot of time on forums let me know if i can better form posts i’m all ears!

So…I installed core on my raspberrypi 3 and am attempting to run the nod-red dashboard on on the wpe-webkit with mir-kiosk. I have 2 specific problems that arise which I assume are a result of the confinement of the node-red snap:

  1. in node red raspberry pi gpio nodes just say “Not available”

  2. when I try to install new node-red modules from the pallet manager that require access to the i2c bus on the i get the following error:

2020-06-11T22:51:49.782Z [out] > node-gyp rebuild
2020-06-11T22:51:49.782Z [out] 
2020-06-11T22:51:54.220Z [err] gyp
2020-06-11T22:51:54.221Z [err]  
2020-06-11T22:51:54.221Z [err] ERR! build error 
2020-06-11T22:51:54.223Z [err] gyp
2020-06-11T22:51:54.223Z [err]  ERR! stack
2020-06-11T22:51:54.224Z [err]  Error: not found: make

I wanted to show some relevant system information but for some reason the lsb_release -a command doesn’t exist but cat /etc/issue/ gives me ```Ubuntu Core 18 on \4 (\1) `` not sure if that info is useful…

I should also mention that I already connected each gpio interface slot to the gpio plugs in node-red but still no dice. and I couldn’t find a plug for the i2c interface in node-red.

Am I missing something here…

Thanks!

1 Like

I should also mention that I did get node-red working with my gpio and i2c devices on previous builds on arch linux by creating a user group and adding my standard user to that group and using chown to give the group access to the hardware devices. Is there an equivalent process in core?

snap servcies (like node-red) always run as root, so there is no need to change permissions …

if you did all connections too, the app should have full access to the gpio devices, there must be something missing in the node-red snap … do you see any DENIED messages in your systemd journal ?

So maybe I screwed something up but I could not get it working so in an attempt to get this project buttoned up I installed an old version of server 18.04 using the instructions on this page:

https://nodered.org/docs/getting-started/raspberrypi

…but it ran slower for some reason and my dashboard application crashed after running for several hours. which unfortunately is a common occurrence for me when I try building IOT devices running on a pi. Any ideas??

I’m not giving up on core yet, but maybe I’m barking up the wrong tree. for now I just need a speedy kiosk running the node-red dashboard I don’t really care what platform at this point. I have so much more to tackle on this project and a customer crawling up my @ss so I should prob lean towards a less experimental approach…

Some pics of my project:

image

1 Like

Well, i think there is something seriously wrong in the node-red snap packaging, there are plenty of projects out there using GPIOs on raspberry pi’s under Ubuntu Core so the GPIO implementation and interfacing is well tested and working widely.

my assumpotion is that either some Pi specific integration library is not shipped in the snap or it does not have all information it needs due to i.e. a missing interface.

Taking a quick look at the node-red snap it is actually missing all architecture specific modules (including the raspberrypi gpio ones), i2c support, the dashboard module and a bunch of other things.

I have forked the snap and added the missing bits and pieces to:

… and renamed it to node-red-rpi. You can try it out with:

snap install node-red-rpi --edge

then connect gpio and i2c interfaces, go to port 1880 and try if it works for you (if it does i’ll happily do a stable release).

1 Like

@ogra! you’re the man! thank you

Ok just installed core and added the following snaps"

snap install mir-kiosk
snap install wpe-webkit-mir-kiosk
snap install node-red-rpi --edge

Node red has same error on install of certain nodes that have to compile / build some of the parts:

-----------------------------------------------------------
2020-06-13T18:24:11.817Z Install : node-red-contrib-bme280-rpi 0.0.1

2020-06-13T18:24:11.468Z npm install --no-audit --no-update-notifier --save --save-prefix="~" --production node-red-contrib-bme280-rpi@0.0.1
2020-06-13T18:24:20.359Z [out] 
2020-06-13T18:24:20.359Z [out] > i2c-bus@5.2.0 install /root/snap/node-red-rpi/1/node_modules/i2c-bus
2020-06-13T18:24:20.359Z [out] > node-gyp rebuild
2020-06-13T18:24:20.359Z [out] 
2020-06-13T18:24:27.246Z [err] gyp
2020-06-13T18:24:27.247Z [err]  ERR! build error
2020-06-13T18:24:27.247Z [err]  
2020-06-13T18:24:27.249Z [err] gyp
2020-06-13T18:24:27.249Z [err]  ERR! stack Error: not found: make

Can these modules be preinstalled in the node-red snap?

node-red-contrib-bme280-rpi 0.0.1
node-red-contrib-i2c

these modules both throw the same error when installing doesn’t look like a permission error can this node be installed on the command line? Although it defeats the purpose of the confinement for security if that was possible guess.

hmm, i thought they are (at least the i2c one) … are you on armhf or arm64 ? (i havent cared a lot for arm64 since thats insane to use on a < 4GB device)

the list of the added modules is:

more importantly though … can you access the gpios via the “rpi gpio in” and “rpi gpio out” nodes from the menu ?

Oh I did install the arm64 version…I will swap that out and try again.

well, i’ll have to do the same for arm64 too anyway… just takes a bit (dinner time etc, might be only happening later tonight)