Skip to content

is_non_critical MCU: QUERY_ENDSTOPS causes error shutdown #965

Description

@mk-maddin

The problem:

  • when a disconnected MCU provides an endstop pin QUERY_ENDSTOPS causes error shutdown

Steps to reproduce:

  • some MCU is defined as is_non_critical: true
  • the MCU has some endstop connect (can be some axis endstop, some probe, some happyhare filament endstop etc. - basically anything using the internal endstop object)
  • the MCU is disconnected
  • QUERY_ENDSTOPS command is executed via console or via mainsail web interface

The behavior:

  • Kalico error shutdown:
Image
  • following three errors can be found in klippy.log
Clock not yet synchronized, clock is untrustworthy
File "/home/pi/klipper/klippy/reactor.py", line 402, in _dispatch_loop
    timeout = self._check_timers(eventtime, busy)
File "/home/pi/klipper/klippy/reactor.py", line 193, in _check_timers
    t.waketime = waketime = t.callback(eventtime)
File "/home/pi/klipper/klippy/reactor.py", line 66, in invoke
    res = self.callback(eventtime)
File "/home/pi/klipper/klippy/webhooks.py", line 303, in <lambda>
    lambda e, s=self, wr=web_request: s._process_request(wr)
File "/home/pi/klipper/klippy/webhooks.py", line 309, in _process_request
    func(web_request)
File "/home/pi/klipper/klippy/webhooks.py", line 527, in _handle_script
    self.gcode.run_script(web_request.get_str("script"))
File "/home/pi/klipper/klippy/gcode.py", line 345, in run_script
    self._process_commands(script.split("\n"), need_ack=False)
File "/home/pi/klipper/klippy/gcode.py", line 318, in _process_commands
    handler(gcmd)
File "/home/pi/klipper/klippy/gcode.py", line 227, in func
    return origfunc(self._get_extended_params(params))
File "/home/pi/klipper/klippy/extras/query_endstops.py", line 54, in cmd_QUERY_ENDSTOPS
    (name, mcu_endstop.query_endstop(print_time))
File "/home/pi/klipper/klippy/mcu.py", line 478, in query_endstop
    clock = self._mcu.print_time_to_clock(print_time)
File "/home/pi/klipper/klippy/mcu.py", line 1375, in print_time_to_clock
    return self._clocksync.print_time_to_clock(print_time)
File "/home/pi/klipper/klippy/clocksync.py", line 248, in print_time_to_clock
    for line in traceback.format_stack():
Internal error on command:"QUERY_ENDSTOPS"
Traceback (most recent call last):
  File "/home/pi/klipper/klippy/gcode.py", line 318, in _process_commands
    handler(gcmd)
    ~~~~~~~^^^^^^
  File "/home/pi/klipper/klippy/gcode.py", line 227, in func
    return origfunc(self._get_extended_params(params))
  File "/home/pi/klipper/klippy/extras/query_endstops.py", line 54, in cmd_QUERY_ENDSTOPS
    (name, mcu_endstop.query_endstop(print_time))
           ~~~~~~~~~~~~~~~~~~~~~~~~~^^^^^^^^^^^^
  File "/home/pi/klipper/klippy/mcu.py", line 481, in query_endstop
    params = self._query_cmd.send([self._oid], minclock=clock)
             ^^^^^^^^^^^^^^^^^^^^
AttributeError: 'NoneType' object has no attribute 'send'
Transition to shutdown state: Internal error on command:"QUERY_ENDSTOPS"
Internal Error on WebRequest: gcode/script
Traceback (most recent call last):
  File "/home/pi/klipper/klippy/webhooks.py", line 309, in _process_request
    func(web_request)
    ~~~~^^^^^^^^^^^^^
  File "/home/pi/klipper/klippy/webhooks.py", line 527, in _handle_script
    self.gcode.run_script(web_request.get_str("script"))
    ~~~~~~~~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/pi/klipper/klippy/gcode.py", line 345, in run_script
    self._process_commands(script.split("\n"), need_ack=False)
    ~~~~~~~~~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/pi/klipper/klippy/gcode.py", line 318, in _process_commands
    handler(gcmd)
    ~~~~~~~^^^^^^
  File "/home/pi/klipper/klippy/gcode.py", line 227, in func
    return origfunc(self._get_extended_params(params))
  File "/home/pi/klipper/klippy/extras/query_endstops.py", line 54, in cmd_QUERY_ENDSTOPS
    (name, mcu_endstop.query_endstop(print_time))
           ~~~~~~~~~~~~~~~~~~~~~~~~~^^^^^^^^^^^^
  File "/home/pi/klipper/klippy/mcu.py", line 481, in query_endstop
    params = self._query_cmd.send([self._oid], minclock=clock)
             ^^^^^^^^^^^^^^^^^^^^
AttributeError: 'NoneType' object has no attribute 'send'
Internal error on command:"QUERY_ENDSTOPS"
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

Script running error
Traceback (most recent call last):
  File "/home/pi/klipper/klippy/extras/delayed_gcode.py", line 51, in _gcode_timer_event
    self.gcode.run_script(self.timer_gcode.render())
    ~~~~~~~~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/pi/klipper/klippy/gcode.py", line 345, in run_script
    self._process_commands(script.split("\n"), need_ack=False)
    ~~~~~~~~~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/pi/klipper/klippy/gcode.py", line 318, in _process_commands
    handler(gcmd)
    ~~~~~~~^^^^^^
  File "/home/pi/klipper/klippy/gcode.py", line 406, in cmd_default
    raise gcmd.error(self.printer.get_state_message()[0])
klippy.gcode.CommandError: Internal error on command:"QUERY_ENDSTOPS"
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

It might be possible that this is related to #900 - but I have not enough code insights to evaluate this

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions