diff options
author | Kevin O'Connor <kevin@koconnor.net> | 2017-03-12 22:43:05 -0400 |
---|---|---|
committer | Kevin O'Connor <kevin@koconnor.net> | 2017-03-13 00:38:17 -0400 |
commit | d21b9280f029f1c65d3dac9310eb00090dd8c531 (patch) | |
tree | cc3b34c2ecc0b277470dfe567a40b144cb7c3174 /klippy/mcu.py | |
parent | 92649332ce1f4ad7445f5e97ee6d24c79eccece9 (diff) | |
download | kutter-d21b9280f029f1c65d3dac9310eb00090dd8c531.tar.gz kutter-d21b9280f029f1c65d3dac9310eb00090dd8c531.tar.xz kutter-d21b9280f029f1c65d3dac9310eb00090dd8c531.zip |
klippy: Eliminate high-level build_config phase
Now that the mcu objects can be created prior to connecting to the
mcu, it is no longer necessary to separate the init and build_config
phases in the high-level code. Move the mcu objection creation from
the build_config phase to the init phase and eliminate the
build_config phase.
Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
Diffstat (limited to 'klippy/mcu.py')
-rw-r--r-- | klippy/mcu.py | 10 |
1 files changed, 5 insertions, 5 deletions
diff --git a/klippy/mcu.py b/klippy/mcu.py index a9dff680..b255a1f3 100644 --- a/klippy/mcu.py +++ b/klippy/mcu.py @@ -385,6 +385,7 @@ class MCU: self._config_crc = None self._init_callbacks = [] self._pin_map = config.get('pin_map', None) + self._custom = config.get('custom', '') # Move command queuing ffi_main, self.ffi_lib = chelper.get_ffi() self._max_stepper_error = config.getfloat('max_stepper_error', 0.000025) @@ -427,6 +428,8 @@ class MCU: self.register_msg(self.handle_shutdown, 'shutdown') self.register_msg(self.handle_shutdown, 'is_shutdown') self.register_msg(self.handle_mcu_stats, 'stats') + self._build_config() + self._send_config() def connect_file(self, debugoutput, dictionary, pace=False): self._is_fileoutput = True self.serial.connect_file(debugoutput, dictionary) @@ -468,8 +471,7 @@ class MCU: return self._is_fileoutput # Configuration phase def _add_custom(self): - data = self._config.get('custom', '') - for line in data.split('\n'): + for line in self._custom.split('\n'): line = line.strip() cpos = line.find('#') if cpos >= 0: @@ -477,7 +479,7 @@ class MCU: if not line: continue self.add_config_cmd(line) - def build_config(self): + def _build_config(self): # Build config commands for oid in self._oids: oid.build_config() @@ -501,8 +503,6 @@ class MCU: # Calculate config CRC self._config_crc = zlib.crc32('\n'.join(self._config_cmds)) & 0xffffffff self.add_config_cmd("finalize_config crc=%d" % (self._config_crc,)) - - self._send_config() def _send_config(self): msg = self.create_command("get_config") if self._is_fileoutput: |