99"""
1010
1111import os
12- import time
1312from argparse import ArgumentParser
1413from logging import debug as logging_debug
1514from logging import error as logging_error
@@ -458,13 +457,13 @@ def __create_connection_with_retry( # pylint: disable=too-many-arguments, too-m
458457 msg = f"Failed to create mavlink connect to { self .comport .device } "
459458 raise ConnectionError (msg )
460459 # --- NEW: collect all vehicles detected within timeout ---
461- start_time = time . time ()
460+ start_time = time_time ()
462461 detected_vehicles = {} # sysid -> last HEARTBEAT
463462
464- while time . time () - start_time < timeout :
463+ while time_time () - start_time < timeout :
465464 m = self .master .recv_match (type = "HEARTBEAT" , blocking = False )
466465 if m is None :
467- time . sleep (0.1 )
466+ time_sleep (0.1 )
468467 continue
469468 sysid = m .get_srcSystem ()
470469 compid = m .get_srcComponent ()
@@ -483,14 +482,15 @@ def __create_connection_with_retry( # pylint: disable=too-many-arguments, too-m
483482 if self .info .is_supported :
484483 msg = _ ("Autopilot type {self.info.autopilot}" )
485484 logging_info (msg .format (** locals ()))
486- else :
487- msg = _ ("Unsupported autopilot type {self.info.autopilot}" )
488- # return msg.format(**locals())
489- continue
485+ self .info .set_type (m .type )
486+ msg = _ ("Vehicle type: {self.info.mav_type} running {self.info.vehicle_type} firmware" )
487+ logging_info (msg .format (** locals ()))
488+ break
489+ msg = _ ("Unsupported autopilot type {self.info.autopilot}" )
490490
491- self .info .set_type ( m . type )
492- msg = _ ("Vehicle type: {self.info.mav_type} running {self.info.vehicle_type} firmware " )
493- logging_info ( msg .format (** locals () ))
491+ if not self .info .is_supported :
492+ msg = _ ("No supported autopilots found " )
493+ return msg .format (** locals ())
494494
495495 self .__request_banner ()
496496 banner_msgs = self .__receive_banner_text ()
0 commit comments