diff options
author | Kevin O'Connor <kevin@koconnor.net> | 2021-02-04 16:33:03 -0500 |
---|---|---|
committer | Kevin O'Connor <kevin@koconnor.net> | 2021-02-18 15:21:32 -0500 |
commit | 81da5379d406236b8284921d34f23e877464db63 (patch) | |
tree | 5d48ff2fa546f1693f943faaa89fe61b9e829e76 /scripts/buildcommands.py | |
parent | efa497dfd86bc64b3f9b991f6fc1a10ff23f7596 (diff) | |
download | kutter-81da5379d406236b8284921d34f23e877464db63.tar.gz kutter-81da5379d406236b8284921d34f23e877464db63.tar.xz kutter-81da5379d406236b8284921d34f23e877464db63.zip |
buildcommands: Extend number of available mcu messages from 96 to 128
Some internal code treats the message ids as encoded "variable length
quantities", while other internal code assumes the message id is
always one byte long. Continue using this scheme, but convert the VLQ
users to use the name "msgtag" while the 1-byte users use "msgid".
Increase the number of available msgids from 96 to 127 - the higher
values get encoded as negative "msgtags".
Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
Diffstat (limited to 'scripts/buildcommands.py')
-rw-r--r-- | scripts/buildcommands.py | 27 |
1 files changed, 15 insertions, 12 deletions
diff --git a/scripts/buildcommands.py b/scripts/buildcommands.py index 9e811485..d41cab0f 100644 --- a/scripts/buildcommands.py +++ b/scripts/buildcommands.py @@ -286,22 +286,25 @@ class HandleCommandGeneration: if msg not in self.msg_to_id: msgid += 1 self.msg_to_id[msg] = msgid - if msgid >= 96: + if msgid >= 128: # The mcu currently assumes all message ids encode to one byte error("Too many message ids") def update_data_dictionary(self, data): - command_ids = [self.msg_to_id[msg] - for msgname, msg in self.messages_by_name.items() - if msgname in self.commands] - response_ids = [self.msg_to_id[msg] + # Handle message ids over 96 (they are decoded as negative numbers) + msg_to_tag = {msg: msgid if msgid < 96 else msgid - 128 + for msg, msgid in self.msg_to_id.items()} + command_tags = [msg_to_tag[msg] for msgname, msg in self.messages_by_name.items() - if msgname not in self.commands] - data['commands'] = { msg: msgid for msg, msgid in self.msg_to_id.items() - if msgid in command_ids } - data['responses'] = {msg: msgid for msg, msgid in self.msg_to_id.items() - if msgid in response_ids } - output = { msg: msgid for msg, msgid in self.msg_to_id.items() - if msgid not in command_ids and msgid not in response_ids } + if msgname in self.commands] + response_tags = [msg_to_tag[msg] + for msgname, msg in self.messages_by_name.items() + if msgname not in self.commands] + data['commands'] = { msg: msgtag for msg, msgtag in msg_to_tag.items() + if msgtag in command_tags } + data['responses'] = { msg: msgtag for msg, msgtag in msg_to_tag.items() + if msgtag in response_tags } + output = {msg: msgtag for msg, msgtag in msg_to_tag.items() + if msgtag not in command_tags and msgtag not in response_tags} if output: data['output'] = output def build_parser(self, msgid, msgformat, msgtype): |