From 44ea31abeb79500cf4d5168f30a5717353515026 Mon Sep 17 00:00:00 2001 From: Jordan Yates Date: Mon, 20 Apr 2026 14:25:03 +1000 Subject: [PATCH] rpc_wrappers: file_write_basic: handle already matching Properly handle the response when the file already exists on the device. Signed-off-by: Jordan Yates --- src/infuse_iot/rpc_wrappers/file_write_basic.py | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/src/infuse_iot/rpc_wrappers/file_write_basic.py b/src/infuse_iot/rpc_wrappers/file_write_basic.py index 832c5bd..b25c60e 100644 --- a/src/infuse_iot/rpc_wrappers/file_write_basic.py +++ b/src/infuse_iot/rpc_wrappers/file_write_basic.py @@ -113,7 +113,14 @@ def handle_response(self, return_code, response): if return_code != 0: print(f"Failed to write file ({errno.strerror(-return_code)})") return - if (response.recv_len != len(self.payload)) or (response.recv_crc != self._expected_crc): + len_match = response.recv_len == len(self.payload) + crc_match = response.recv_crc != self._expected_crc + + if (response.recv_len == 0) and crc_match: + print("File already existed") + print(f"\tLength: {len(self.payload)}") + print(f"\t CRC: 0x{response.recv_crc:08x}") + elif (not len_match) or (not crc_match): print("Unexpected write contents") print(f"\tLength: {response.recv_len} (Expected {len(self.payload)})") print(f"\t CRC: 0x{response.recv_crc:08x} (Expected 0x{self._expected_crc:08x})")