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????

manu7irl commented 4 years ago

The problem is related to the big klipper commit that has been done a few days ago. It made some changes to the gcode.py file with that the change that Stephan has made in that file to make dwc2 working are not inline with the new file structure. We need to revert to an older commit and wait for Stephan to make the changes needed in order to get that fixed.

On Sat, May 9, 2020, 10:35 PM markwinger notifications@github.com wrote:

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????

— 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, or unsubscribe https://github.com/notifications/unsubscribe-auth/AAWT4RBEK3CRMZKZRFGAXQ3RQWV7JANCNFSM4M45TLGA .

markwinger commented 4 years ago

On github 2.1.7 it showed a duetwebcontrol-SD.zip so I tried that too. No difference.

Stephan3 commented 4 years ago

@manu7irl you pointed the Klipper commit allready. I have not the time doing much theese days.

manu7irl commented 4 years ago

I will try to make the changes needed to your sed commands. I will try to send a pr.

On Sat, May 9, 2020, 11:03 PM Stephan notifications@github.com wrote:

@manu7irl https://github.com/manu7irl you pointed the Klipper commit allready. I have not the time doing much theese days.

— 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-626228449, or unsubscribe https://github.com/notifications/unsubscribe-auth/AAWT4RHAWH6TTR7OMUGUCB3RQWZKJANCNFSM4M45TLGA .

markwinger commented 4 years ago

Octoprint works with klipper if I comment out the [web_dwc2] section.

BlackStump commented 4 years ago

If you are desperate to try something other then Octoprint you could try Mainsail It is alpha but seems to be quite functional, it has a DWC2 look about it.

pajak15 commented 4 years ago

I had the same issue today while doing a fresh install. Try changing at line 49 in the web_dwc2.py "try_load_module" with "load_object". As stated before there was a commit in klipper where they renamed try_load_module() to load_object().

pluuuk commented 4 years ago

a simple sed command to replace try_load_module with load_object works.

Szeker commented 4 years ago

@pluuuk: Are you on the latest Klipper? Simply replacing the "try_load..." to "load_object" seems not enough. "gcode.py" also has been modified in the latest version, so the original patch probably needs to be updated also.

pluuuk commented 4 years ago

@Szeker , I opened #75 with the fixes to get dwc2 working again.

markwinger commented 4 years ago

I am away now but i will try the fix tomorrow and update.

Get BlueMail for Androidhttp://www.bluemail.me/r?b=15860 On May 10, 2020, at 4:57 PM, pluuuk notifications@github.com<mailto:notifications@github.com> wrote:

@Szekerhttps://github.com/Szeker , I opened #74https://github.com/Stephan3/dwc2-for-klipper/pull/74 with the fixes to get dwc2 working again.

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHubhttps://github.com/Stephan3/dwc2-for-klipper/issues/73#issuecomment-626395825, or unsubscribehttps://github.com/notifications/unsubscribe-auth/ABNGCRC3W4USM3POAODZYG3RQ4PNVANCNFSM4M45TLGA.

markwinger commented 4 years ago

OK, one install says to use wget https://github.com/chrishamm/DuetWebControl/releases/download/2.1.6/DuetWebControl-SBC.zip. But this does not exist, I get 2020-05-11 06:55:38 ERROR 404: Not Found.

The other: wget https://github.com/chrishamm/DuetWebControl/releases/download/2.0.0-RC5/DuetWebControl.zip is well over a year old.

There are no SBC files after 2.1.4. What do you recommend?

manu7irl commented 4 years ago

wget https://github.com/chrishamm/DuetWebControl/releases/download/2.1.7/DuetWebControl-SD.zip

markwinger commented 4 years ago

