diff options
author | Kevin O'Connor <kevin@koconnor.net> | 2018-01-29 10:16:42 -0500 |
---|---|---|
committer | Kevin O'Connor <kevin@koconnor.net> | 2018-01-29 10:25:25 -0500 |
commit | 077a56c2ca0315957efa8969221b850ed34c2cf7 (patch) | |
tree | d032ac838fab3ef1f72f110d7ab65ccfae423e88 | |
parent | a67306c76b0c0c2083f9e39e1186a7c3e0550744 (diff) | |
download | kutter-077a56c2ca0315957efa8969221b850ed34c2cf7.tar.gz kutter-077a56c2ca0315957efa8969221b850ed34c2cf7.tar.xz kutter-077a56c2ca0315957efa8969221b850ed34c2cf7.zip |
mcu: Default the restart method to 'command' on non-serial ports
If the mcu supports command restarts and it does not appear to use a
real serial port, then default the restart method to 'command'. This
is a better default on boards with native USB support.
Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
-rw-r--r-- | config/example.cfg | 5 | ||||
-rw-r--r-- | klippy/mcu.py | 10 |
2 files changed, 11 insertions, 4 deletions
diff --git a/config/example.cfg b/config/example.cfg index a7d6fd3d..bc71d46c 100644 --- a/config/example.cfg +++ b/config/example.cfg @@ -264,7 +264,7 @@ serial: /dev/ttyACM0 pin_map: arduino # This option may be used to enable Arduino pin name aliases. The # default is to not enable the aliases. -#restart_method: arduino +#restart_method: # This controls the mechanism the host will use to reset the # micro-controller. The choices are 'arduino', 'rpi_usb', and # 'command'. The 'arduino' method (toggle DTR) is common on Arduino @@ -273,7 +273,8 @@ pin_map: arduino # disables power to all USB ports to accomplish a micro-controller # reset. The 'command' method involves sending a Klipper command to # the micro-controller so that it can reset itself. The default is -# 'arduino'. +# 'arduino' if the micro-controller communicates over a serial port, +# 'command' otherwise. # The printer section controls high level printer settings. [printer] diff --git a/klippy/mcu.py b/klippy/mcu.py index 06da3ea6..d91e6314 100644 --- a/klippy/mcu.py +++ b/klippy/mcu.py @@ -428,9 +428,9 @@ class MCU: # Restarts self._restart_method = 'command' if baud: - rmethods = {m: m for m in ['arduino', 'command', 'rpi_usb']} + rmethods = {m: m for m in [None, 'arduino', 'command', 'rpi_usb']} self._restart_method = config.getchoice( - 'restart_method', rmethods, 'arduino') + 'restart_method', rmethods, None) self._reset_cmd = self._config_reset_cmd = None self._emergency_stop_cmd = None self._is_shutdown = self._is_timeout = False @@ -600,6 +600,12 @@ class MCU: self._emergency_stop_cmd = self.lookup_command("emergency_stop") self._reset_cmd = self.try_lookup_command("reset") self._config_reset_cmd = self.try_lookup_command("config_reset") + if (self._restart_method is None + and (self._reset_cmd is not None + or self.config_reset_cmd is not None) + and self._serial.msgparser.get_constant( + 'SERIAL_BAUD', None) is None): + self._restart_method = 'command' self.register_msg(self.handle_shutdown, 'shutdown') self.register_msg(self.handle_shutdown, 'is_shutdown') self.register_msg(self.handle_mcu_stats, 'stats') |