Skip to content

Commit e994395

Browse files
claude fix for non critical mcu issue
1 parent f4c1141 commit e994395

1 file changed

Lines changed: 14 additions & 2 deletions

File tree

klippy/extras/temperature_mcu.py

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,8 @@ def setup_minmax(self, min_temp, max_temp):
5151
self.max_temp = max_temp
5252
# Internal code
5353
def adc_callback(self, read_time, read_value):
54+
if self.base_temperature is None or self.slope is None:
55+
return
5456
temp = self.base_temperature + read_value * self.slope
5557
self.temperature_callback(read_time + SAMPLE_COUNT * SAMPLE_TIME, temp)
5658
def calc_temp(self, adc):
@@ -65,8 +67,18 @@ def handle_mcu_identify(self):
6567
def _build_config(self):
6668
# Obtain mcu information
6769
mcu = self.mcu_adc.get_mcu()
68-
self.debug_read_cmd = mcu.lookup_query_command(
69-
"debug_read order=%c addr=%u", "debug_result val=%u")
70+
try:
71+
self.debug_read_cmd = mcu.lookup_query_command(
72+
"debug_read order=%c addr=%u", "debug_result val=%u")
73+
except Exception:
74+
if not getattr(mcu, 'is_non_critical', False):
75+
raise
76+
logging.warning(
77+
"temperature_mcu: MCU '%s' does not support 'debug_read'"
78+
" command, skipping MCU temperature configuration",
79+
mcu.get_name())
80+
self.mcu_adc.setup_adc_sample(SAMPLE_TIME, SAMPLE_COUNT)
81+
return
7082
self.mcu_type = mcu.get_constants().get("MCU", "")
7183
# Run MCU specific configuration
7284
cfg_funcs = [

0 commit comments

Comments
 (0)