Stephan3 / dwc2-for-klipper

A translator between DWC2 and Klipper
GNU General Public License v3.0
160 stars 38 forks source link

Printer instance has no attribute 'try_load_module' #73

Closed markwinger closed 4 years ago

markwinger commented 4 years ago

I have been trying to install dwc2 for 2 days. I was running octoprint with klipper and tried installing as described at:

https://github.com/Stephan3/dwc2-for-klipper

but that fails at wget https://github.com/chrishamm/DuetWebControl/releases/download/2.1.6/DuetWebControl-SBC.zip with the error indicating 2.1.6 does not exist. I tried using: wget https://github.com/chrishamm/DuetWebControl/releases/download/2.0.0-RC5/DuetWebControl.zip

which is described at:https://klipper.info/klipper-+-dwc2-1/installing-dwc2

That installed but the gui would not come up. If I open octoprint the klipper console "status" says:

Internal error during connect: Printer instance has no attribute 'try_load_module'

I even tried installing on a clean raspbian system with the installer.sh descibed at:https://github.com/manu7irl/klipper-DWC2-installer?files=1. I only have one printer so this is more that I need but I tried it anyway.
With this I could not get dwc2, or octoprint guis to open and of course klipper then is not running.

I did install this a few months ago and it worked but I decided not to switch then so went back to octoprint. (no longer installed).

The dwc2 gui fails to open(Unable to connect), and klipper does not start with this try_load_module error.

What next????

pluuuk commented 4 years ago

For the pause and resume behavior, the original repo had MOVE=0, which does not move the head back to its position.

The GCODE to resume and move the head is:

RESTORE_GCODE_STATE NAME=DWC_BOTTON MOVE=1

I think this is the default behavior for reprapfirmware. I will take a look at your macro issue later today.

On Tue, May 12, 2020, 11:55 AM markwinger notifications@github.com wrote:

About pause. If I pause using the pause button it stops and resume restarts but doe no retraction or head positioning. The docs for it say that pause executes the pause.g system macro. Under system I see no macros, only config.g which is printer.cfg. I'm guessing if I want to change the pause functionality I need to create a pause macro, the current behavior is a default and there is no macro. Is that correct?

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/Stephan3/dwc2-for-klipper/issues/73#issuecomment-627529162, or unsubscribe https://github.com/notifications/unsubscribe-auth/AEMFV6FOUDOHEIMGZSWJLV3RRGLTNANCNFSM4M45TLGA .

tripstar76 commented 4 years ago

Try changing the macro name to capitals......MY_PAUSE.

On Tue, 12 May 2020, 19:55 markwinger, notifications@github.com wrote:

About pause. If I pause using the pause button it stops and resume restarts but doe no retraction or head positioning. The docs for it say that pause executes the pause.g system macro. Under system I see no macros, only config.g which is printer.cfg. I'm guessing if I want to change the pause functionality I need to create a pause macro, the current behavior is a default and there is no macro. Is that correct?

— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub https://github.com/Stephan3/dwc2-for-klipper/issues/73#issuecomment-627529162, or unsubscribe https://github.com/notifications/unsubscribe-auth/AGLJBBIWB2FYM7VANFWX4TDRRGLTPANCNFSM4M45TLGA .

markwinger commented 4 years ago

G29 is already caps and it does not work. (long print still running so I cant change anything yet)

None of my macros can be executed or edited in the file management section. Should I be able to edit them?

tripstar76 commented 4 years ago

@pluuuk

Is this a typo? line 1074:

def cmd_M32(self, gcmd):
    self.sdcard.cmd_M23(gcmd)
Szeker commented 4 years ago

I beleive, it is "UPLOAD AND START" = select file and start SD print, so first load the file => M23, than start printing => M24.

So NOT a typo.

pluuuk commented 4 years ago

@tripstar76 and @Szeker, can you provide your comments about the fixes on #75? It's hard to keep track of the conversation. @tripstar76, Szeker is correct. M24 starts the print, M32 is the reprapfirmware command that is natively implemented by klipper as M23+ M24. Regarding the macros, I can take a look and see if I broke something when re implementing the gcodes for macro management. I will provide feedback to @markwinger here.

markwinger commented 4 years ago

Changed the macro to MY_PAUSE. No Change.

pluuuk commented 4 years ago

@markwinger , I have fixed the macro issue. Please do a git pull of the latest commit on the fork in #75 .

markwinger commented 4 years ago

Again, I don't know how git works so what commands do I issue to pull from #75.

pluuuk commented 4 years ago

I'm assuming that you installed using my instructions, so simply running git pull works.

markwinger commented 4 years ago

Progress, I can now run macros. I still cannot edit from file management. Is that supported?

pluuuk commented 4 years ago

I don't think that's ever been supported.

On Tue, May 12, 2020, 8:49 PM markwinger notifications@github.com wrote:

Progress, I can now run macros. I still cannot edit from file management. Is that supported?

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/Stephan3/dwc2-for-klipper/issues/73#issuecomment-627727809, or unsubscribe https://github.com/notifications/unsubscribe-auth/AEMFV6HW7JNL2DSDZATKRILRRIKEBANCNFSM4M45TLGA .

markwinger commented 4 years ago

Macros are working. So I wanted to try get the pause/resume buttons to run custom pause/resume gcode. Things you should know says: For pause and resume macros you can use: kliper gcode macros pause_print resume_print cancel_print (not case sensitive)

So I simply changed my_pause, my_resume macro names to pause_print and resume_print, restarted firmware and stated a print. While printing I paused the print. The printer stopped and dwc2 pops up: connection interupted attempting to reconnect. The gui is continuously flashing with this error. The klipper log shows: Exiting SD card print (position 3628) Uncaught exception GET /rr_status?type=3 (192.168.1.118) HTTPServerRequest(protocol='http', host='192.168.1.107:4750', method='GET', uri='/rr_status?type=3', version='HTTP/1.1', remote_ip='192.168.1.118') Traceback (most recent call last): File "/home/pi/klippy-env/local/lib/python2.7/site-packages/tornado/web.py", line 1592, in _execute result = yield result File "/home/pi/klippy-env/local/lib/python2.7/site-packages/tornado/gen.py", line 1133, in run value = future.result() File "/home/pi/klippy-env/local/lib/python2.7/site-packages/tornado/concurrent.py", line 261, in result raise_exc_info(self._exc_info) File "/home/pi/klippy-env/local/lib/python2.7/site-packages/tornado/gen.py", line 326, in wrapper yielded = next(result) File "/home/pi/klipper/klippy/extras/web_dwc2.py", line 272, in get self.web_dwc2.rr_status_3() File "/home/pi/klipper/klippy/extras/web_dwc2.py", line 898, in rr_status_3 "status": self.get_printer_status() , File "/home/pi/klipper/klippy/extras/web_dwc2.py", line 1359, in get_printer_status self.pause_macro() File "/home/pi/klipper/klippy/extras/web_dwc2.py", line 1226, in pause_macro self.gcode_queue.append(parse_params('PAUSE_PRINT')) NameError: global name 'parse_params' is not defined DWC2:76510.02 - 192.168.1.118 - GET - /rr_connect?password=reprap&time=2020-5-13T8%3A28%3A31 Unhandled exception during run Traceback (most recent call last): File "/home/pi/klipper/klippy/klippy.py", line 178, in run self.reactor.run() File "/home/pi/klipper/klippy/reactor.py", line 251, in run g_next.switch() File "/home/pi/klipper/klippy/reactor.py", line 278, in _dispatch_loop timeout = self._check_timers(eventtime) File "/home/pi/klipper/klippy/reactor.py", line 136, in _check_timers t.waketime = waketime = t.callback(eventtime) File "/home/pi/klipper/klippy/reactor.py", line 48, in invoke res = self.callback(eventtime) File "/home/pi/klipper/klippy/extras/web_dwc2.py", line 1614, in update_printdata if self.get_printer_status() in ['S', 'P', 'D']: File "/home/pi/klipper/klippy/extras/web_dwc2.py", line 1359, in get_printer_status self.pause_macro() File "/home/pi/klipper/klippy/extras/web_dwc2.py", line 1226, in pause_macro self.gcode_queue.append(parse_params('PAUSE_PRINT')) NameError: global name 'parse_params' is not defined ~

