Index: scripts/MsgUtils/msgutils/MsgHandlingIni.py =================================================================== diff -u -r64243101dff61b5c1a40b96ef33080236999acf6 -rc6a4b63a37f3beb1e8a51702ec3a56a1c32cfe8f --- scripts/MsgUtils/msgutils/MsgHandlingIni.py (.../MsgHandlingIni.py) (revision 64243101dff61b5c1a40b96ef33080236999acf6) +++ scripts/MsgUtils/msgutils/MsgHandlingIni.py (.../MsgHandlingIni.py) (revision c6a4b63a37f3beb1e8a51702ec3a56a1c32cfe8f) @@ -13,8 +13,11 @@ # Call loadConf() to load message definitions, then loadIni() to merge in existing # action/topic values, then write_ini() to write the result. class MsgHandlingIni(MsgData): - DEFAULT_ACTION = 'drop' - VALID_ACTIONS = ('send_always', 'send_delta', 'drop') + DEFAULT_ACTION = 'Drop' + VALID_ACTIONS = ('SendAlways', 'SendDelta', 'Drop') + DEFAULT_TOPIC = 'NormalPriority' + VALID_TOPICS = ('HighPriority', 'NormalPriority', 'DeviceLogFile', + 'TreatmentLogFile', 'CloudSyncLogFile') # \brief Initializer def __init__(self): @@ -28,7 +31,7 @@ def loadConf(self, filename, clear=True): super().loadConf(filename, clear) for msg in self.data.values(): - msg['action'] = self.DEFAULT_ACTION + msg['action'] = '' msg['topic'] = '' @@ -55,21 +58,27 @@ print(f"WARNING: could not convert section message ID {section} to valid message ID, skipping") continue if msg_id_value not in self.data.keys(): - action = cfg.get(section, 'action', fallback=self.DEFAULT_ACTION).strip() + action = cfg.get(section, 'action', fallback='').strip() topic = cfg.get(section, 'topic', fallback='').strip() - if action != self.DEFAULT_ACTION or topic: + if action or topic: print(f"WARNING: {MsgData.value_to_hex_string(msg_id_value)} no longer in Unhandled.conf, " - f"dropping section with action={action} topic={topic or ''}") + f"dropping section with action={action or ''} topic={topic or ''}") continue - action = cfg.get(section, 'action', fallback=self.DEFAULT_ACTION).strip() - if action not in self.VALID_ACTIONS: + action = cfg.get(section, 'action', fallback='').strip() + if len(action) and action not in self.VALID_ACTIONS: print(f"WARNING: {MsgData.value_to_hex_string(msg_id_value)} has invalid action \"{action}\", " f"resetting to {self.DEFAULT_ACTION}") - action = self.DEFAULT_ACTION + action = '' + topic = cfg.get(section, 'topic', fallback='').strip() + if len(topic) and topic not in self.VALID_TOPICS: + print(f"WARNING: {MsgData.value_to_hex_string(msg_id_value)} has invalid topic \"{topic}\", " + f"resetting to {self.DEFAULT_TOPIC}") + topic = '' + self.data[msg_id_value]['action'] = action - self.data[msg_id_value]['topic'] = cfg.get(section, 'topic', fallback='').strip() + self.data[msg_id_value]['topic'] = topic # \brief Write the loaded message data to the INI file.