From node-red snap not able to read gpio file


#1

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)


#2

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?


#3

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

#4

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


#5

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)


#6

The syntax is:

snap connect snap:plug snap:slot

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


#7

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

#8

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).


#9

thank you!! problem solved