Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

added feature for sending GCODE only once. #29

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

DrWatson
Copy link

@DrWatson DrWatson commented Jun 6, 2018

Made some changes to address an issue that has been reported a few times here. I picked one of the issues (issue 22) as the name of the branch. This has been referred to as a "looping" problem in other posts. It basically allows the user to configure witch a checkbox if they want to old classic behaviour of resending the GCODE or if they want to send it only once. The way this is accomplished is by simply unhooking the callback when the filament is out and then rehooking it again when they resume.

This was referenced Jun 6, 2018
@mylife4aiurr
Copy link

mylife4aiurr commented Jun 7, 2018

Omg this it's really needed. I actually stopped using this pluggin because of this behavior. This bug forced me to learn how to find and configure a free pin in Marlin. Modify and upload firmware and then wire a endstop as a filament sensor. Harder but at least I know how now.

@DrWatson
Copy link
Author

DrWatson commented Jun 7, 2018

If you are interested, I can make the changes available to you (two files to replace in your octoprint deployment) so you can test it out. Let me know and I can make that happen.

@mylife4aiurr
Copy link

@DrWatson Yes please. I still have one printer(Taz6) that I haven't hard wired a filament sensor to. I'd love to try it this weekend.

@DrWatson
Copy link
Author

DrWatson commented Jun 8, 2018

Please read this whole message. If anything in here is not at your comfort level, then I suggest you not proceed. If you do choose to proceed, you do this at your own risk, of course. I will help if I can...just post here.

You will need two files. The first is the _ _ init _ _.py which you can find here:
https://github.com/DrWatson/Octoprint-Filament-Reloaded/tree/issue22/octoprint_filamentreload

The second file is the filamentreload_settings.jinja2 which you can find here:
https://github.com/DrWatson/Octoprint-Filament-Reloaded/tree/issue22/octoprint_filamentreload/templates

Making some assumptions about your octoprint deployment, here, but you should back up both of these files. I will assume that you know how to ssh and get to the folders where these files are. Mine are located here:
/home/pi/oprint/lib/python2.7/site-packages/octoprint_filamentreload/init.py
and here
/home/pi/oprint/lib/python2.7/site-packages/octoprint_filamentreload/templates/filamentreload_settings.jinja2

After you have backed up the original files and replaced them with the two above, you should restart octoprint by running:

sudo service octoprint restart

For me, I am using the reload filament command of M600 to help in the reloading process when I get a filament run out. To do this, I have set mine up using these steps:

  1. Go into the settings for the plugin and change the GCODE entry to something like this:
    M600 X40 Y40 Z10 E2 L10

  2. Place a check in "Pause print when out of filament".

  3. Place a check in "Send GCODE only once when out of filament."

Remember that you need to have M600 enabled in your firmware. It's not on by default in Marlin 1.1.* Here is a video for how to do it:
https://www.youtube.com/watch?v=CDz2IxxINBE

The process will now be that when the filament is out, the M600 command is called once and Octoprint pauses the print. The M600 command will lift the head, park it, and allow for refilling of filament. You control these steps from the LCD on the printer. (Yes M600 in marlin is only operational using the LCD panel.) Once the filament is loaded and you've finished the steps on the LCD, you go over to OctoPrint and resume the print. The head will go back to the position it left off at when the filament ran out and resume the print.

Let me know if you have any questions.

@mylife4aiurr
Copy link

Thanks for the detailed instructions. I haven't touched my Taz6 for months. But I'll dust her off to try this, this weekend.
Its clear you have a thorough understanding of Marlin from your write up. I shouldn't have any trouble getting your changes live with those excellent instructions.
One change I'll make on my own because I dislike the behavior of after a filament change is complete having to hit "continue print" on lcd screen and then also having to hit "resume print" in Octoprint. So I leave pause print unchecked in the pluggin - That way print resumes right after I hit continue on lcd without having to also hit resume in Octoprint. Because I leave pause print unchecked in pluggin, as soon as M600 is complete, nozzle unparks and resumes.
I also I have my custom park position defined in Marlin, so I dont define it in Octoprint pluggin - just a standard M600. Both are just my personal preference.
The main thing is I hope this fixs the loop that currently happens.

@DrWatson
Copy link
Author

DrWatson commented Jun 8, 2018

Leaving the pause print unchecked won't be a solution for you, I fear. Let me explain.

