diff options
author | Kevin O'Connor <kevin@koconnor.net> | 2017-07-02 14:11:10 -0400 |
---|---|---|
committer | Kevin O'Connor <kevin@koconnor.net> | 2017-07-02 14:11:10 -0400 |
commit | 0ac518040b42396ba509e02aa3e8c4866fac63d8 (patch) | |
tree | 4dbbdbe3022062417b579f0f2268780292d29caa /klippy/msgproto.py | |
parent | 067fac05a865ee2eccab02637ca82ee3f0b3705b (diff) | |
download | kutter-0ac518040b42396ba509e02aa3e8c4866fac63d8.tar.gz kutter-0ac518040b42396ba509e02aa3e8c4866fac63d8.tar.xz kutter-0ac518040b42396ba509e02aa3e8c4866fac63d8.zip |
msgproto: Export static_strings from mcu to host as a dictionary
Export the static strings as a dictionary instead of as a list.
Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
Diffstat (limited to 'klippy/msgproto.py')
-rw-r--r-- | klippy/msgproto.py | 7 |
1 files changed, 4 insertions, 3 deletions
diff --git a/klippy/msgproto.py b/klippy/msgproto.py index df7b6717..9f8082cb 100644 --- a/klippy/msgproto.py +++ b/klippy/msgproto.py @@ -185,7 +185,7 @@ class MessageParser: self.unknown = UnknownFormat() self.messages_by_id = {} self.messages_by_name = {} - self.static_strings = [] + self.static_strings = {} self.config = {} self.version = "" self.raw_identify_data = "" @@ -240,7 +240,7 @@ class MessageParser: params['#name'] = mid.name static_string_id = params.get('static_string_id') if static_string_id is not None: - params['#msg'] = self.static_strings[static_string_id] + params['#msg'] = self.static_strings.get(static_string_id, "?") return params def encode(self, seq, cmd): msglen = MESSAGE_MIN + len(cmd) @@ -311,7 +311,8 @@ class MessageParser: commands = data.get('commands') responses = data.get('responses') self._init_messages(messages, commands+responses) - self.static_strings = data.get('static_strings', []) + static_strings = data.get('static_strings', {}) + self.static_strings = { int(k): v for k, v in static_strings.items() } self.config.update(data.get('config', {})) self.version = data.get('version', '') def get_constant(self, name): |