node-red / node-red-nodes

Extra nodes for Node-RED
Other
994 stars 594 forks source link

neopixel 0.1.1 stopped / TypeError: Cannot read property 'stdin' of null #740

Open y8s opened 3 years ago

y8s commented 3 years ago

Which node are you reporting an issue on?

node-red-node-pi-neopixel

What are the steps to reproduce?

on a raspberry pi running buster: curl -sS get.pimoroni.com/unicornhat | bash npm install node-red-node-pi-neopixel create an inject node with msg.payload (text) of red,8 for example connect it to a configured neopixel node (pin 12, 8 pixels strip) deploy and click inject node

What happens?

on deploy, neopixel node shows "stopped" on inject, debug shows: "TypeError: Cannot read property 'stdin' of null" node-red-log shows same as debug, no other errors for neopixel

What do you expect to happen?

8 red leds to light up on clicking the inject node

Please tell us about your environment:

I did find the other issue [(] where a similar thing happened but it doesn't help. I'm not running docker.

I did run the command

./neopix 1 40 pcent 100 true

and this comes back:

Traceback (most recent call last):
  File "./neopix.py", line 50, in <module>
    LED_CHANNEL = int(sys.argv[6])
IndexError: list index out of range

I have tried other pins but same thing.

Note: the 8 led strip works with the unicorn hat simple.py (my 8 pixels light up pinky-purple)

Also note it works on another pi running buster and nodered v1.2.6 at neopixel version 0.0.25

dceejay commented 3 years ago

Well there aren't enough parameters in your line

 ./neopix 8 40 pixels 100 true 0 12

would be more realistic

But the node should report "ok" image as long as nothing else is trying to talk to that pin at the same time. IE other python code not running etc.

y8s commented 3 years ago

Is there a list of parameters for the neopix command?

Would the rpi-gpio nodes conflict if there was nothing configured on the pins I'm using for neopix? (I will double check this...)

y8s commented 3 years ago

I had to dig into the python to answer the first question, but your command did light up the strip.

I also checked that python was not using pin 12 (or 32) and it is not.

$ ps aux | grep "python"
pi        5823  0.0  0.6  20652  5748 ?        SNl  09:54   0:00 python -u /home/pi/.node-red/node_modules/node-red-node-pi-gpio/nrgpio.py in 8 down 25
pi        5826  0.0  0.6  12456  5656 ?        SN   09:54   0:00 python -u /home/pi/.node-red/node_modules/node-red-node-pi-gpio/nrgpio.py out 37 100
pi        5828  9.0  0.6  20652  5680 ?        SNl  09:54   0:43 python -u /home/pi/.node-red/node_modules/node-red-node-pi-gpio/nrgpio.py pwm 33 5000
dceejay commented 3 years ago

You should not need to run the command yourself (except to check it does run) - the node should call it - that is what sets up the OK message when it is running.

y8s commented 3 years ago

You should not need to run the command yourself (except to check it does run) - the node should call it - that is what sets up the OK message when it is running.

I understand that the command is simply a diagnostic tool in this context.

But why would it run fine but the node fail with a "Stopped" status? I have uninstalled and reinstalled the node-red-node-pi-neopixel and re-run both the unicorn hat install script AND the node-red install script below:

bash <(curl -sL https://raw.githubusercontent.com/node-red/linux-installers/master/deb/update-nodejs-and-nodered)
curl -sS get.pimoroni.com/unicornhat | bash
dceejay commented 3 years ago

indeed - that is the question. Are you running it as a service ? As the same user as when you run it that command from the command line ? If you are running as a service - is it different if you stop the service and just run node-red from the command line ?

y8s commented 3 years ago

I run everything as my user (pi) without sudo.

so I checked the systemd status and it shows

pam_unix(sudo:auth): conversation failed
pam_unix(sudo:auth): auth could not identify password for [pi]

Which is odd because it used to work. I tried a shortcut by giving pi passwordless sudo and restarted nodered and the status shows up as "OK" now. This is not ideal obviously.

Was there a change from 0.0.25 to 0.1.1 that requried sudo permission?

edit: apparently not because my other install shows this status:

pi : TTY=unknown ; PWD=/home/pi ; USER=root ; COMMAND=/usr/bin/python -u /home/pi/.node-red/node_modules/node-red-node-pi-neopixel/neopix.py 8 40
pam_unix(sudo:session): session opened for user root by (uid=0)

and that install is NOT using passwordless sudo for pi.

EDIT: forgot to answer the question you posed: stopping the service and running node-red does indeed work.

dceejay commented 3 years ago

most odd - it seems to be like the pi user has dropped out of the sudo group. Certainly not something we have done in Node-RED - hopefully not something Pi guys have changed.

wdmtech commented 3 years ago

Also have this issue, however the pi user is in the sudo group as expected.

Starting node-red as a service results in stopped node status:

image

Running node-red on its own works (requires manual intervention to type the sudo password, but not in this case as I had already run a sudo command)

stopping the service and running node-red does indeed work.

image

hardillb commented 3 years ago

@wdmtech Just checking are you actually running Raspbian or Octopi (as implied by the hostname)?

Because on Raspbian running sudo will never ask for a password for the pi user

TheOzarkWizard commented 3 years ago

I have been having the same issue, but get a different return code, listed below. Short of reinstalling everything, which I just did yestrerday, im not sure what to do. This was working 10 minutes ago.

I got cannot read property stdin of null, and after rebooting and trying again I got :

pi : TTY=unknown ; PWD=/home/pi ; USER=root ; COMMAND=/usr/bin/python3 -u /home/pi/.node-red/node_modules/node-red-node-pi-neopixel/neopix.py 8 40 pcent 100 false 0 18