OK, that was the last one I pulled. So just to clarify (I don't understand git) if I just repeat the install process these fixes will get installed?

markwinger commented 4 years ago

Ok, I tried again and installed using the method here: https://github.com/Stephan3/dwc2-for-klipper

Same problem. I modified klippy/extras/web_dwc2.py changing try_load_object to load_object. But the klipper logs show: File "/home/pi/klipper/klippy/extras/web_dwc2.py", line 49, in init self.stepper_enable = self.printer.try_load_module(config, "stepper_enable") This line is now at line 50. I assume I need to compile it but I don't know how. What should I do?

manu7irl commented 4 years ago

you need to clone @pluuuk folder instaed of Stephan because this work is not merged yet... git clone https://github.com/pluuuk/dwc2-for-klipper

markwinger commented 4 years ago

Ok, still no joy.

I used the instructions on the page you pointed to, substituting pluuuk for Stephan3 on the clode of dwc2-for-klipper.git. The install seems to work. Octoprint no longer complains about try_load_module, but when I open ip:4750, no gui. (Unable to connect)

manu7irl commented 4 years ago

Use my script and report there I got it patched, AFAIK, it should work now. https://github.com/manu7irl/klipper-dwc2-installer

On Tue, May 12, 2020, 1:00 AM markwinger notifications@github.com wrote:

Ok, still no joy.

I used the instructions on the page you pointed to, substituting pluuuk for Stephan3 on the clode of dwc2-for-klipper.git. The install seems to work. Octoprint no longer complains about try_load_module, but when I open ip:4750, no gui.

— 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-626988253, or unsubscribe https://github.com/notifications/unsubscribe-auth/AAWT4RGIS7APKBCHLFYBGTTRRBYOHANCNFSM4M45TLGA .

markwinger commented 4 years ago

I just tried to install dwc2 with it and it complains that the PrinterFarm direcoty does not exist. Do I need to unistall everything and install everything with you script to move it all to the PrinterFarm?

pluuuk commented 4 years ago

@markwinger, did you configure the virtual_sdcard and patched gcode.py using the sed commands?

pluuuk commented 4 years ago

@manu7irl, the dwc2-for-klipper repo is 7 months old. I'm not sure if @markwinger will be able to use your installer.

pluuuk commented 4 years ago

These are the ammended instructions to run the fork that fixes these issues:

sudo systemctl stop klipper
cd ~
mv klipper klipper_backup 
PYTHONDIR="${HOME}/klippy-env"
virtualenv ${PYTHONDIR}
${PYTHONDIR}/bin/pip install tornado==5.1.1

git clone https://github.com/KevinOConnor/klipper.git
git clone https://github.com/pluuuk/dwc2-for-klipper.git
ln -s ~/dwc2-for-klipper/web_dwc2.py ~/klipper/klippy/extras/web_dwc2.py

mkdir -p ~/sdcard/dwc2/web
mkdir -p ~/sdcard/sys
cd ~/sdcard/dwc2/web 
wget https://github.com/chrishamm/DuetWebControl/releases/download/2.1.6/DuetWebControl-SBC.zip
unzip *.zip && for f_ in $(find . | grep '.gz');do gunzip ${f_};done
sudo systemctl start klipper

You will still need to configure the virtual_sdcard as in the readme

markwinger commented 4 years ago

Yes: [virtual_sdcard] path: ~/.octoprint/uploads/

and yes gcode=$(sed 's/self.bytes_read = 0/self.bytes_read = 0\n self.respond_callbacks = []/g' klipper/klippy/gcode.py) gcode=$(echo "$gcode" | sed 's/# Response handling/def register_respond_callback(self, callback):\n self.respond_callbacks.append(callback)/') gcode=$(echo "$gcode" | sed 's/os.write(self.fd, msg+"\n")/os.write(self.fd, msg+"\n")\n for callback in self.respond_callbacks:\n callback(msg+"\n")/') echo "$gcode" > klipper/klippy/gcode.py

What about PrinterFarm directory? Do I have to uninstall klipper and resinstall it with your script? Klipper is installed and running with octoprint and I would like to keep it and add dwc2 so I can use either as I did when I tried it a few months ago. Can that be done with you installer.sh script?

pluuuk commented 4 years ago

@markwinger , please see my last comment, I changed some things in the fork to remove the need to run the sed commands to modify gcode.py. This should allow you to install this much easier. I'm not familiar with @manu7irl install scripts.

markwinger commented 4 years ago

This still fails: wget https://github.com/chrishamm/DuetWebControl/releases/download/2.1.6/DuetWebControl-SBC.zip

I changed it to 2.1.7/DuetWebControl-SD.zip.

Installed ok, but klipper fails to start again with a new error as shown in octoprints klipper console: Internal error during connect: GCodeParser instance has no attribute 'register_respond_callback'

pluuuk commented 4 years ago

make sure you're running a clean klipper install, it seems you're running a modified gcode.py

cd klipper
git checkout -- klippy/gcode.py

Should help you clean it up.

On Mon, May 11, 2020, 6:00 PM markwinger notifications@github.com wrote:

This still fails: wget https://github.com/chrishamm/DuetWebControl/releases/download/2.1.6/DuetWebControl-SBC.zip

I changed it to 2.1.7/DuetWebControl-SD.zip.

Installed ok, but klipper fails to start again with a new error as shown in octoprints klipper console: Internal error during connect: GCodeParser instance has no attribute 'register_respond_callback'

— 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-627045816, or unsubscribe https://github.com/notifications/unsubscribe-auth/AEMFV6EEOZXUIKFZGGYSO4LRRCNSVANCNFSM4M45TLGA .

markwinger commented 4 years ago

No change. So I deleted gcode.py, then did checkout again. Still no change.

pluuuk commented 4 years ago

Can you run this and see if you still see the issue?

  cd dwc2-for-klipper
  git checkout -- .
  git pull
markwinger commented 4 years ago

Now klipper starts but the dwc2 gui will not connect.

pluuuk commented 4 years ago

Can you attach to a gist a clean /tmp/klippy.log? Make sure to issue a RESTART or FIRMWARE_RESTART command first.

markwinger commented 4 years ago

Rebooted. Then attacked with octoprint, then tried to open dwc2 gui. klippy.log

pluuuk commented 4 years ago

It seems your SD card path is configured for octoprint and its not pointing to where you extracted duetwebcontrol.

This is the error: DWC2 failed to start, no webif found in /home/pi/.octoprint/uploads/dwc2/web

markwinger commented 4 years ago

Thanks. I had the path commented out and was using the one I had for octoprint. The gui starts now.

pluuuk commented 4 years ago

Thanks, let me know if you find issues. The fixes haven't been fully tested yet, I hope some more users get a chance to ensure it all works properly.

On Mon, May 11, 2020, 6:43 PM markwinger notifications@github.com wrote:

Thanks. I had the path commented out and was using the one I had for octoprint. The gui starts now.

— 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-627057953, or unsubscribe https://github.com/notifications/unsubscribe-auth/AEMFV6HUEKIRQ63DB2QZYBDRRCSUJANCNFSM4M45TLGA .

manu7irl commented 4 years ago

Yes: [virtual_sdcard] path: ~/.octoprint/uploads/

and yes gcode=$(sed 's/self.bytes_read = 0/self.bytes_read = 0\n self.respond_callbacks = []/g' klipper/klippy/gcode.py) gcode=$(echo "$gcode" | sed 's/# Response handling/def register_respond_callback(self, callback):\n self.respond_callbacks.append(callback)/') gcode=$(echo "$gcode" | sed 's/os.write(self.fd, msg+"\n")/os.write(self.fd, msg+"\n")\n for callback in self.respond_callbacks:\n callback(msg+"\n")/') echo "$gcode" > klipper/klippy/gcode.py

What about PrinterFarm directory? Do I have to uninstall klipper and resinstall it with your script? Klipper is installed and running with octoprint and I would like to keep it and add dwc2 so I can use either as I did when I tried it a few months ago. Can that be done with you installer.sh script?

Hi my script is for scratch install. Save your printer.cfg file. Uninstall the regular klipper and reinstall it with my script klipper and dwc2 will then be installed in a structured folder called PrinterFarm. And everything will be handle from there, in Octoprint nothing is needed to change but the virtual serial endpoint which will be /tmp/printer-0 and the printer.cfg file location will be at ~/PrinterFarm/KlipperFarm/printer-0/printer-0.cfg. If you uninstall command to remove the old init.d startup script tell me I will give you. For follow my readme to understand more about the changes.

markwinger commented 4 years ago

I did an overnight printer with it. The printer came out fine but there were many notifications on the screen and I can't get rid of them. They say: ok B27.1/0.0 TO 25.0/0.4 Not SD Printing ok

or SD Not Printing ok ok B26:26.0/0.0 to B26:0/0.0

These messages messages all show up on the klipper console in too with a lot of NOT SD printing ok messages. These messages seem to never stop. The print finished 5 or six hours ago but these popup messages seem to still be printing. There are so many the cover the right side of the screen top to bottom, covering other important info.

How do I stop them? Can I turn off these notification popups somehow, or filter all these constant status messages.

manu7irl commented 4 years ago

I am almost 10 hours printing without issue and no sdcard messages.

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

I did an overnight printer with it. The printer came out fine but there were many notifications on the screen and I can't get rid of them. They say: ok B27.1/0.0 TO 25.0/0.4 Not SD Printing ok

or SD Not Printing ok ok B26:26.0/0.0 to B26:0/0.0

These messages messages all show up on the klipper console in too with a lot of NOT SD printing ok messages. These messages seem to never stop. The print finished 5 or six hours ago but these popup messages seem to still be printing. There are so many the cover the right side of the screen top to bottom, covering other important info.

How do I stop them? Can I turn off these notification popups somehow, or filter all these constant status messages.

— 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-627375591, or unsubscribe https://github.com/notifications/unsubscribe-auth/AAWT4RD2ZD4XQSPX4BEEVRLRRFLH7ANCNFSM4M45TLGA .

markwinger commented 4 years ago

I also cannot run any macros from the dashboard/macros or the file management/macros. If I specify a macro in the file management/macros I get an error: M98 P"0:/macros/G29" SD card not printing ok.

I have a macro for pause and resume used for filament run out. They work when filament out or from the printer lcd control. But if I resume using my macro I get this error: 5/12/2020, 10:02:03 AM | M98 P"0:/macros/MY_RESUME"JSON.parse: unexpected non-whitespace character after JSON data at line 1 column 22 of the JSON data

markwinger commented 4 years ago

I also see a lot of messages: "response too long, see console" but I see nothing in the console about them.

markwinger commented 4 years ago

Is there a more appropriate place to report issues I see? There are many.

pluuuk commented 4 years ago

@markwinger, can you summarize all the issues you're seeing? I think this is the appropriate place to report issues. The ack system in gcode.py changed, so it's expected to see more messages than usual , but i haven't seen that many.

pluuuk commented 4 years ago

About the SDcard messages, it seems it's an issue with octoprint. Can you disable octoprint and test if the messages go away? https://github.com/OctoPrint/OctoPrint/issues/3258

pluuuk commented 4 years ago

I will take a look at the macro system and report back what i find.

markwinger commented 4 years ago

How do I disable octoprint?

pluuuk commented 4 years ago

It depends on your linux distro, but I'm guessing the commands down here should work.

sudo systemctl stop octoprint If you don't want it to start automatically: sudo systemctl disable octoprint You can re-enable it with: sudo systemctl enable octoprint

markwinger commented 4 years ago

That definitely stopped the endless streams of notification.

I know the macros dont work and I'll document here other things I find odd or not working.

manu7irl commented 4 years ago

You problably should start from scratch as I have no errors at all! I run 2 printers simultaneously. Everything is ok.

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

That definitely stopped the endless streams of notification.

I know the macros dont work and I'll document here other things I find odd or not working.

— 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-627470934, or unsubscribe https://github.com/notifications/unsubscribe-auth/AAWT4REELFPM7DOR5IXPY33RRF6M7ANCNFSM4M45TLGA .

pluuuk commented 4 years ago

@markwinger, to help with the macro issue, can you attach your macro?

markwinger commented 4 years ago

Below is the my_pause macro. The my_pause macro is called when out of filament and that works correctly. I can call it from the lcd control panel but fails if I try to execute it from dwc2. my_pause calls my_temps which I also included.

If I right click on the macro in the file management/Macro on any of the macros and click edit, I get an error: 0:/macros/MY_PAUSE

These macros are all in the printer.cfg file. Do I to move them out of the printer.cfg file or something?

[gcode_macro my_pause] gcode: ; relative XYZE my_temps G91 M83

 ; retract filament of 25 mm up, move Z slightly upwards and
 G1 Z+5 E-10 F1000
 G1 E-50 F1000

 ; absolute XYZE
 M82
 G90

 ; move to a safe rest position, adjust as necessary
 G1 X0 Y0
 M117 Filament out

[gcode_macro my_temps] variable_nozzle_temp: 0 gcode:

save nozzle temp

 SET_GCODE_VARIABLE MACRO=my_temps VARIABLE=nozzle_temp VALUE={printer.extruder.target}
 M104 S0 ; turn off hot end heater
 SET_IDLE_TIMEOUT timeout=20000
markwinger commented 4 years ago

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? (I'm doing a 12hr print right now or I would just try it)