The way the plugin works is that it registers for an event from the Pi GPIO interface. It gets a steady flow of events from this interface regardless of pin change. This is why in the logs you get a message a few times each second that reports "Filament detected!". This is the root cause of the looping behaviour in sending GCODE.

To fix this problem, when the new "Send GCODE only once when out of filament." configuration item is checked, I unregister the callback so the plugin doesn't get any events from the GPIO interface. When you resume the print, it reregisters the callback and the GPIO events begin to flow again.

So if you don't use the pause functionality of the plugin, you won't need to resume the print in Octoprint, however, you will no longer get the GPIO events. In this way, you will only get the out of filament handling once. If you run out of filament again subsequently in the same print, you will not get the event because it hasn't reregistered for the event because resume was never called.

Hope that makes sense.

I don't know if I can get an event into the plugin when the M600 is complete. If I do, then code could be added there to reregister for the GPIO event, but I didn't think of that at the time or writing. Perhaps that's something else for me to look at this weekend or next week.

@mylife4aiurr
Copy link

mylife4aiurr commented Jun 8, 2018

Ok I'll test for the loop behavior fix anyway. And then report back either tonight or tomorrow.

As for hitting resume in Octoprint and continue in lcd, I understand your explanation.
B4 I knew you could just uncheck pause print during filament change. I ran into a situation where I had completed the filament change with LCD, the printer unparked nozzle and returned to print location but then froze waiting for instructions from host(Octoprint). So that can lead to nozzle melting model until user hits resume button in Octoprint. Ofc the way around was to hit resume in Octoprint 1st, then continue print on LCD. I just liked dealing with LCD only by unchecking don't pause....but I won't now 😔

@mylife4aiurr
Copy link

mylife4aiurr commented Jun 9, 2018

@DrWatson
Got my Taz6 dusted off. Updated printers firmware, updated cura software, updated pi3, updated Octoprint and varies pluggins.
Backed up:
init.py
filamentreload_settings.jinja2
Replaced with versions downloaded from the links above. Reloaded Octoprint, but then restarted whole pi3.

I dont see option to "Place a check in "Send GCODE only once when out of filament." in the plggin window

Your versions size init.py is 84,368 compared to old @ 5,292
Your versions size ............settings.jinja2 is 60,228 compared to old @ 2,894
all same file permissions

Couldnt test as I cant get it to install properly?? suggestions?

@DrWatson
Copy link
Author

Those file sizes do not look close at all to what is in my repo. I have downloaded the files from the repo and included them here. Please use these files instead and see if you get different results.

sendGCODEOnce.zip

@mylife4aiurr
Copy link

mylife4aiurr commented Jun 11, 2018

Ok i used the files from the download above. When I do so, the Filament Sensor Reloaded (1.0.1) doesn't show up in the pluggins section on the right where all pluggins are listed and you can alter their parameters.
1st I did a restart of Octoprint. Then I did a complete reboot.

It does show up in the main plug in manager as being installed, however. Reverting to stock and rebooting fixes the issues of it not showing up on the left under pluggins, but then im stock cant test.

@DrWatson
Copy link
Author

That's strange. Those are the exact files I am running. If the plug in fails to load, there will be an error in /home/pi/.octoprint/logs/octoprint.log . If you could put the files from the zip file back in place and restart octoprint again, then paste here what the log says after the restart.

I changed very little for this fix, so I'm surprised it's being difficult.

@mylife4aiurr
Copy link

ok my logging level is set to debug:

 13:50:47,401 - octoprint.startup - INFO - ******************************************************************************
