Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

MAVProxy support retries from cmd line #1353

Merged
merged 2 commits into from
Apr 10, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 3 additions & 2 deletions MAVProxy/mavproxy.py
Original file line number Diff line number Diff line change
Expand Up @@ -1301,6 +1301,7 @@ def set_mav_version(mav10, mav20, autoProtocol, mavversionArg):
parser.add_option("--version", action='store_true', help="version information")
parser.add_option("--default-modules", default="log,signing,wp,rally,fence,ftp,param,relay,tuneopt,arm,mode,calibration,rc,auxopt,misc,cmdlong,battery,terrain,output,adsb,layout", help='default module list')
parser.add_option("--udp-timeout",dest="udp_timeout", default=0.0, type='float', help="Timeout for udp clients in seconds")
parser.add_option("--retries", type=int, help="number of times to retry connection", default=3)

(opts, args) = parser.parse_args()
if len(args) != 0:
Expand Down Expand Up @@ -1402,9 +1403,9 @@ def quit_handler(signum = None, frame = None):
for mdev in opts.master:
if mdev.find('?') != -1 or mdev.find('*') != -1:
for m in glob.glob(mdev):
if not mpstate.module('link').link_add(m, force_connected=opts.force_connected):
if not mpstate.module('link').link_add(m, force_connected=opts.force_connected, retries=opts.retries):
sys.exit(1)
elif not mpstate.module('link').link_add(mdev, force_connected=opts.force_connected):
elif not mpstate.module('link').link_add(mdev, force_connected=opts.force_connected, retries=opts.retries):
sys.exit(1)

if not opts.master and len(serial_list) == 1:
Expand Down
8 changes: 5 additions & 3 deletions MAVProxy/modules/mavproxy_link.py
Original file line number Diff line number Diff line change
Expand Up @@ -323,7 +323,7 @@ def apply_link_attributes(self, conn, optional_attributes):
print("Applying attribute to link: %s = %s" % (attr, optional_attributes[attr]))
setattr(conn, attr, optional_attributes[attr])

def link_add(self, descriptor, force_connected=False):
def link_add(self, descriptor, force_connected=False, retries=3):
'''add new link'''
try:
(device, optional_attributes) = self.parse_link_descriptor(descriptor)
Expand All @@ -342,13 +342,15 @@ def link_add(self, descriptor, force_connected=False):
conn = mavutil.mavlink_connection(device, autoreconnect=True,
source_system=self.settings.source_system,
baud=self.settings.baudrate,
force_connected=force_connected)
force_connected=force_connected,
retries=retries)
except Exception as e:
# try the same thing but without force-connected for
# backwards-compatability
conn = mavutil.mavlink_connection(device, autoreconnect=True,
source_system=self.settings.source_system,
baud=self.settings.baudrate)
baud=self.settings.baudrate,
retries=retries)
conn.mav.srcComponent = self.settings.source_component
except Exception as msg:
print("Failed to connect to %s : %s" % (descriptor, msg))
Expand Down
Loading