Cannot call method 'stop' of undefined
80leaves opened this issue · 9 comments
Hey,
I just created a fresh copy of wheezy on a raspberrypi with node v0.10.5 and using your example I'm getting following message:
/home/pi/gpio/node_modules/gpio/lib/gpio.js:124
GPIO.prototype.unexport = function(fn) { this.valueWatcher.stop(); _unexport(t
^
TypeError: Cannot call method 'stop' of undefined
at GPIO.unexport (/home/pi/gpio/node_modules/gpio/lib/gpio.js:124:60)
at gpio.export.ready (/home/pi/gpio/app.js:29:13)
at /home/pi/gpio/node_modules/gpio/lib/gpio.js:102:51
at /home/pi/gpio/node_modules/gpio/lib/gpio.js:53:38
at /home/pi/gpio/node_modules/gpio/lib/gpio.js:20:33
at fs.js:944:21
at Object.oncomplete (fs.js:107:15)
can you post your code in app.js
?
I think I know what the problem is. When a header is exported, this library will try to unexport first. Looks like the FileWatcher isn't quite ready yet. I'm surprised I didn't catch this before. Pretty sure I can write a failing test case and a fix for this.
I used the example provided straight away. The only change I made was at the port-number.
how do you fix this?
Are you using the code under "standard usage"? That's the only piece of code I was able to produce the Cannot call method 'stop' of undefined
error in. If so, I recommend running the example code under the "Cycle voltage every half second" section instead.
The one under "standard usage" is just showing what the API looks like and isn't meant to be thrown into a file and ran. You get the above error when trying to unexport
a header when it hasn't been fully exported yet. I really must fix the README to make this more clear.
Indeed! I tried your recommended example from the "Cycle voltage every half second". It somehow works only as root, but I guess I messed up some permissions while playing around with it.
This is expected, accessing the gpio headers require root access. I'm actually looking at adopting gpio-admin so that gpio access permissions can be assigned to a user instead. For the time being, you need to run as root. I'll update the README to include this information.
thx!