2018-06-11 13:50:47,401 - octoprint.startup - INFO - Starting OctoPrint 1.3.8
2018-06-11 13:50:47,402 - octoprint.startup - INFO - ******************************************************************************
2018-06-11 13:50:47,467 - octoprint.util.connectivity_checker - INFO - Connectivity changed from offline to online
2018-06-11 13:50:48,091 - octoprint.startup - INFO - Blacklist processing done
2018-06-11 13:50:48,170 - octoprint.plugin.core - INFO - Loading plugins from /home/pi/oprint/lib/python2.7/site-packages/octoprint/plugins, /home/pi/.octoprint/plugins and installed plugin packages...
2018-06-11 13:50:51,501 - octoprint.plugin.core - INFO - Found 21 plugin(s) providing 21 mixin implementations, 13 hook handlers
2018-06-11 13:50:51,632 - octoprint.server.heartbeat - INFO - Starting server heartbeat, 900.0s interval
2018-06-11 13:50:51,677 - octoprint.server - INFO - Intermediary server started
2018-06-11 13:50:51,678 - octoprint.plugin.core - INFO - Loading plugins from /home/pi/oprint/lib/python2.7/site-packages/octoprint/plugins, /home/pi/.octoprint/plugins and installed plugin packages...
2018-06-11 13:50:51,974 - octoprint.plugin.core - INFO - Found 21 plugin(s) providing 21 mixin implementations, 13 hook handlers
2018-06-11 13:50:52,011 - octoprint.filemanager.storage - INFO - Initializing the file metadata for /home/pi/.octoprint/uploads...
2018-06-11 13:50:52,779 - octoprint.filemanager.storage - INFO - ... file metadata for /home/pi/.octoprint/uploads initialized successfully.
2018-06-11 13:50:52,811 - octoprint.plugins.filamentreload - INFO - Running RPi.GPIO version '0.6.3'
2018-06-11 13:50:53,007 - octoprint.plugins.softwareupdate - INFO - Loaded version cache from disk
2018-06-11 13:51:03,483 - octoprint.util.pip - INFO - Using "/home/pi/oprint/bin/python -m pip" as command to invoke pip
2018-06-11 13:51:05,864 - octoprint.util.pip - INFO - Version of pip is 9.0.1
2018-06-11 13:51:05,865 - octoprint.util.pip - INFO - pip installs to /home/pi/oprint/lib/python2.7/site-packages (writable -> yes), --user flag needed -> no, virtual env -> yes
2018-06-11 13:51:05,865 - octoprint.util.pip - INFO - ==> pip ok -> yes
2018-06-11 13:51:05,870 - octoprint.plugin.core - INFO - Initialized 21 plugin implementation(s)
2018-06-11 13:51:05,882 - octoprint.plugin.core - INFO - 21 plugin(s) registered with the system:
|  Announcement Plugin (bundled) = /home/pi/oprint/lib/python2.7/site-packages/octoprint/plugins/announcements
|  Core Wizard (bundled) = /home/pi/oprint/lib/python2.7/site-packages/octoprint/plugins/corewizard
|  CuraEngine (<= 15.04) (bundled) = /home/pi/oprint/lib/python2.7/site-packages/octoprint/plugins/cura
|  Discovery (bundled) = /home/pi/oprint/lib/python2.7/site-packages/octoprint/plugins/discovery
|  DisplayZ (0.1.0) = /home/pi/oprint/local/lib/python2.7/site-packages/octoprint_displayz
|  EEPROM Marlin Editor Plugin (1.2.1) = /home/pi/oprint/local/lib/python2.7/site-packages/octoprint_eeprom_marlin
|  Filament Sensor Reloaded (1.0.1) = /home/pi/oprint/local/lib/python2.7/site-packages/octoprint_filamentreload
|  Fullscreen Plugin (0.0.4) = /home/pi/oprint/local/lib/python2.7/site-packages/octoprint_fullscreen
|  GcodeEditor (0.1.1) = /home/pi/oprint/local/lib/python2.7/site-packages/octoprint_GcodeEditor
|  HeaterTimeout (0.0.1) = /home/pi/oprint/local/lib/python2.7/site-packages/octoprint_HeaterTimeout
|  Logging (bundled) = /home/pi/oprint/lib/python2.7/site-packages/octoprint/plugins/logging
|  Navbar Temperature Plugin (0.9) = /home/pi/oprint/local/lib/python2.7/site-packages/octoprint_navbartemp
|  OctoPi Support Plugin (bundled) = /home/pi/oprint/lib/python2.7/site-packages/octoprint/plugins/octopi_support
|  OctoPrint Anywhere (0.6.3) = /home/pi/oprint/local/lib/python2.7/site-packages/octoprint_anywhere
|  Plugin Manager (bundled) = /home/pi/oprint/lib/python2.7/site-packages/octoprint/plugins/pluginmanager
|  Preheat Button (0.2.0) = /home/pi/oprint/local/lib/python2.7/site-packages/octoprint_preheat
|  Printer Safety Check (bundled) = /home/pi/oprint/lib/python2.7/site-packages/octoprint/plugins/printer_safety_check
|  Pushbullet (0.1.9) = /home/pi/oprint/local/lib/python2.7/site-packages/octoprint_octobullet
|  Software Update (bundled) = /home/pi/oprint/lib/python2.7/site-packages/octoprint/plugins/softwareupdate
|  Themeify (1.2.0) = /home/pi/oprint/local/lib/python2.7/site-packages/octoprint_themeify
|  Virtual Printer (bundled) = /home/pi/oprint/lib/python2.7/site-packages/octoprint/plugins/virtual_printer
2018-06-11 13:51:05,899 - octoprint.environment - INFO - Detected environment is Python 2.7.9 under Linux (linux2). Details:
|  hardware:
|    cores: 4
|    freq: 1200.0
|    ram: 918323200
|  os:
|    id: linux
|    platform: linux2
|  plugins:
|    octopi_support:
|      model: 3B
|      revision: a02082
|      version: 0.14.0
|  python:
|    pip: 9.0.1
|    version: 2.7.9
|    virtualenv: /home/pi/oprint
2018-06-11 13:51:05,911 - octoprint.server - INFO - Reset webasset folder /home/pi/.octoprint/generated/webassets...
2018-06-11 13:51:05,936 - octoprint.server - INFO - Reset webasset folder /home/pi/.octoprint/generated/.webassets-cache...
2018-06-11 13:51:05,947 - octoprint.server.util.flask.collect_plugin_assets - WARNING - Plugin GcodeEditor is referring to non existing css asset css/GcodeEditor.css
2018-06-11 13:51:06,200 - octoprint.server - INFO - Shutting down intermediary server...
2018-06-11 13:51:06,465 - octoprint.server - INFO - Intermediary server shut down
2018-06-11 13:51:06,467 - octoprint.events - INFO - Processing startup event, this is our first event
2018-06-11 13:51:06,468 - octoprint.events - INFO - Adding 1 events to queue that were held back before startup event
2018-06-11 13:51:06,475 - octoprint.filemanager - INFO - Adding backlog items from all storage types to analysis queue...
2018-06-11 13:51:06,503 - octoprint.plugins.pluginmanager - INFO - Loaded plugin repository data from disk, was still valid
2018-06-11 13:51:06,518 - octoprint.filemanager - INFO - Added 0 items from storage type "local" to analysis queue
2018-06-11 13:51:06,712 - octoprint.plugins.pluginmanager - INFO - Loaded notice data from disk, was still valid
2018-06-11 13:51:07,014 - octoprint.plugins.discovery - INFO - Registered OctoPrint instance "Taz 6" for _http._tcp
2018-06-11 13:51:07,024 - octoprint.plugins.discovery - INFO - Registered OctoPrint instance "Taz 6" for _octoprint._tcp
2018-06-11 13:51:07,028 - octoprint.plugins.discovery - INFO - Registered OctoPrint instance "Taz 6" for SSDP
2018-06-11 13:51:07,028 - octoprint.server - INFO - Listening on http://127.0.0.1:5000
2018-06-11 13:51:07,050 - octoprint.plugins.HeaterTimeout - INFO - Starting up...
2018-06-11 13:51:07,188 - octoprint.plugins.anywhere - WARNING - Not connected to server ws or connection lost
2018-06-11 13:51:07,197 - octoprint.plugins.filamentreload - INFO - Filament Sensor Reloaded started
2018-06-11 13:51:07,199 - octoprint.plugins.filamentreload - INFO - Setting up sensor.
2018-06-11 13:51:07,265 - octoprint.plugins.filamentreload - INFO - Using Board Mode
2018-06-11 13:51:07,266 - octoprint.plugins.filamentreload - INFO - Filament Sensor active on GPIO Pin [7]
2018-06-11 13:51:07,280 - octoprint.server.util.sockjs - INFO - New connection from client: 127.0.0.1
2018-06-11 13:51:07,285 - octoprint.plugins.anywhere - WARNING - Not connected to server ws or connection lost
2018-06-11 13:51:07,306 - octoprint.plugins.anywhere - WARNING - Not connected to server ws or connection lost
2018-06-11 13:51:08,506 - octoprint.server.util.sockjs - INFO - New connection from client: 192.168.1.181
2018-06-11 13:51:08,833 - octoprint.plugins.octobullet - INFO - Connected to PushBullet
2018-06-11 13:51:08,877 - octoprint.plugins.pluginmanager - INFO - Loaded plugin repository data from disk, was still valid
2018-06-11 13:51:08,970 - octoprint.plugins.pluginmanager - INFO - Loaded notice data from disk, was still valid
2018-06-11 13:51:08,985 - octoprint.server.preemptive_cache - INFO - Preemptively caching / (ui _default) for {'query_string': 'l10n=en', 'path': '/', 'base_url': 'http://192.168.1.7/'}
2018-06-11 13:51:20,513 - octoprint.server.preemptive_cache - INFO - ... done in 11.53s
2018-06-11 13:51:25,974 - octoprint.util.comm - INFO - Changing monitoring state from "Offline" to "Detecting serial port"
2018-06-11 13:51:26,076 - octoprint.util.comm - INFO - Changing monitoring state from "Detecting serial port" to "Opening serial port"
2018-06-11 13:51:26,079 - octoprint.util.comm - INFO - Changing monitoring state from "Opening serial port" to "Connecting"
2018-06-11 13:51:26,086 - octoprint.util.comm - INFO - M110 detected, setting current line number to 0
2018-06-11 13:51:35,277 - octoprint.util.comm - INFO - M110 detected, setting current line number to 0
2018-06-11 13:51:40,971 - octoprint.util.comm - INFO - Changing monitoring state from "Connecting" to "Operational"
2018-06-11 13:51:40,979 - octoprint.util.comm - INFO - M110 detected, setting current line number to 0
2018-06-11 13:51:41,051 - octoprint.util.comm - INFO - Printer reports firmware name "Marlin"
2018-06-11 13:51:41,062 - octoprint.util.comm - INFO - Firmware states that it supports temperature autoreporting
2018-06-11 13:51:41,124 - octoprint.util.comm - INFO - Firmware states that it supports temperature autoreporting

