beyondscreen / node-rpi-ws281x-native

native bindings to drive WS2811 (or WS2812) LED-Controllers on a Raspberry Pi
MIT License
224 stars 101 forks source link

problems with reset() and finalize() in the new api #77

Open natcl opened 6 years ago

natcl commented 6 years ago

With the new version (1.x) I get the following error when I call reset():

Press <ctrl>+C to exit.
^C/home/pi/leds/node_modules/rpi-ws281x-native/lib/ws281x-native.js:93
    this.array.fill(0);
              ^

TypeError: Cannot read property 'fill' of null
    at Channel.[_reset] (/home/pi/leds/node_modules/rpi-ws281x-native/lib/ws281x-native.js:93:15)
    at channels.forEach.channel (/home/pi/leds/node_modules/rpi-ws281x-native/lib/ws281x-native.js:173:46)
    at Array.forEach (native)
    at Function.reset (/home/pi/leds/node_modules/rpi-ws281x-native/lib/ws281x-native.js:173:12)
    at process.<anonymous> (/home/pi/leds/node_modules/rpi-ws281x-native/examples/new-api.js:10:10)
    at emitNone (events.js:86:13)
    at process.emit (events.js:185:7)
    at Signal.wrap.onsignal (internal/process.js:217:44)

Also finalize() does a segmentation fault.

Any ideas ?

Thanks !

natcl commented 6 years ago

I fixed the first problem by changing this:

  [_reset]() {
    if (this.array) this.array.fill(0);
  }

The segmentation fault remains upon finalize though.

riccardolardi commented 6 years ago

Same problem here, .finalize() leads to segmentation fault, but weirdly only sometimes