node-red / node-red/node-red-nodes

node-red-node-pi-gpio and node-red-contrib-python3-function don't work on Ubuntu 20.10

Open
#721 17 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Needs Help
Dominant language
JavaScript
Stars
1.1k
Forks
612
Avg merge
13h 57m
Merged PRs (30d)
3

Description

Which node are you reporting an issue on?

node-red-node-pi-gpio
node-red-contrib-python3-function

What are the steps to reproduce?

Using image ubuntu-20.10-preinstalled-desktop-arm64+raspi.img.xz
sudo apt update
sudo apt upgrade
sudo apt full-upgrade

sudo rpi-eeprom-update
#CURRENT: Thu 03 Sep 2020 12:11:43 PM UTC (1599135103)

#GPIO support
sudo groupadd -f --system gpio
sudo groupadd -f --system i2c
sudo groupadd -f --system spi
sudo groupadd -f --system input
sudo usermod -a -G gpio root
sudo usermod -a -G i2c root
sudo usermod -a -G spi root
sudo usermod -a -G input root
sudo usermod -a -G gpio user
sudo usermod -a -G i2c user
sudo usermod -a -G spi user
sudo usermod -a -G input user
sudo chown root:gpio /dev/gpiomem
#use 99-com.rules from rasbian OS
#99-com.rules


SUBSYSTEM=="input", GROUP="input", MODE="0660"
SUBSYSTEM=="i2c-dev", GROUP="i2c", MODE="0660"
SUBSYSTEM=="spidev", GROUP="spi", MODE="0660"
SUBSYSTEM=="bcm2835-gpiomem", GROUP="gpio", MODE="0660"

SUBSYSTEM=="gpio", GROUP="gpio", MODE="0660"
SUBSYSTEM=="gpio*", PROGRAM="/bin/sh -c '\
        chown -R root:gpio /sys/class/gpio && chmod -R 770 /sys/class/gpio;\
        chown -R root:gpio /sys/devices/virtual/gpio && chmod -R 770 /sys/devices/virtual/gpio;\
        chown -R root:gpio /sys$devpath && chmod -R 770 /sys$devpath\
'"

KERNEL=="ttyAMA[01]", PROGRAM="/bin/sh -c '\
        ALIASES=/proc/device-tree/aliases; \
        if cmp -s $ALIASES/uart0 $ALIASES/serial0; then \
                echo 0;\
        elif cmp -s $ALIASES/uart0 $ALIASES/serial1; then \
                echo 1; \
        else \
                exit 1; \
        fi\
'", SYMLINK+="serial%c"

KERNEL=="ttyS0", PROGRAM="/bin/sh -c '\
        ALIASES=/proc/device-tree/aliases; \
        if cmp -s $ALIASES/uart1 $ALIASES/serial0; then \
                echo 0; \
        elif cmp -s $ALIASES/uart1 $ALIASES/serial1; then \
                echo 1; \
        else \
                exit 1; \
        fi \

sudo mv 99-com.rules /etc/udev/rules.d
sudo udevadm control --reload-rules && sudo udevadm trigger

#misc
sudo adp intsall -y curl

#Python3
sudo apt install -y python3 python3-dev
sudo apt install -y python3-pip

#Python3 GPIO
sudo apt install -y python3-rpi.gpio
sudo python3 -m pip install gpiozero

#I verfied using PyCharm that both RPi.GPIO and gpiozero import and work at this step

#NodeRED
#https://nodered.org/docs/getting-started/raspberrypi
sudo apt install -y build-essential git
sudo apt-get install nodejs
sudo apt install -y npm
sudo npm install -g --unsafe-perm node-red
sudo npm install -g --unsafe-perm node-red node-red-admin
sudo npm install -g --unsafe-perm node-red-contrib-python3-function
sudo npm install -g --unsafe-perm node-red-contrib-uibuilder
sudo npm install -g --unsafe-perm node-red-dashboard
sudo npm install -g --unsafe-perm node-red-node-pi-gpio
sudo npm install -g --unsafe-perm node-red-node-random
sudo npm install -g --unsafe-perm node-red-node-ping
sudo npm install -g --unsafe-perm node-red-contrib-play-audio
sudo npm install -g --unsafe-perm node-red-node-smooth
sudo npm install -g --unsafe-perm node-red-node-serialport
npm config set update-notifier false
npm rebuild --unsafe-perm
sudo ufw allow 1880
#In /usr/bin, copy python3 and rename as python. Otherwise python3 and GPIO won't work!
node-red

#Receive the error:
#/bin/sh: 1: /usr/local/lib/node_modules/node-red-node-pi-gpio/testgpio.py: not found

#Create GPIO input and output nodes via webpage
#Deploy flow, test. Does not work.

#Create Python3 Script node via webpage
#Deploy flow, test. Does not work, crashes NodeRed.

What happens?

RPi-GPIO module does not load. IO fails to work. See N/A on node status text.
Python3 script causes NodeRed to crash/shutdown

What do you expect to happen?

I expected the modules to load/work

Please tell us about your environment:
  • Node-RED version: 1.2.6
  • node.js version: 14.15.1
  • npm version: 6.4.8
  • Platform/OS: Raspberry Pi 4Model B 4GB firmware version 1599135103, ubuntu-20.10-preinstalled-desktop-arm64+raspi.img.xz (problem also occurs in UbuntuMate 20.04 Raspberry Pi image)
  • Browser: FireFox

The root cause is that there is no python command, only python3.
node-red-node-pi-gpio and node-red-contrib-python3-function both appear to reference python and assume it will map to python3, but this isn't true in most cases.
I can fix the issue by going into /usr/bin, copying python3 to the filename python. After that, everything works as expected.

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by inspecting the node-red-node-pi-gpio entry point and /usr/local/lib/node_modules/node-red-node-pi-gpio/testgpio.py, then compare how node-red-contrib-python3-function launches Python. Reproduce the flows on the stated Ubuntu Raspberry Pi setup; done means both nodes load and execute without requiring a manually created python alias.

Written by the indexing model from the issue text.

Assessment

Tech stack
javascript, nodejs, python, ubuntu
Domain
backend, operating-systems
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.