From e876b2023cdbb5ff4e05bdf997404038ebfb8126 Mon Sep 17 00:00:00 2001 From: M1nd3r Date: Tue, 12 Mar 2024 11:53:16 +0100 Subject: [PATCH] Fix awaits and debug output --- core/src/trezor/wire/__init__.py | 6 +++--- core/src/trezor/wire/context.py | 6 +++--- core/src/trezor/wire/thp_v1.py | 4 ++-- 3 files changed, 8 insertions(+), 8 deletions(-) diff --git a/core/src/trezor/wire/__init__.py b/core/src/trezor/wire/__init__.py index 2f5edb05f..6b1cbcd22 100644 --- a/core/src/trezor/wire/__init__.py +++ b/core/src/trezor/wire/__init__.py @@ -116,7 +116,7 @@ async def _handle_single_message( __name__, "%s:%x receive: <%s>", ctx.iface.iface_num(), - ctx.session_id, + int.from_bytes(ctx.session_id, "big"), msg_type, ) @@ -232,8 +232,8 @@ async def handle_session( msg = next_msg next_msg = None - # Set ctx.session_id to the value msg.session_id - ctx.session_id = msg.session_id + # Set ctx.session_id to the value msg.session_id + ctx.session_id = msg.session_id try: next_msg = await _handle_single_message( diff --git a/core/src/trezor/wire/context.py b/core/src/trezor/wire/context.py index 94fa415c9..b6603be73 100644 --- a/core/src/trezor/wire/context.py +++ b/core/src/trezor/wire/context.py @@ -103,7 +103,7 @@ class Context: __name__, "%s:%x expect: %s", self.iface.iface_num(), - self.session_id, + int.from_bytes(self.session_id, "big"), expected_type.MESSAGE_NAME if expected_type else expected_types, ) @@ -126,7 +126,7 @@ class Context: __name__, "%s:%x read: %s", self.iface.iface_num(), - self.session_id, + int.from_bytes(self.session_id, "big"), expected_type.MESSAGE_NAME, ) @@ -142,7 +142,7 @@ class Context: __name__, "%s:%x write: %s", self.iface.iface_num(), - self.session_id, + int.from_bytes(self.session_id, "big"), msg.MESSAGE_NAME, ) diff --git a/core/src/trezor/wire/thp_v1.py b/core/src/trezor/wire/thp_v1.py index 7085330b6..ddb479edd 100644 --- a/core/src/trezor/wire/thp_v1.py +++ b/core/src/trezor/wire/thp_v1.py @@ -159,7 +159,7 @@ async def read_message_or_init_packet( continue # 3: Send ACK in response - _sendAck(iface, cid, sync_bit) # TODO await + await _sendAck(iface, cid, sync_bit) THP.sync_set_receive_expected_bit(session, 1 - sync_bit) return await _handle_allocated(ctrl_byte, session, payload) @@ -307,7 +307,7 @@ async def _handle_broadcast(iface: WireInterface, ctrl_byte, report) -> Message ) checksum = _compute_checksum_bytes(response_header.to_bytes() + response_data) - write_to_wire(iface, response_header, response_data + checksum) # TODO await + await write_to_wire(iface, response_header, response_data + checksum) async def _handle_allocated(ctrl_byte, session: SessionThpCache, payload) -> Message: