github: support bound and symlinked devices (#4163)

* Fix unaccessible flipper for binded access points

workaround to work with symlinked devices

* Fix return None if Flipper not started

* exception handling

* decreased timeouts

* Check environment variables for flipper path
This commit is contained in:
Evgeny E
2025-03-31 14:20:25 +01:00
committed by GitHub
parent 79bb24406e
commit bcbf78a45d
5 changed files with 45 additions and 16 deletions

View File

@@ -4,6 +4,8 @@ import time
from datetime import datetime
from typing import Optional
from serial.serialutil import SerialException
from flipper.app import App
from flipper.storage import FlipperStorage
from flipper.utils.cdc import resolve_port
@@ -34,23 +36,34 @@ class Main(App):
def _get_flipper(self, retry_count: Optional[int] = 1):
port = None
self.logger.info(f"Attempting to find flipper with {retry_count} attempts.")
for i in range(retry_count):
time.sleep(1)
self.logger.info(f"Attempt to find flipper #{i}.")
self.logger.info(
f"Attempting to find flipper (Attempt {i + 1}/{retry_count})."
)
if port := resolve_port(self.logger, self.args.port):
self.logger.info(f"Found flipper at {port}")
break
if not port:
self.logger.info(f"Failed to find flipper {port}")
self.logger.info(f"Failed to find flipper")
return None
flipper = FlipperStorage(port)
flipper.start()
return flipper
for i in range(retry_count):
try:
flipper.start()
self.logger.info("Flipper successfully started.")
return flipper
except IOError as e:
self.logger.info(
f"Failed to start flipper (Attempt {i + 1}/{retry_count}): {e}"
)
time.sleep(1)
self.logger.error("Flipper failed to start after all retries.")
return None
def await_flipper(self):
if not (flipper := self._get_flipper(retry_count=self.args.timeout)):