In node-red how to read gpio from dell gateway 3001

#1

we are integrating with dell gateway 3001 but we are not getting how to work with gpio from node-red. The operating System is ubutu core.

The manual for dell gateway for using gpio is in https://www.dell.com/support/manuals/in/en/inbsdt1/dell-edge-gateway-3000-series/dell-edge_gateway-3001-install_manual/gpio?guid=guid-9ca4244f-635c-48ab-8052-dec2558f77cd&lang=en-us

0 Likes

#2

Assuming that you can run Node-RED on the gateway, you can use the simple commands listed on the referenced page in an exec node.

On Linux I/O devices can often be treated as files so you might also be able to use the file read/write file nodes as well.

0 Likes

#3

@TotallyInformation - note that the referenced page says (as root) - so you can't just use an exec as that would be a privilege escalation. You need to either run the whole of Node-RED as root and then use exec as you said - which is probably a bad idea as no doubt the next thing will be to connect this to the internet so it can be remotely controlled. Or to write (outside of Node-RED) a wrapper for those commands that exposes them in user-space in a slightly safer manner. Several examples exist for Pi - eg https://www.raspberrypi.org/forums/viewtopic.php?p=131069&sid=88282aaa50634ad7db83c3965625c033#p131069

0 Likes

#4

Thanks Dave, missed that.

As always, the best approach for that is to add the user running Node-RED to the appropriate group so that you don't need root access.

0 Likes

#5

I don't think the docs mention any group... so tricky.

0 Likes

#6

I'm getting the following exception

cat: /sys/class/gpio/gpio337/direction: Permission deniedcat: 1550749439835: No such file or directory

0 Likes

#7

because you aren't running as root....

0 Likes

#8

is there anything we can do to run as root as I've not found in documentation or can I do that using bigexec?

0 Likes

#9

Another option would be not to use the gpio at all and rather use external I/O with MQTT or modbus etc

0 Likes

#10

run the command ls -la /sys/class/gpio you may need to do that for the sub-folders too. Let us know what the output is. It may be that they are owned by root/root which wont help. But they might be owned by root/wheel - in which case you can simply add the user id running Node-RED to the "wheel" group.

0 Likes

#11

yeah i have tried please find the below image

0 Likes

#12

Drat, OK so you can see that all of the devices are owned by root/root which doesn't help you very much.

Here, for example, is the output on a Raspberry Pi

As you can see, ownership is root/gpio which means that you only need to add the userid that runs Node-RED to the gpio group and it has access.

My recommendation is that you create a gpio group and reassign ownership something like this:

sudo groupadd gpio
sudo chown -R root:gpio /sys/class/gpio
sudo usermod -a -G gpio <userid>

Replacing <userid> with the userid that is running Node-RED. Sorry, not sure if you then have to log out and back in for the user to actually pick up the group (assuming you are logged in with the same account).

Also note that the /sys/class/gpio actually are linked back to /sys/devices and you will need to go and change ownership on those as well.

This avoids the need for you have to install and run Node-RED as root which is rather more secure. Also note though that you are opening up control of your GPIO ports to that user - you will want to make sure that you are using a decent password (or cert-based login) and make sure that if you are exposing Node-RED or other endpoints to the Internet that you have properly secured everything.

0 Likes

#13

Now the problem is solved, when we run node-red or any other snap(like in any containerized environment like docker or snap..) we have to do some configuration to the application to communicate with host network or env. So ,in case of node-red we have to create interface between snap and the gpio slot.

command to be used: snap interface gpio to list available GPIO slots in the system.

Use snap connect snap:plug snap:slot to connect to the gpio slot.

ex in my case it is snap connect node-red:gpio caracalla:gpa-sku-gpio0

1 Like