Open JimmyPesto opened 4 years ago
Can you try this version ? npm install https://github.com/cymplecy/node-red-contrib-rpi-ws2801#Change-to-deal-with-upstream-move-to-use-bus-and-device-instead-of-port
I'm working from japan now and don't have access to hardware but if all goes fine with it I'll merge it. thanks.
First I installed the current version of this repo with:
npm install https://github.com/natcl/node-red-contrib-rpi-ws2801.git
as you already have the new dependency of the 'rpi-ws2801' using 'spi-device' module to run 2-wire bus.
But this throws errors when I access the LEDs:
error opening SPI device 2.5 Error: EINVAL, incorrect arguments passed to openSync(busNumber, deviceNumber[, options]) at RPiWS2801.connect (/home/pi/node-red-ws2801/node_modules/rpi-ws2801/rpi-ws2801.js:52:22) at new Ws2801Node (/home/pi/node-red-ws2801/node_modules/node-red-contrib-rpi-ws2801/rpi-ws2801/rpi-ws2801.js:20:23) at Object.createNode (/usr/lib/node_modules/node-red/node_modules/@node-red/runtime/lib/nodes/flows/util.js:483:31)
I think cymplecy's fork has the same problem. I'm not into node-red but I found the error and I will try to fix it later on.
It accrues when in this file:
node-red-contrib-rpi-ws2801/rpi-ws2801/rpi-ws2801.js
line 18 is called:
node.leds.connect(node.numLeds, node.port, node.gamma);
as the connect method from the 'rpi-ws2801' module wants this parameters (’rpi-ws2801.js’ line 38):
connect: function(numLEDs, spiBus, spiDevice, gamma)
which is then basically calling the openSync method defined by the 'spi-device' module.
openSync(busNumber, deviceNumber[, options]) busNumber - the number of the SPI bus to open, 0 for /dev/spidev0.n, 1 for /dev/spidev1.n, ... deviceNumber - the number of the SPI device to open, 0 for /dev/spidevn.0, 1 for /dev/spidevn.1, ... options - an optional object specifying device configuration options
So we need busNumber and deviceNumber. /dev/spidev[busNumber].[deviceNumber]
There are two possible solutions: 1) Keep the current node-red configuration and parse SPI port property of the ws2801 node and pass the numbers to the connect method. 2) Change the properties of the node and let the users specify busNumber and deviceNumber themselves.
As I'm not into node-red i could create a pull request with solution 1).
Pull request is available now.
Oops! The open pull request of @cymplecy fixes the issue with solution 2). I really didn't see this haha He took care of keeping the old SPI port property and added the new parameters to the node. Maybe my request is a little bit more straight forward for users who do not know whats the bus/device number of the /dev/spidev0.0 string. Anyway it would be great if you could merge one of our requests.
Greetings ;)
Hey,
I'm trying to setup some WS2801 on an Raspberry Pi 3 B+ running Buster but the rpi-ws2801 dependency does not work based on the fs access to SPI method from the past. I dont know why, but it really does not. Everything is hooked up and installed fine. The current npm package I get running "npm i rpi-ws2801" and the commit in your dependencies do not throw any errors but the leds are not working at all. Some flash up for a moment or switch to a random color. When i clone the newest commit from Jorgen-VikingGod/node-rpi-ws2801 (e118c5310b1badbab14dfacd852fcdc8961028a4) the provided example code runs finde. It would be great if you could update your dependency.
Edit: Okay now i saw this is already done. Sorry! But maybe someone could explain me how to import the newest version from this repo into my node-red flows. I've tried to clone it to the node_modules directory of my node_red user space and added it as a dependency of the package.json but I get this error:
SPI device is specified with "/dev/spidev0.0" in node-red. I really cant see whats going wrong.
Greetings ;)