@mylife4aiurr
Copy link

Deleted the pluggin. Reinstalled.
renamed old
upload new

Now I get pluggin showing up in master pluggin list and on left where I can edit parameters.
However I dont see the new "only send once check box"

@DrWatson
Copy link
Author

type:
cd /home/pi/oprint/lib/python2.7/site-packages

then type:
grep -r -i "send gcode" *

post the results here.

@mylife4aiurr
Copy link

pi@octopi:~/oprint/lib/python2.7/site-packages $ grep -r -i "send gcode" *
octoprint_filamentreload/templates/filamentreload_settings.jinja2: {{ _('Send GCODE only once when out of filament.') }}

@DrWatson
Copy link
Author

DrWatson commented Jun 12, 2018

Something still isn't right. There should be more files that contain that pattern. At least two:

  1. octoprint_filamentreload/templates/filamentreload_settings.jinja2
  2. octoprint_filamentreload/_ _ init _ _.py

Let's try this from scratch again...this time a little more thorough. (Sorry about this.)

Unzip the zip file in this message and place the filamentreload_settings.jinja2 file that it in the templates folder (octoprint_filamentreload/templates/filamentreload_settings.jinja2)

Place the _ _ init _ _.py in the folder one up from the templates folder (octoprint_filamentreload/).

