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

MMU Shutdown after updating to 3.1 #617

Open
florek41 opened this issue Feb 3, 2025 · 7 comments
Open

MMU Shutdown after updating to 3.1 #617

florek41 opened this issue Feb 3, 2025 · 7 comments
Labels
believe fixed / answered The bug is believed fixed in latest release

Comments

@florek41
Copy link

florek41 commented Feb 3, 2025

Hi, I have a problem after most recent update - 3.1
I'm gettin all sorts of errors
For example - during homing MMU I've got

Internal error on command:"MMU_HOME"

Internal Error on WebRequest: gcode/script
Traceback (most recent call last):
  File "/home/bartek/klipper/klippy/webhooks.py", line 256, in _process_request
    func(web_request)
  File "/home/bartek/klipper/klippy/webhooks.py", line 436, in _handle_script
    self.gcode.run_script(web_request.get_str('script'))
  File "/home/bartek/klipper/klippy/gcode.py", line 229, in run_script
    self._process_commands(script.split('\n'), need_ack=False)
  File "/home/bartek/klipper/klippy/gcode.py", line 211, in _process_commands
    handler(gcmd)
  File "/home/bartek/klipper/klippy/gcode.py", line 137, in <lambda>
    func = lambda params: origfunc(self._get_extended_params(params))
  File "/home/bartek/klipper/klippy/extras/mmu/mmu.py", line 6022, in cmd_MMU_HOME
    self.home(tool, force_unload=force_unload)
  File "/home/bartek/klipper/klippy/extras/mmu/mmu.py", line 5684, in home
    self.selector.home(force_unload=force_unload)
  File "/home/bartek/klipper/klippy/extras/mmu/mmu_selector.py", line 331, in home
    self.mmu.unload_sequence()
  File "/home/bartek/klipper/klippy/extras/mmu/mmu.py", line 4841, in unload_sequence
    self._unload_gate(homing_max=bowden_move) # Full slow unload
  File "/home/bartek/klipper/klippy/extras/mmu/mmu.py", line 4107, in _unload_gate
    success = self._reverse_home_to_encoder(homing_max)
  File "/home/bartek/klipper/klippy/extras/mmu/mmu.py", line 4135, in _reverse_home_to_encoder
    for i in range(max_steps):
TypeError: range() integer end argument expected, got float.
MCU 'mmu' shutdown: Command request

After restart I've got
Internal error on command:"__MMU_SENSOR_INSERT"
Internal error on command:"MMU_PRELOAD"

Internal error on command:"MMU_PRELOAD"
Traceback (most recent call last):
  File "/home/bartek/klipper/klippy/gcode.py", line 211, in _process_commands
    handler(gcmd)
  File "/home/bartek/klipper/klippy/gcode.py", line 137, in <lambda>
    func = lambda params: origfunc(self._get_extended_params(params))
  File "/home/bartek/klipper/klippy/extras/mmu/mmu.py", line 8082, in cmd_MMU_PRELOAD
    self._preload_gate()
  File "/home/bartek/klipper/klippy/extras/mmu/mmu.py", line 3976, in _preload_gate
    self._unload_gate()
  File "/home/bartek/klipper/klippy/extras/mmu/mmu.py", line 4107, in _unload_gate
    success = self._reverse_home_to_encoder(homing_max)
  File "/home/bartek/klipper/klippy/extras/mmu/mmu.py", line 4135, in _reverse_home_to_encoder
    for i in range(max_steps):
TypeError: range() integer end argument expected, got float.
Transition to shutdown state: Internal error on command:"MMU_PRELOAD"

and looks like it traces to the same place.
Any ideas?

klippy (19).log

@bombela
Copy link

bombela commented Feb 4, 2025

Same error here.

Internal error on command:"MMU_CALIBRATE_BOWDEN"
Traceback (most recent call last):
  File "/home/pi/klipper/klippy/gcode.py", line 212, in _process_commands
    handler(gcmd)
  File "/home/pi/klipper/klippy/gcode.py", line 140, in <lambda>
    func = lambda params: origfunc(self._get_extended_params(params))
  File "/home/pi/klipper/klippy/extras/mmu/mmu.py", line 2582, in cmd_MMU_CALIBRATE_BOWDEN
    length, clog = self._calibrate_bowden_length_auto(approx_bowden_length, extruder_homing_max, repeats)
  File "/home/pi/klipper/klippy/extras/mmu/mmu.py", line 2297, in _calibrate_bowden_length_auto
    self._unload_gate()
  File "/home/pi/klipper/klippy/extras/mmu/mmu.py", line 4107, in _unload_gate
    success = self._reverse_home_to_encoder(homing_max)
  File "/home/pi/klipper/klippy/extras/mmu/mmu.py", line 4135, in _reverse_home_to_encoder
    for i in range(max_steps):
