From 81da5379d406236b8284921d34f23e877464db63 Mon Sep 17 00:00:00 2001 From: Kevin O'Connor Date: Thu, 4 Feb 2021 16:33:03 -0500 Subject: 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 --- scripts/buildcommands.py | 27 +++++++++++++++------------ 1 file changed, 15 insertions(+), 12 deletions(-) (limited to 'scripts/buildcommands.py') 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): -- cgit v1.2.3-70-g09d2