Klipper Palette2s - Unhandled exception

Basic Information:

Printer Model: CR10S
MCU / Printerboard: Stock
Host / SBC: Raspberry Pi 4

Fill out above information and in all cases attach your klippy.log file (use zip to compress it, if too big). Pasting your printer.cfg is not needed
Be sure to check our “Knowledge Base” Category first. Most relevant items, e.g. error messages, are covered there

Describe your issue:

I have sliced a print using the the Mosaic Canvas3d.io slicer - as PrusaSlicer with p2pp will halt my palette when print begins (It will not procide filament when pulled from the buffer).

During the print (after ~1hour) an exception occurs and klipper occurs:

Sending current ping info O31 D46beead2
Unhandled exception during run
Traceback (most recent call last):
  File "/home/pi/klipper/klippy/klippy.py", line 217, in run
  File "/home/pi/klipper/klippy/reactor.py", line 292, in run
  File "/home/pi/klipper/klippy/reactor.py", line 340, in _dispatch_loop
    timeout = self._check_timers(eventtime, busy)
  File "/home/pi/klipper/klippy/reactor.py", line 158, in _check_timers
    t.waketime = waketime = t.callback(eventtime)
  File "/home/pi/klipper/klippy/extras/palette2.py", line 578, in _run_Read
  File "/home/pi/klipper/klippy/extras/palette2.py", line 519, in p2cmd
  File "/home/pi/klipper/klippy/extras/palette2.py", line 382, in p2cmd_O34
    percent = float(params[1][1:])
ValueError: invalid literal for float(): 0.-1
Transition to shutdown state: Unhandled exception during run

klippy.log.shutdown02831.zip (4.8 MB)

Well, Looking at the palette2 code (and is obvious by your error), the python code tried to convert a .-1 to a floating point value.

I don’t know enough about the Palette2 to know why or how it gave a .-1 value as a return, as .-1 isn’t a number.

You might have some error lurking in your Palette2, but again, I don’t know enough about that to comment.

What I can do is…

palette2.zip (5.5 KB)

Drop that files into your ~/klipper/klippy/extras folder and replace the existing palette2.py.

I added a conversion check to make sure the value in the param is a legit float, if not it’ll make it a “NaN” as a default value.

Hopefully that more gracefully deals with it and doesn’t just die on you. I added right above that a new logging output to say when the an invalid parameter was fed into that p2cmd so maybe later we can see if it happens a lot.

Hi @TheFuzzyGiggler

Are you the maintainer of the palette2s module?

I am just a user of klipper and palette2s. I have followed the documentation and it has been working for a long time.

Lately (after updating klipper etc), I have experienced these crashes during print.

To me it looks like the palette2s module are not correctly parsing/handling the Omega code O31 response. To my understanding, this is a ping - correct?

I have had some issues with my palette2s, but it turned out some compatibility problems with p2pp and prusaslicer. It would somehow overload/crash the palette during filament loading.
Switching back to canvas3d.io fixed the problem - for now at least.

I will test your fix and see if it helps.

I am not, The signature on the palette2 module is:

Clifford Roche clifford.roche@gmail.com

He wrote it in 2021, not sure if he’s still active or actively maintains it.

As for my fix, I simply tried to handle the error more gracefully than what happened above. I did a cursory Google on how the palette2 works but it has a lot going on behind the scenes and I don’t have one to test with so that killed my chances of trying to go any further.