From 88a57863bfb7cc34f0f1bb803fa825fdc954c1a7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Kuba=20Szczodrzy=C5=84ski?= Date: Sat, 4 Nov 2023 16:28:44 +0100 Subject: [PATCH] Add timeout for Kickstart flash reading --- ltctplugin/upk2esphome/work.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/ltctplugin/upk2esphome/work.py b/ltctplugin/upk2esphome/work.py index 0514860..b4e2e0c 100644 --- a/ltctplugin/upk2esphome/work.py +++ b/ltctplugin/upk2esphome/work.py @@ -50,7 +50,7 @@ def run_url(self, url: str): start = 0x1E0000 - offset end = 0x200000 - offset init_size = 1024 - block_size = 4096 + block_size = 2048 buffer = bytearray(end - start) with ClickProgressCallback(length=end - start) as bar: @@ -66,7 +66,7 @@ def run_url(self, url: str): params = dict(offset=0, length=init_size) bar.on_message(f"Connecting to {ip}...") - with requests.get(url, params) as r: + with requests.get(url, params, timeout=5.0) as r: data = r.content if len(data) != init_size: self.on_error( @@ -81,7 +81,7 @@ def run_url(self, url: str): params["offset"] = offset + start params["length"] = read_size sleep(0.05) - with requests.get(url, params) as r: + with requests.get(url, params, timeout=5.0) as r: data = r.content if len(data) != read_size: warning(f"Incomplete response read: {len(data)}/{read_size}")