Skip to content

Commit d162167

Browse files
authored
Merge pull request #32 from arduino/non_block_wait_for_FW
feat: _wait_for_fw_check timeout on unavailable FW version
2 parents b566a87 + 7c6d3fe commit d162167

File tree

1 file changed

+7
-1
lines changed

1 file changed

+7
-1
lines changed

arduino_alvik/arduino_alvik.py

+7-1
Original file line numberDiff line numberDiff line change
@@ -254,13 +254,19 @@ def _wait_for_ack(self) -> None:
254254
sleep_ms(20)
255255
self._waiting_ack = None
256256

257-
def _wait_for_fw_check(self) -> bool:
257+
def _wait_for_fw_check(self, timeout=5) -> bool:
258258
"""
259259
Waits until receives version from robot, check required version and return true if everything is ok
260+
:param timeout: wait for fw timeout in seconds
260261
:return:
261262
"""
263+
start = ticks_ms()
262264
while self._fw_version == [None, None, None]:
263265
sleep_ms(20)
266+
if ticks_diff(ticks_ms(), start) < timeout * 1000:
267+
print("Could not get FW version")
268+
return False
269+
264270
if self.check_firmware_compatibility():
265271
return True
266272
else:

0 commit comments

Comments
 (0)