In the octoprint_filamentreload/ folder, please delete the _ _ init _ _.pyc file. This is a compiled version of the file and will be rebuilt when needed. Perhaps something is being cached.

Reboot the Pi.

When you go to your web browser and navigate to the settings page for the filament reload configuration, press Shift+Reload (I will assume chrome, don't know what force reload would be in whatever browser you're using) to make sure you are not being served a cached copy of the page.

2.zip

@mylife4aiurr
Copy link

Ah oh ok. I never deleted the .pyc
At work today, I'll try it tonight... Report back

@DrWatson
Copy link
Author

I haven't had to delete the pyc before, but I'm thinking it's more likely a browser cache thing. The new files in the zip are the actual files I am running on my Pi (which are slightly different than the ones in the repo.) Just curious. Were you replacing the files in the two different directories? ie octoprint_filamentreload/templates/ and octoprint_filamentreload/_ _ init _ _.py? What is the whole path for the files you are replacing? Mine is in: /home/pi/oprint/lib/python2.7/site-packages/octoprint_filamentreload.

@mylife4aiurr
Copy link

Yes my path was the same as yours. I renamed originals as ......old, in both folders. Then uploaded your versions.

@mylife4aiurr
Copy link

Success - I can see the new "Send GCODE only once when out of filament" in the pluggin window.
Deleted old versions and deleted the compiled pyc. Used the versions in 2.zip

