From 310b6c52173fe8508b4e7836f5b587cc32d0644d Mon Sep 17 00:00:00 2001 From: matejcik Date: Thu, 10 Feb 2022 11:19:59 +0100 Subject: [PATCH] fix(legacy): support Success and Failure for debuglink --- common/protob/messages.proto | 4 ++-- legacy/firmware/protob/messages_map.py | 13 ++++++------- 2 files changed, 8 insertions(+), 9 deletions(-) diff --git a/common/protob/messages.proto b/common/protob/messages.proto index 0c9d9914a0..d8d4583a01 100644 --- a/common/protob/messages.proto +++ b/common/protob/messages.proto @@ -79,8 +79,8 @@ enum MessageType { // Management MessageType_Initialize = 0 [(bitcoin_only) = true, (wire_in) = true, (wire_tiny) = true]; MessageType_Ping = 1 [(bitcoin_only) = true, (wire_in) = true]; - MessageType_Success = 2 [(bitcoin_only) = true, (wire_out) = true]; - MessageType_Failure = 3 [(bitcoin_only) = true, (wire_out) = true]; + MessageType_Success = 2 [(bitcoin_only) = true, (wire_out) = true, (wire_debug_out) = true]; + MessageType_Failure = 3 [(bitcoin_only) = true, (wire_out) = true, (wire_debug_out) = true]; MessageType_ChangePin = 4 [(bitcoin_only) = true, (wire_in) = true]; MessageType_WipeDevice = 5 [(bitcoin_only) = true, (wire_in) = true]; MessageType_GetEntropy = 9 [(bitcoin_only) = true, (wire_in) = true]; diff --git a/legacy/firmware/protob/messages_map.py b/legacy/firmware/protob/messages_map.py index f901d3492b..a3bac8b356 100755 --- a/legacy/firmware/protob/messages_map.py +++ b/legacy/firmware/protob/messages_map.py @@ -36,17 +36,16 @@ IFACE_DIR_PAIRS = { SPECIAL_DEBUG_MESSAGES = {"MessageType_LoadDevice"} -def get_wire_extension(message): +def get_wire_extensions(message): extensions = message.GetOptions().Extensions - return next(ext for ext in IFACE_DIR_PAIRS if extensions[ext]) + return (ext for ext in IFACE_DIR_PAIRS if extensions[ext]) -def handle_message(fh, fl, skipped, message): +def handle_message(fh, fl, skipped, message, extension): name = message.name short_name = name.split("MessageType_", 1).pop() assert short_name != name - extension = get_wire_extension(message) interface, direction = IFACE_DIR_PAIRS[extension] for s in skipped: @@ -120,8 +119,8 @@ messages = defaultdict(list) for message in MessageType.DESCRIPTOR.values: if message.GetOptions().deprecated: continue - extension = get_wire_extension(message) - messages[extension].append(message) + for extension in get_wire_extensions(message): + messages[extension].append(message) for extension in (wire_in, wire_out, wire_debug_in, wire_debug_out): if extension == wire_debug_in: @@ -133,7 +132,7 @@ for extension in (wire_in, wire_out, wire_debug_in, wire_debug_out): for message in messages[extension]: if message.name in SPECIAL_DEBUG_MESSAGES: fh.write("#if DEBUG_LINK\n") - handle_message(fh, fl, skipped, message) + handle_message(fh, fl, skipped, message, extension) if message.name in SPECIAL_DEBUG_MESSAGES: fh.write("#endif\n")