TypeError: range() integer end argument expected, got float.
Transition to shutdown state: Internal error on command:"MMU_CALIBRATE_BOWDEN"

Happy Hare 395db13

@bombela
Copy link

bombela commented Feb 4, 2025

And after this, nothing works anymore.

Internal error on command:"MMU_HOME"
Once the underlying issue is corrected, use the
"FIRMWARE_RESTART" command to reset the firmware, reload the
config, and restart the host software.
Printer is shutdown

Internal error on command:"MMU_HOME"
Internal Error on WebRequest: gcode/script
Traceback (most recent call last):
  File "/home/pi/klipper/klippy/webhooks.py", line 256, in _process_request
    func(web_request)
  File "/home/pi/klipper/klippy/webhooks.py", line 436, in _handle_script
    self.gcode.run_script(web_request.get_str('script'))
  File "/home/pi/klipper/klippy/gcode.py", line 230, in run_script
    self._process_commands(script.split('\n'), need_ack=False)
  File "/home/pi/klipper/klippy/gcode.py", line 212, in _process_commands
    handler(gcmd)
  File "/home/pi/klipper/klippy/gcode.py", line 140, in <lambda>
    func = lambda params: origfunc(self._get_extended_params(params))
  File "/home/pi/klipper/klippy/extras/mmu/mmu.py", line 6022, in cmd_MMU_HOME
    self.home(tool, force_unload=force_unload)
  File "/home/pi/klipper/klippy/extras/mmu/mmu.py", line 5684, in home
    self.selector.home(force_unload=force_unload)
  File "/home/pi/klipper/klippy/extras/mmu/mmu_selector.py", line 331, in home
    self.mmu.unload_sequence()
  File "/home/pi/klipper/klippy/extras/mmu/mmu.py", line 4841, in unload_sequence
    self._unload_gate(homing_max=bowden_move) # Full slow unload
  File "/home/pi/klipper/klippy/extras/mmu/mmu.py", line 4107, in _unload_gate
    success = self._reverse_home_to_encoder(homing_max)
  File "/home/pi/klipper/klippy/extras/mmu/mmu.py", line 4135, in _reverse_home_to_encoder
    for i in range(max_steps):
TypeError: range() integer end argument expected, got float.

@bombela
Copy link

bombela commented Feb 4, 2025

Same error on the v3.1.0 tag. 4863e64 (tag: v3.1.0)

@moggieuk
Copy link
Owner

moggieuk commented Feb 4, 2025

This isn't a change in HH but something in the environment... Hmm. Did you upgrade OS / python?

@bombela
Copy link

bombela commented Feb 4, 2025

I am not sure exactly how I fixed it. Here is an account of what happened.

After getting TypeError: range() integer end argument expected, got float. various version of Happy Hare, I threw a fit, powered off the printer and walked away.

A day later, moonraker refuses to start, complaining about some syntax error. Which as far as I can tell was coming from klipper itself.

For some reason, klipper was running in a python2 env, while moonraker was running under its own python3 env. How comes it worked the day prior far enough to start moonraker/mainsail, but not anymore? No idea. I even double checked the systemd units, and they did not look different. Clearly something changed that the reboot reloaded.

I fully removed python2 from the whole machine as an extra precaution. And re-created a python3 env for klipper. Then I update Happy Hare to the latest main branch (some changes landed over night).

And everything is now working fine. Interestingly, Happy Hare also stopped complaining about a lack of completed calibration.

I still cannot explain how klipper managed to work under python2 one day and not the next. And why moonraker worked and then not anymore. But I must have had something loaded that a reboot cleared.

@moggieuk
Copy link
Owner

moggieuk commented Feb 4, 2025

100% sure this wan't a change in HH. Anyway, I've added a precaution to the code (and pushed an update). This will force an integer. FWIW the code is using:
math.ceil() to generate the number of movement. This is an integer! However (apparently) it is possible for some version's of Python 2 to return a float!!!! I suspect some other update caused python2 to misbehave. This would cause havoc with klipper too...

Final note: Python 2 is a dead language. I support it because Klipper does, but you really should upgrade to python 3.

@moggieuk moggieuk added the believe fixed / answered The bug is believed fixed in latest release label Feb 4, 2025
@bombela
Copy link

bombela commented Feb 4, 2025

Thank you for the details @moggieuk.

Back when I installed klipper with kiauth, it created a python2 venv. I used kiauth to handle the updates for me. Which apparently doesn't warn about python2 nor re-create a python3 env during updates.

I am still on the ERCFv1. And Happy Hare is handling it very well so far. Thank you for the fantastic work.

The original encoder is still working perfectly ;)

Load direction:   mean=605.00 stdev=0.00 min=605 max=605 range=0
Unload direction: mean=605.00 stdev=0.00 min=605 max=605 range=0

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
believe fixed / answered The bug is believed fixed in latest release
Projects
None yet
Development

No branches or pull requests

3 participants