I can now test filament changes for loop behavior, :)

@DrWatson
Copy link
Author

Awesome! Let me know how the testing goes.

@mylife4aiurr
Copy link

mylife4aiurr commented Jun 13, 2018

Did a little testing last night. At first I thought it didnt work. When I cut filament, printer kept on printing. Thought it was something on my end. So I double checked the pin assignment and the state of sensor, normally open, normally closed.

Then I decided to tail the output of log in real time...... From turning printer on and reboot of Octoprint. Did test again monitoring the log output. Cut filament. No trigger filament change, even in log.
So since filament was already cut off from the spool at this point, I just pulled sensor pass cut end again, then it triggered. And it triggered only once, no looping behavior.

So from scratch again. Printer powered off. Octoprint restarted. No trigger 1st out of filament. 2nd out of filament detected. No loop.

@DrWatson
Copy link
Author

Great, so this solution works for you? Call it a success?

@mylife4aiurr
Copy link

mylife4aiurr commented Jun 14, 2018

No loop behavior for filament changes - success.

For me 1st filament outage undetected.
Not good. This weekend I can test more.

@DrWatson
Copy link
Author

Just re-read your messages again and realized I missed the part about it not working the first time. I don't know why that would be. Would be interesting to see if that happens with the plugin without my modifications. If so, then we can rule out the changes I made as being the culprit and tackle it differently. If you find that it misses the first out of filament trigger again and you determine it's not some kind of problem with the printer or detector somehow, then let me know and we can try and troubleshoot together.

@mylife4aiurr
Copy link

mylife4aiurr commented Jun 16, 2018

@DrWatson
I dont know if your around. But I should be available for the next 10 hours or so.
I have troubleshooted as best I can. With your new code - no loop when changing filament ie printer doesn't initiate another filament change.
However I cant get it to trigger the 1st filament outage, only 2 or 3 etc.....

Without your new code, stock filament reload pluggin - I change filament - printer gets stuck in a loop if you happen to trigger the runout sensor during a filament change - creating a loop. However stock pluggin is always able to trigger/catch a filament runout condition.

@3DEnthusiast
Copy link

I followed suggestions here and deleted the .pyc and replaced everything. It worked once. Now anytime the sensor is triggered, I receive the following in a webpage and have to completely restart the Octoprint.

The OctoPrint server is currently not running
If you just started up your Raspberry Pi, please wait a couple of seconds, then try to refresh this page.

If the issue persists, please log into your Raspberry Pi via SSH and check the following:

Verify that the process is running: ps -ef | grep -i octoprint | grep -i python should show a python process:
pi@octopi:~ $ ps -ef | grep -i octoprint | grep -i python
pi 1441 1 6 11:12 ? 00:00:15 /home/pi/oprint/bin/python
/home/pi/oprint/bin/octoprint --host=127.0.0.1 --port=5000
If it isn't, the question is why. Take a look into ~/.octoprint/logs/octoprint.log, there might be an error logged in there that helps to determine what's wrong.
You might also want to try if you can restart the server (if no obvious error is visible): sudo service octoprint restart.
If all that doesn't help to trouble shoot the issue, you can seek support on the OctoPrint Mailinglist or in the OctoPrint G+ Community. Please provide your OctoPi and OctoPrint versions, your octoprint.log (in form of a pastebin link) and explain what you already tried and observed as detailed as possible.

The gcode I am using is as follows:
M104 S0 ;turn extruder heater off
G91 ;change the printer into relative movement mode
G1 Z10 ;move the head up 10mm
G90 ;put printer back in absolute movement mode

Also I have the "pause Print" and "Send GCode only once" checked.

@DrWatson
Copy link
Author

Looks like octoprint is crashing. Can you remove the gcode you have entered in the text box and try again ? We need to narrow down what is causing the issue. Did any of this work prior to substituting the new files?

@DrWatson
Copy link
Author

@mylife4aiurr
I will take a look this weekend as to why you don't get the first trigger.

@3DEnthusiast
Copy link

It did work stock. I believe it works with just the pause print checked and no gcode but I will have to test it further and get back to you.

@DrWatson
Copy link
Author

@3DEnthusiast

