Coverage for tropicsquare / config / uap_mcounter.py: 78%
41 statements
« prev ^ index » next coverage.py v7.13.5, created at 2026-03-27 21:24 +0000
« prev ^ index » next coverage.py v7.13.5, created at 2026-03-27 21:24 +0000
1"""UAP Monotonic Counter operation configuration classes"""
3from tropicsquare.config.uap_base import UapMultiSlotConfig, UapPermissionField
4from tropicsquare.config.constants import (
5 UAP_MCOUNTER_0_3_POS,
6 UAP_MCOUNTER_4_7_POS,
7 UAP_MCOUNTER_8_11_POS,
8 UAP_MCOUNTER_12_15_POS
9)
12class MCounterConfig(UapMultiSlotConfig):
13 """UAP Monotonic Counter base configuration."""
15 @property
16 def mcounter_0_3(self) -> UapPermissionField:
17 """Permission field for monotonic counters 0-3."""
18 return self._get_slot_field(UAP_MCOUNTER_0_3_POS)
20 @mcounter_0_3.setter
21 def mcounter_0_3(self, field: UapPermissionField) -> None:
22 self._set_slot_field(UAP_MCOUNTER_0_3_POS, field)
24 @property
25 def mcounter_4_7(self) -> UapPermissionField:
26 """Permission field for monotonic counters 4-7."""
27 return self._get_slot_field(UAP_MCOUNTER_4_7_POS)
29 @mcounter_4_7.setter
30 def mcounter_4_7(self, field: UapPermissionField) -> None:
31 self._set_slot_field(UAP_MCOUNTER_4_7_POS, field)
33 @property
34 def mcounter_8_11(self) -> UapPermissionField:
35 """Permission field for monotonic counters 8-11."""
36 return self._get_slot_field(UAP_MCOUNTER_8_11_POS)
38 @mcounter_8_11.setter
39 def mcounter_8_11(self, field: UapPermissionField) -> None:
40 self._set_slot_field(UAP_MCOUNTER_8_11_POS, field)
42 @property
43 def mcounter_12_15(self) -> UapPermissionField:
44 """Permission field for monotonic counters 12-15."""
45 return self._get_slot_field(UAP_MCOUNTER_12_15_POS)
47 @mcounter_12_15.setter
48 def mcounter_12_15(self, field: UapPermissionField) -> None:
49 self._set_slot_field(UAP_MCOUNTER_12_15_POS, field)
51 def to_dict(self) -> dict:
52 """Export fields as dictionary."""
53 return {
54 'mcounter_0_3': self.mcounter_0_3.to_dict(),
55 'mcounter_4_7': self.mcounter_4_7.to_dict(),
56 'mcounter_8_11': self.mcounter_8_11.to_dict(),
57 'mcounter_12_15': self.mcounter_12_15.to_dict()
58 }
60 def __str__(self) -> str:
61 """Table row with monotonic counter specific field names."""
62 s0 = str(self.mcounter_0_3)
63 s1 = str(self.mcounter_4_7)
64 s2 = str(self.mcounter_8_11)
65 s3 = str(self.mcounter_12_15)
66 return "{:26s} | {} || {} || {} || {} |".format(
67 self.__class__.__name__,
68 s0, s1, s2, s3
69 )
72class MCounterInitConfig(MCounterConfig):
73 """UAP Monotonic Counter Init configuration (CFG_UAP_MCOUNTER_INIT @ 0x150).
75 Controls which pairing key slots can initialize monotonic counters.
76 Has 4 permission fields for counter groups 0-3, 4-7, 8-11, 12-15.
77 """
79 pass
82class MCounterGetConfig(MCounterConfig):
83 """UAP Monotonic Counter Get configuration (CFG_UAP_MCOUNTER_GET @ 0x154).
85 Controls which pairing key slots can read monotonic counter values.
86 Has 4 permission fields for counter groups 0-3, 4-7, 8-11, 12-15.
87 """
89 pass
92class MCounterUpdateConfig(MCounterConfig):
93 """UAP Monotonic Counter Update configuration (CFG_UAP_MCOUNTER_UPDATE @ 0x158).
95 Controls which pairing key slots can update monotonic counters.
96 Has 4 permission fields for counter groups 0-3, 4-7, 8-11, 12-15.
97 """
99 pass