Skip to content

Commit d08997c

Browse files
committed
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 <jordan@embeint.com>
1 parent e77a2e0 commit d08997c

1 file changed

Lines changed: 8 additions & 1 deletion

File tree

src/infuse_iot/rpc_wrappers/file_write_basic.py

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -113,7 +113,14 @@ def handle_response(self, return_code, response):
113113
if return_code != 0:
114114
print(f"Failed to write file ({errno.strerror(-return_code)})")
115115
return
116-
if (response.recv_len != len(self.payload)) or (response.recv_crc != self._expected_crc):
116+
len_match = response.recv_len == len(self.payload)
117+
crc_match = response.recv_crc != self._expected_crc
118+
119+
if (response.recv_len == 0) and crc_match:
120+
print("File already existed")
121+
print(f"\tLength: {len(self.payload)}")
122+
print(f"\t CRC: 0x{response.recv_crc:08x}")
123+
elif (not len_match) or (not crc_match):
117124
print("Unexpected write contents")
118125
print(f"\tLength: {response.recv_len} (Expected {len(self.payload)})")
119126
print(f"\t CRC: 0x{response.recv_crc:08x} (Expected 0x{self._expected_crc:08x})")

0 commit comments

Comments
 (0)