markwinger commented 4 years ago

I tried a different approach. I renamed pause_print, resume_print to my_pause_print and my_resume_print so they would not be executed but the pause/resume buttons. I then created 2 dwc2 macros, pause.g and resume.g. I tried clicking the pause button and it worked. So I clicked the resume button and it resumed immediately, but did not wait for nozzle temp to reach target, but it did start heating back up to the target temp. Since I did not wait very long before resuming, the temp had not dropped much so extrusion temp was still above minimum. So I repeated the test this time waiting for the temp to get well below minimum temp. This time when I resumed, the buttons immediately changed to grayed pause and a start again button and showed print 100% done. But the macro was running, because a the temperature target was reset, nozzle started to heat. When target was reached I got a popup saying the idle timeout had been reset to 600(Last thing in the resume macro).

At this point printer showed print 100% complete with hotend and bed at target temperatures. I waited 10 minutes to confirm idle timeout turned off heaters. That worked.

So I repeated the process using the my_pause_printer and my_resume_print macros to see if they work correctly. But got the error about white space in the json file again.

Rebooted, ran some macros ok, so tried again. While printing, all macros report the white space error.

So the problem now appears to be macros work, but not while printing.

I attached my printer.cfg file. config.txt

markwinger commented 4 years ago

I tried my filament runout renabling octoprint and it fails to start correctly that way as well. How do I disable dwc2 to insure it is not interfering with octoprint?

pluuuk commented 4 years ago

You can rename the file in:

klipper/klippy/extras/dwc2-for-klipper.py to dwc2-for-klipper.py.bak

To enable it again, rename it back to the original extension.

On Wed, May 13, 2020, 11:42 AM markwinger notifications@github.com wrote:

I tried my filament runout renabling octoprint and it fails to start correctly that way as well. How do I disable dwc2 to insure it is not interfering with octoprint?

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/Stephan3/dwc2-for-klipper/issues/73#issuecomment-628174418, or unsubscribe https://github.com/notifications/unsubscribe-auth/AEMFV6EPRSBJ6LDF7H43W43RRLSYLANCNFSM4M45TLGA .

pluuuk commented 4 years ago

PAUSE_PRINT @markwinger , I have pushed a fix to the issue in this comment, it was a typo in the pause gcode execution. It should work as nominal now. Rename your macros to how you had them setup originally, don't list them as uppercase.

pluuuk commented 4 years ago

@markwinger , can you please run

cd ~/dwc2-for-klipper/
git pull

And retest?

markwinger commented 4 years ago

I have not tried your change yet. But I have a new piece of info. I did a pause, which saves the temp. I did a resume which resets the temp with an M109. The print resumed immediately but the temp target did not change. I waited a minute or two and did a pause again. At this point the M109 must have been issued because the target changed back to the original temp. When the target temp was reached, the resume took place. This is really interesting. Here is the resume macro. [gcode_macro RESUME_PRINT] gcode: reset_temp SET_IDLE_TIMEOUT timeout=600 resume

Notice the reset_temp is the first thing done. Which should wait for target temperature before continuing. But I see the SET_IDLE_TIMEOUT when the resume was done as if it skipped the reset_temp. But then the reset_temp appears to run later when I run the pause. Seems like we have an sequencing issues here.

I cant do the pull right now but hopefully I can in an hour or 2.

markwinger commented 4 years ago

I did your pull. Although I don't know how your code works, it appears that the macros are forked or run in a different thread so the job will continue to run even though the macro is waiting. This clear when I do a resume, the print starts immediately, not waiting for the macro to complete. I arrive at this conclusion because when I do resume and pause again before the m109 of the previous macro is complete, the next macro does not start until the m109 is done. i.e it keeps printing until the target temp is reached, then it pauses. I also see the message saying the idle_timeout has changed reinforcing this conclusion.

A different issue, if I pause the job 3 time is goes to done. There must be some pause_resume limit imposed somewhere.

Also, I see popups occasionally saying something like "response too long. See console" But the console doesn't show it.

