MoonshineSG / Octoprint-Filament

Pause print on GPIO sensor
26 stars 16 forks source link

Error while calling plugin filament #8

Open Werja opened 8 years ago

Werja commented 8 years ago

from octoprint Log:

2016-09-01 15:53:54,607 - octoprint.plugins.filament - INFO - Running RPi.GPIO version '0.6.2'... 2016-09-01 15:53:54,610 - octoprint.plugins.filament - INFO - Filament Sensor Plugin [filament] initialized... ... 2016-09-01 15:53:57,605 - octoprint.plugins.filament - INFO - Filament Sensor Plugin setup on GPIO [2]... ... 2016-09-01 16:36:19,306 - octoprint.plugin - ERROR - Error while calling plugin filament Traceback (most recent call last): File "/home/pi/oprint/local/lib/python2.7/site-packages/OctoPrint-1.2.15-py2.7.egg/octoprint/plugin/init.py", line 204, in call_plugin result = getattr(plugin, method)(_args, *_kwargs) File "/home/pi/oprint/local/lib/python2.7/site-packages/octoprint_filament/init.py", line 56, in on_event self.setup_gpio() File "/home/pi/oprint/local/lib/python2.7/site-packages/octoprint_filament/init.py", line 70, in setup_gpio GPIO.add_event_detect(self.PIN_FILAMENT, GPIO.FALLING, callback=self.check_gpio, bouncetime=self.BOUNCE) RuntimeError: Failed to add edge detection

MoonshineSG commented 8 years ago

what pin number are you using ?

Werja commented 8 years ago

2016-09-01 15:53:57,605 - octoprint.plugins.filament - INFO - Filament Sensor Plugin setup on GPIO [2]... The status request via API works!

MoonshineSG commented 8 years ago

That is odd.... Just trying to see what can be wrong... Did you do a "chmod a+rw /dev/gpiomem" ? Assume running under 'pi' user ? What OS version ?

Werja commented 8 years ago

OS Version 7 (wheezy) running under pi user I have the "chmod a+rw /dev/gpiomem" added to the octoprint startscript

MoonshineSG commented 8 years ago

can you run a "sudo chmod a+rw /dev/gpiomem" from terminal ? just run it once and restart OctoPrint .

do a ls -l /dev/gpiomem and capture the output... I'm curious what is it now...

I don't think you need that to be in the startup script...

MoonshineSG commented 8 years ago

Then again... if you said the request via API works it has nothing to do with permissions... And, of course, the API returns the correct status of the filament sensor.. right ?

Werja commented 8 years ago

yes.. { "status": "1" } when filament is detected and { "status": "0" } if not detected

MoonshineSG commented 8 years ago

I which I can say I know how to help... what's your hardware like ? RPi2 RPi3 ? I can try to do an exact setup and see what happens, but it might take a while for me to have the time to do that...

Not much help from google when searching for "Failed to add edge detection"...

Werja commented 8 years ago

ok, many thanks for your help. I think it is a problem in my individual RPi / Octoprint configuration. I will give you feedback, when the problem is solved.

MoonshineSG commented 8 years ago

Please do. It might help in the future. Hope you solve it!

ghvader commented 7 years ago

I have the same exact issue as the OP. any suggestions?

so the RPI and octoprint see's the change in filament state. but it never pauses. from the log setup 2016-10-23 18:17:02,127 - octoprint.plugins.filament - INFO - Filament Sensor Plugin setup on GPIO [24]... then when called to act 2016-10-23 18:17:46,314 - octoprint.plugins.filament - INFO - Printing started. Filament sensor enabled. 2016-10-23 18:17:47,354 - octoprint.plugin - ERROR - Error while calling plugin filament Traceback (most recent call last): File "/home/pi/oprint/local/lib/python2.7/site-packages/OctoPrint-1.2.16-py2.7.egg/octoprint/plugin/init.py", line 204, in call_plugin result = getattr(plugin, method)(_args, *_kwargs) File "/home/pi/oprint/local/lib/python2.7/site-packages/octoprint_filament/init.py", line 56, in on_event self.setup_gpio() File "/home/pi/oprint/local/lib/python2.7/site-packages/octoprint_filament/init.py", line 70, in setup_gpio GPIO.add_event_detect(self.PIN_FILAMENT, GPIO.FALLING, callback=self.check_gpio, bouncetime=self.BOUNCE) RuntimeError: Failed to add edge detection

MoonshineSG commented 7 years ago

The "RuntimeError: Failed to add edge detection" seams to be a problem with the underlying OS.

ghvader commented 7 years ago

i was using the octopi image, today i went ahead and started fresh with raspbian and installed octoprint manually. i was able to get the plugin working correctly. it did indeed pause the print.. so you were right.. thanks for the tip!

MoonshineSG commented 7 years ago

@ghvader if you install the devel branch, the plugin will fire FILAMENT_RUNOUT event. You can then, write your own plugin to handle that event in any way you choose.

A temporary solution, is to write the M commands to turn off the heater and bed in the OctoPrint Settings "GCODE Scripts" / "After print job is paused" (just don't forget to turn it off otherwise ANY pause will stop your heaters!!!)

Btw, you should never leave the house with the printer running.

ghvader commented 7 years ago

I saw those options just after i posted my comment.. so i came back for an edit. I'll give the M codes a try.

yeah yeah :)

MoonshineSG commented 7 years ago

@ghvader Wait a couple of minutes and I'm updating the devel. I'm changing "pause" to "gcode" and you can write whatever you want there... This should work for you