Just to be specific, if you could try having pause checked and send gcode once checked, but don't include any gcode. If octoprint still crashes, then we can rule out the gcode and the gcode messaging pipeline and we can look elsewhere.

@3DEnthusiast
Copy link

3DEnthusiast commented Jun 22, 2018

@DrWatson

The error appears to occur when gcode is input into the box with both items checked. With no gcode, the printer pauses as expected and wants for the unpause to be hit.

@DrWatson
Copy link
Author

@3DEnthusiast
I managed to reproduce this. This didn't used to happen when I originally wrote this code. What version of Octoprint are you running? I am using 1.3.8 but only recently updated to that. I wonder if something changed under the hood that is causing this.

For me, I could get the pause to happen on the first time during a print. Then I continue the print with no issues. Then I go to remove the filament again, and it crashed Octoprint. I have to restart everything and once I'm back up again, I remove the filament. This time, the GCODE doesn't get executed and Octoprint crashes. Is this the same behaviour you see?

@mylife4aiurr
Copy link

Speaking of updates. I upgraded my Octoprint version to newest maintenance release (1.3.9rc1).
I will try your changes to pluggin with 1.3.9rc1 and a different sensor just to try and rule out my sensor as issue with no trigger first filament outage.

@3DEnthusiast
Copy link

3DEnthusiast commented Jun 22, 2018

I'm running 1.3.8, myself.

That sounds like what is happening to my octoprint when any gcode is used after it's paused.

@DrWatson
Copy link
Author

I think I have found the problem with Octoprint crashing. I think it is because I unregister for the filament out callbacks while I am inside the callback itself. Kind of like sawing off the branch you're standing in. I have changed how it works now so it doesn't do that.

I am doing some testing right now and will report back after I am satsfied with the results. So far, it's looking good though.

@3DEnthusiast
Copy link

Awesome! Hopefully it is an easy solution!

@DrWatson
Copy link
Author

Bad news. Just made it crash again.

I decided to remove the plugin all together and reinstall. Then I left it stock and only enabled the pause checkbox. Then went into the Octoprint configuration into the section GCODE Scripts -> After print job is paused and entered this GCODE:

M600 X40 Y40 Z10 E2 L10

I then started a print job and caused a out of filament trigger. Octoprint paused and then immediately crashed. I assume it crashed when it tried to run the GCODE. Ugh. So this is with the stock plugin and no GCODE executed.

I decided to try again. I started another print job and caused a out of filament trigger. Octoprint paused and the GCODE executed as expected. Weird! Then when I refilled the filament and clicked resume, Octoprint crashed again.

There is definitely something going on here and I have confirmed it doesn't have anything to do with my changes. I am going to have to post something on the Octoprint Google+ group and see if anyone else is seeing issues somewhere around this area.

Sorry guys. Looks like a solution is not in the cards in the short term.

@DrWatson
Copy link
Author

I actually, just thought of something else to try. I am going to remove the plugin again and remove the run out sensor also. I am going to leave the GCODE in the pause script area of Octoprint. Then I am going to manually click pause in the UI and see if it crashes. If it does, then we can rule out the plugin altogether and point directly at Octoprint with an easier set of reproduction steps. I'll let you know what I find.

@3DEnthusiast
Copy link

I just put the move gcode in the "after pause" section of octoprint. It worked about 4 times but now it's crashed octoprint.

Pause print and send once we're checked but no gcode in the plug-in itself.

@3DEnthusiast
Copy link

Further testing shows that Octoprint seems to crash if it's paused and restarted multiple times. I believe my optical endstop is triggering multiple times and causing it to crash.

@DrWatson
Copy link
Author

What about if you manually pause and restart?

@3DEnthusiast
Copy link

3DEnthusiast commented Jun 26, 2018 via email

@bjstrange
Copy link
Contributor

Added different fix for this issue at #35

@raindancer2204
Copy link

Hi i have a question. I have also the Filament Sensor reloaded Plugin with the orginal Anycubic Sensor. It is connected to the PI3 directly and it works. I tried it make pause etc and it works but in some cases it dont works. I got the Message in the octoprintlog:
"octoprint.plugins.filamentreload - INFO - Sensor callback but no trigger state change"

And the Octoprint does not stop. I checked the Switch with "gpio read 7" and it works fine from PI side.

Does anybody now a fix for this Problem? I use Octoprint 1.3.10 with Filament Plugin Version: 1.1.0

Regards.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

5 participants