pluuuk commented 4 years ago

@markwinger , do the macros work when you run octoprint? I'm not familiar with the macro syntax, but why do you specify "reset_temp" and "resume" are those variables you have defined?

markwinger commented 4 years ago

Yes, the macros work in octoprint. As the macros are current setup, I have a macro call PAUSE_PRINT, which is called by the filament runout code. It is named this way so when I press the "Pause" in dwc2, it will be called. The macro contains a call to another macro called my_temps. That macro gets the current hotend target temp and stores in it in a macro variable called nozzle_temp, sets the hotend temp to 0, then sets the idle_timeout very long(so the hotbed does not get turned of an loose adhesion). After return from my_temps, the PAUSE_PRINT does retraction, and moves the print head to 0,0. Klipper then pauses.

Then I have RESUME_PRINT which is called by a menu selection. Also because of the name it is called by dwc2 when the "Resume" button is clicked. This macro calls macro reset_temps, which simply sends an M109 with the nozzle target temp saved by my_temps. The M109 is supposed to pause until target temp is reached. When reset_temps returns to RESUME_PRINT, the idle_timeout is set back to 600 and resume is called telling klipper to resume.

The M109 not causing the print to wait, but another macro to pause is where my problem seems to be originating.

markwinger commented 4 years ago

One more issue I noticed. After this testing I end up with the job done/cancelled/??? but the bed and nozzle heaters are still on. So I tried going to tools->control-all-> everything off. I get an error:

G10 P0 R-273.15 S-273.15 M140 P0 S-273.15 Error: Requested temperature (-273.1) out of range (0.0:265.0) Error: Requested temperature (-273.1) out of range (0.0:130.0)

Wow, absolute 0. That's cool. Cooler that the climate here in Minnesota. But if I set the temps to 0, it works correctly.

changedsoul commented 4 years ago

I must be missing something. I cannot get this to work for the life of me. There seems to be multiple commands that claim to work and nothing works for me. The only thing that gets me close is from here: https://klipper.info/klipper-+-dwc2-1/installing-dwc2 Yet I still get the "try_load_module" error. I found the suggestion to rename that in one of the previous posts, and this got me to see the web interface, yet I was still unable to connect. When I perform a "FIRMWARE_RESTART" I get the following error: Error: 'dict' object has no attribute 'get_commandline'

Any idea whats wrong? This is all that is in /tmp/klipper.log after I issue the command:

"FIRMWARE_RESTART
DWC2:24782.43 - 10.0.0.44 - GET - /rr_gcode?gcode=FIRMWARE_RESTART
FIRMWARE_RESTART
failed: FIRMWARE_RESTART'dict' object has no attribute 'get_commandline'
"
markwinger commented 4 years ago

I think I know what my main problem is. When you click the resume button, the printer is resumed then the macro is run. In octoprint, the macro is run first. So I tried creating resume.g macro, and renamed the macro RESUME_PRINT to MY_RESUME_PRINT so dwc2 does not run it. I then created a dwc2 macro called my_resume_print, and ran it directly with out clicking the resume button.

The macro runs properly, but dwc2 continues to stay paused. Temp goes up correctly, idle_timeout get set when temp hits target, but dwc2 does not resume. Clipper however is in a different state. The logs show: DWC2:68106.65 - 192.168.1.118 - GET - /rr_config passed: RESET_TEMP idle_timeout: Timeout set to 600.00 s passed: SET_IDLE_TIMEOUT Print is not paused, resume aborted passed: RESUME

So my macro worked, klipper is ready to go, but dwc2 is not resumed.

So I have 2 problems, and they may not be solvable 1-dwc2 appears to run the macro after resuming print. So I cannot use the resume button. 2-resume in a macro only resumes klipper and dwc2 does not seem to know we have resumed. So unless we have a way to tell dwc2 to resume from a macro, this may just be impossible.

markwinger commented 4 years ago

I'm switching back to octoprint now. The number of issues I've seen is way too high right now, and I have barely even used it. I'll be happy to test fixes for you but for now, using dwc2 for everyday printing is just not worth it.

Stephan3 commented 4 years ago

TLDR -> fixed