Skip to content

Commit 8f0456f

Browse files
committed
BUGFIX: parameter default values must be a Dict[str, Par]
1 parent da9632a commit 8f0456f

File tree

3 files changed

+8
-8
lines changed

3 files changed

+8
-8
lines changed

MethodicConfigurator/annotate_params.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -225,7 +225,7 @@ def format_params(param_dict: Dict[str, 'Par'], file_format: str = "missionplann
225225
formatted_params = []
226226
if file_format == "missionplanner":
227227
for key, parameter in param_dict.items():
228-
if isinstance(parameter, dict):
228+
if isinstance(parameter, Par):
229229
if parameter.comment:
230230
formatted_params.append(f"{key},{format(parameter.value, '.6f').rstrip('0').rstrip('.')}"
231231
f" # {parameter.comment}")
@@ -235,7 +235,7 @@ def format_params(param_dict: Dict[str, 'Par'], file_format: str = "missionplann
235235
formatted_params.append(f"{key},{format(parameter, '.6f').rstrip('0').rstrip('.')}")
236236
elif file_format == "mavproxy":
237237
for key, parameter in param_dict.items():
238-
if isinstance(parameter, dict):
238+
if isinstance(parameter, Par):
239239
if parameter.comment:
240240
formatted_params.append(f"{key:<16} {parameter.value:<8.6f} # {parameter.comment}")
241241
else:

MethodicConfigurator/backend_filesystem.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -532,14 +532,14 @@ def copy_fc_params_values_to_template_created_vehicle_files(self, fc_parameters:
532532
Par.export_to_param(Par.format_params(param_dict), os_path.join(self.vehicle_dir, param_filename))
533533
return ''
534534

535-
def write_param_default_values(self, param_default_values: Dict[str, float]):
535+
def write_param_default_values(self, param_default_values: Dict[str, 'Par']) -> bool:
536536
param_default_values = dict(sorted(param_default_values.items()))
537537
if self.param_default_dict != param_default_values:
538538
self.param_default_dict = param_default_values
539539
return True
540540
return False
541541

542-
def write_param_default_values_to_file(self, param_default_values: Dict[str, float], filename: str='00_default.param'):
542+
def write_param_default_values_to_file(self, param_default_values: Dict[str, 'Par'], filename: str='00_default.param'):
543543
if self.write_param_default_values(param_default_values):
544544
Par.export_to_param(Par.format_params(param_default_values), os_path.join(self.vehicle_dir, filename))
545545

MethodicConfigurator/backend_flightcontroller.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -271,13 +271,13 @@ def __process_autopilot_version(self, m):
271271
self.info.set_vendor_id_and_product_id(m.vendor_id, m.product_id)
272272
return ""
273273

274-
def download_params(self, progress_callback=None) -> Tuple[Dict[str, float], Dict[str, float]]:
274+
def download_params(self, progress_callback=None) -> Tuple[Dict[str, float], Dict[str, 'Par']]:
275275
"""
276276
Requests all flight controller parameters from a MAVLink connection.
277277
278278
Returns:
279279
Dict[str, float]: A dictionary of flight controller parameters.
280-
Dict[str, float]: A dictionary of flight controller default parameters.
280+
Dict[str, Par]: A dictionary of flight controller default parameters.
281281
"""
282282
# FIXME this entire if statement is for testing only, remove it later pylint: disable=fixme
283283
if self.master is None and self.comport is not None and self.comport.device == 'test':
@@ -332,7 +332,7 @@ def __download_params_via_mavlink(self, progress_callback=None) -> Dict[str, flo
332332
break
333333
return parameters
334334

335-
def download_params_via_mavftp(self, progress_callback=None) -> Tuple[Dict[str, float], Dict[str, float]]:
335+
def download_params_via_mavftp(self, progress_callback=None) -> Tuple[Dict[str, float], Dict[str, 'Par']]:
336336
# FIXME global variables should be avoided but I found no other practical way get the FTP result pylint: disable=fixme
337337
global ftp_should_run # pylint: disable=global-variable-undefined
338338
global pdict # pylint: disable=global-variable-undefined
@@ -362,7 +362,7 @@ def callback(fh):
362362
logging_info("got %u parameter values", len(pdict))
363363
if pdata.defaults:
364364
for (name, value, _ptype) in pdata.defaults:
365-
defdict[name.decode('utf-8')] = value
365+
defdict[name.decode('utf-8')] = Par(value)
366366
logging_info("got %u parameter default values", len(defdict))
367367
ftp_should_run = False
368368
progress_callback(len(data), len(data))

0 commit comments

Comments
 (0)