Skip to content
This repository was archived by the owner on Nov 23, 2025. It is now read-only.

Commit cadb228

Browse files
committed
Including the TX packet in the RX response.
This allows us more freedom to build higher level decoding functions.
1 parent dc93048 commit cadb228

3 files changed

Lines changed: 25 additions & 20 deletions

File tree

CHANGES.rst

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,8 @@ Version 0.5.0
2828
packet rather than all of these needing to build the packet internally.
2929
* Shifted NPC based functionality into an explict class that bundles this.
3030
``abstractions.NPCPacket``
31+
* Including the TX packet in the RX response.
32+
This allows us more freedom to build higher level decoding functions.
3133

3234
Version 0.4.0
3335
-------------

uoshardware/abstractions.py

Lines changed: 21 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -77,26 +77,6 @@ def get_from_address(address: int) -> UOSFunction | None:
7777
return None # function not found.
7878

7979

80-
@dataclass
81-
class ComResult:
82-
"""Containing the data structure used to capture UOS results."""
83-
84-
status: bool
85-
exception: str = ""
86-
ack_packet: list = field(default_factory=list)
87-
rx_packets: list = field(default_factory=list)
88-
89-
90-
@dataclass
91-
class InstructionArguments:
92-
"""Containing the data structure used to generalise UOS arguments."""
93-
94-
payload: tuple = ()
95-
expected_rx_packets: int = 1
96-
check_pin: int | None = None
97-
volatility: Persistence = Persistence.NONE
98-
99-
10080
@dataclass(init=False)
10181
class NPCPacket:
10282
"""Class contains functions and data for the packet based communication."""
@@ -163,6 +143,27 @@ def expects_rx_packets(self) -> list[int]:
163143
)
164144

165145

146+
@dataclass
147+
class ComResult:
148+
"""Containing the data structure used to capture UOS results."""
149+
150+
status: bool
151+
exception: str = ""
152+
ack_packet: list = field(default_factory=list)
153+
rx_packets: list = field(default_factory=list)
154+
tx_packet: NPCPacket | None = None
155+
156+
157+
@dataclass
158+
class InstructionArguments:
159+
"""Containing the data structure used to generalise UOS arguments."""
160+
161+
payload: tuple = ()
162+
expected_rx_packets: int = 1
163+
check_pin: int | None = None
164+
volatility: Persistence = Persistence.NONE
165+
166+
166167
class UOSInterface(metaclass=ABCMeta):
167168
"""Base class for low level UOS interfaces classes to inherit."""
168169

uoshardware/api.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -293,6 +293,8 @@ def __execute_instruction(
293293
rx_response.status = rx_response.status & (
294294
computed_checksum == current_packet[-2]
295295
)
296+
# include the tx packet for convenience
297+
rx_response.tx_packet = packet
296298
else: # run a special action
297299
rx_response = getattr(self.__device_interface, function.name)()
298300
finally: # Safety check for lazy loading being used outside of context manager

0 commit comments

Comments
 (0)