From 9359dfe423da115bf7a6132b0b093c05637d6486 Mon Sep 17 00:00:00 2001 From: Jordan Yates Date: Mon, 20 Apr 2026 13:36:03 +1000 Subject: [PATCH 1/3] tools: rpc: timeouts from RPC wrapper Allow RPC wrappers to overwrite the default 10 seconds timeout. Signed-off-by: Jordan Yates --- src/infuse_iot/commands.py | 4 ++++ src/infuse_iot/tools/rpc.py | 1 + 2 files changed, 5 insertions(+) diff --git a/src/infuse_iot/commands.py b/src/infuse_iot/commands.py index c41557f..0704a33 100644 --- a/src/infuse_iot/commands.py +++ b/src/infuse_iot/commands.py @@ -60,6 +60,10 @@ def auth_level(self) -> Auth: """Authentication level to run command with""" return Auth.DEVICE + def command_timeout_ms(self) -> int: + """Duration to wait for the RPC response in milliseconds""" + return 10000 + def request_struct(self) -> ctypes.LittleEndianStructure | bytes: """RPC_CMD request structure""" raise NotImplementedError diff --git a/src/infuse_iot/tools/rpc.py b/src/infuse_iot/tools/rpc.py index a2b52b1..8b08a33 100644 --- a/src/infuse_iot/tools/rpc.py +++ b/src/infuse_iot/tools/rpc.py @@ -85,6 +85,7 @@ def run(self): with self._client.connection(self._id, types, self._args.conn_timeout) as mtu: self._max_payload = mtu rpc_client = RpcClient(self._client, mtu, self._id, self.rx_handler) + rpc_client.set_timeout(self._command.command_timeout_ms()) params = bytes(self._command.request_struct()) if hasattr(self._command.response, "vla_from_buffer_copy"): # type: ignore From de3bc6d1df5908cf697913dc3ad2460682eda4fd Mon Sep 17 00:00:00 2001 From: Jordan Yates Date: Mon, 20 Apr 2026 13:38:41 +1000 Subject: [PATCH 2/3] rpc_wrappers: data_logger_erase: longer timeout Make the `data_logger_erase` command have a longer, configurable, RPC timeout. Signed-off-by: Jordan Yates --- src/infuse_iot/rpc_wrappers/data_logger_erase.py | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/infuse_iot/rpc_wrappers/data_logger_erase.py b/src/infuse_iot/rpc_wrappers/data_logger_erase.py index c9e4a79..7da0384 100644 --- a/src/infuse_iot/rpc_wrappers/data_logger_erase.py +++ b/src/infuse_iot/rpc_wrappers/data_logger_erase.py @@ -16,9 +16,12 @@ def add_parser(cls, parser): action="store_true", help="Erase entire address space, not just written blocks", ) + # Erasing a complete flash chip can take a long time + parser.add_argument("--timeout", type=int, default=60000, help="Duration to wait for erase to complete") def __init__(self, args): self.infuse_id = args.id + self.timeout = args.timeout if args.onboard: self.logger = defs.rpc_enum_data_logger.FLASH_ONBOARD elif args.removable: @@ -27,6 +30,9 @@ def __init__(self, args): raise NotImplementedError self.erase_all = 1 if args.erase_all else 0 + def command_timeout_ms(self) -> int: + return self.timeout + def request_struct(self): return self.request(self.logger, self.erase_all) From 3df61985aeb4e53b0b33ed0a69de0ef731942626 Mon Sep 17 00:00:00 2001 From: Jordan Yates Date: Mon, 20 Apr 2026 13:39:12 +1000 Subject: [PATCH 3/3] rpc_wrappers: data_logger_erase: force erase option Support the force erase option recently added to the embedded implementation. Signed-off-by: Jordan Yates --- src/infuse_iot/rpc_wrappers/data_logger_erase.py | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/src/infuse_iot/rpc_wrappers/data_logger_erase.py b/src/infuse_iot/rpc_wrappers/data_logger_erase.py index 7da0384..1022c82 100644 --- a/src/infuse_iot/rpc_wrappers/data_logger_erase.py +++ b/src/infuse_iot/rpc_wrappers/data_logger_erase.py @@ -11,11 +11,17 @@ def add_parser(cls, parser): logger = parser.add_mutually_exclusive_group(required=True) logger.add_argument("--onboard", action="store_true", help="Onboard flash logger") logger.add_argument("--removable", action="store_true", help="Removable flash logger (SD)") - parser.add_argument( + erase_mode = parser.add_mutually_exclusive_group() + erase_mode.add_argument( "--erase-all", action="store_true", help="Erase entire address space, not just written blocks", ) + erase_mode.add_argument( + "--erase-force", + action="store_true", + help="Erase entire address space, even if logger init failed", + ) # Erasing a complete flash chip can take a long time parser.add_argument("--timeout", type=int, default=60000, help="Duration to wait for erase to complete") @@ -28,7 +34,7 @@ def __init__(self, args): self.logger = defs.rpc_enum_data_logger.FLASH_REMOVABLE else: raise NotImplementedError - self.erase_all = 1 if args.erase_all else 0 + self.erase_all = 1 if args.erase_all else (0xAA if args.erase_force else 0) def command_timeout_ms(self) -> int: return self.timeout