Skip to content

Commit

Permalink
Include reset name in message repr() if recognized.
Browse files Browse the repository at this point in the history
  • Loading branch information
adamshapiro0 committed Oct 13, 2023
1 parent d3f5ea2 commit 9ea143b
Showing 1 changed file with 27 additions and 2 deletions.
29 changes: 27 additions & 2 deletions python/fusion_engine_client/messages/control.py
Original file line number Diff line number Diff line change
Expand Up @@ -345,11 +345,36 @@ def calcsize(cls) -> int:

def __repr__(self):
result = super().__repr__()[:-1]
result += f', mask=0x{self.reset_mask:08X}]'
mask_text = f'0x{self.reset_mask:08X}'
name = self._get_known_mask_name(self.reset_mask)
if name is not None:
mask_text += f' ({name})'
result += f', mask={mask_text}]'
return result

def __str__(self):
return 'Reset Request [mask=0x%08x]' % self.reset_mask
mask_text = f'0x{self.reset_mask:08X}'
name = self._get_known_mask_name(self.reset_mask)
if name is not None:
mask_text += f' ({name})'
return f'Reset Request [mask={mask_text}]'

@classmethod
def _get_known_mask_name(cls, mask) -> str:
if mask == cls.HOT_START:
return 'HOT_START'
elif mask == cls.WARM_START:
return 'WARM_START'
elif mask == cls.PVT_RESET:
return 'PVT_RESET'
elif mask == cls.COLD_START:
return 'COLD_START'
elif mask == cls.FACTORY_RESET:
return 'FACTORY_RESET'
elif mask & cls.DIAGNOSTIC_LOG_RESET:
return 'DIAGNOSTIC_LOG_RESET'
else:
return None


class VersionInfoMessage(MessagePayload):
Expand Down

0 comments on commit 9ea143b

Please sign in to comment.