mirror of
https://github.com/trezor/trezor-firmware.git
synced 2024-12-23 06:48:16 +00:00
trezor.wire: print session ID as hex
This commit is contained in:
parent
d30e565cb3
commit
8bdd59642f
@ -39,14 +39,14 @@ def setup(iface):
|
||||
|
||||
|
||||
async def read(session_id, *wire_types):
|
||||
log.info(__name__, 'session %d: read types %s', session_id, wire_types)
|
||||
log.info(__name__, 'session %x: read(%s)', session_id, wire_types)
|
||||
signal = loop.Signal()
|
||||
sessions.listen(session_id, _handle_response, wire_types, signal)
|
||||
return await signal
|
||||
|
||||
|
||||
async def write(session_id, pbuf_msg):
|
||||
log.info(__name__, 'session %d: write %s', session_id, pbuf_msg)
|
||||
log.info(__name__, 'session %x: write(%s)', session_id, pbuf_msg)
|
||||
pbuf_type = pbuf_msg.__class__
|
||||
msg_data = pbuf_type.dumps(pbuf_msg)
|
||||
msg_type = pbuf_type.MESSAGE_WIRE_TYPE
|
||||
@ -131,7 +131,8 @@ def _handle_workflow(session_id, msg_type, data_len):
|
||||
|
||||
def _handle_unexpected(session_id, msg_type, data_len):
|
||||
log.warning(
|
||||
__name__, 'session %d: skip type %d, len %d', session_id, msg_type, data_len)
|
||||
__name__, 'session %x: skip type %d, len %d', session_id, msg_type, data_len)
|
||||
|
||||
try:
|
||||
while True:
|
||||
yield
|
||||
|
@ -18,13 +18,13 @@ def generate():
|
||||
def open(session_id=None):
|
||||
if session_id is None:
|
||||
session_id = generate()
|
||||
log.info(__name__, 'session %d: open', session_id)
|
||||
log.info(__name__, 'session %x: open', session_id)
|
||||
opened.add(session_id)
|
||||
return session_id
|
||||
|
||||
|
||||
def close(session_id):
|
||||
log.info(__name__, 'session %d: close', session_id)
|
||||
log.info(__name__, 'session %x: close', session_id)
|
||||
opened.discard(session_id)
|
||||
readers.pop(session_id, None)
|
||||
|
||||
@ -38,10 +38,10 @@ def get_codec(session_id):
|
||||
|
||||
def listen(session_id, handler, *args):
|
||||
if session_id not in opened:
|
||||
raise KeyError('Session %d is unknown' % session_id)
|
||||
raise KeyError('Session %x is unknown' % session_id)
|
||||
if session_id in readers:
|
||||
raise KeyError('Session %d is already being listened on' % session_id)
|
||||
log.info(__name__, 'session %d: listening', session_id)
|
||||
raise KeyError('Session %x is already being listened on' % session_id)
|
||||
log.info(__name__, 'session %x: listening', session_id)
|
||||
decoder = get_codec(session_id).decode_stream(session_id, handler, *args)
|
||||
decoder.send(None)
|
||||
readers[session_id] = decoder
|
||||
@ -62,16 +62,16 @@ def dispatch(report, open_callback, close_callback, unknown_callback):
|
||||
open_callback()
|
||||
return
|
||||
elif marker == codec_v2.REP_MARKER_CLOSE:
|
||||
log.debug(__name__, 'request for closing session %d', session_id)
|
||||
log.debug(__name__, 'request for closing session %x', session_id)
|
||||
close_callback(session_id)
|
||||
return
|
||||
|
||||
if session_id not in readers:
|
||||
log.warning(__name__, 'report on unknown session %d', session_id)
|
||||
log.warning(__name__, 'report on unknown session %x', session_id)
|
||||
unknown_callback(session_id, report_data)
|
||||
return
|
||||
|
||||
log.debug(__name__, 'report on session %d', session_id)
|
||||
log.debug(__name__, 'report on session %x', session_id)
|
||||
reader = readers[session_id]
|
||||
|
||||
try:
|
||||
|
Loading…
Reference in New Issue
Block a user