Skip to content

Commit

Permalink
download: change to QGC param format (#265)
Browse files Browse the repository at this point in the history
  • Loading branch information
afwilkin authored Dec 5, 2023
1 parent 6b146f9 commit 31a4915
Show file tree
Hide file tree
Showing 2 changed files with 36 additions and 7 deletions.
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -208,3 +208,5 @@ chmod u+x init-letsencrypt.sh
## Contributing
Contributions are welcome! Just open a pull request with detailed description
why the changes are needed, or open an issue for bugs, feature requests, etc...

Feel free to run `./run_pylint.sh` before PR to ensure CICD checks pass on your code.
41 changes: 34 additions & 7 deletions app/tornado_handlers/download.py
Original file line number Diff line number Diff line change
Expand Up @@ -60,19 +60,32 @@ def get_original_filename(default_value, new_file_suffix):
print("DB access failed:", sys.exc_info()[0], sys.exc_info()[1])
return default_value


if download_type == '1': # download the parameters
ulog = load_ulog_file(log_file_name)
param_keys = sorted(ulog.initial_parameters.keys())

self.set_header("Content-Type", "text/plain")
self.set_header('Content-Disposition', 'inline; filename=params.txt')
self.set_header('Content-Type', 'application/octet-stream')
self.set_header("Content-Description", "File Transfer")
self.set_header('Content-Disposition', 'attachment; filename=vehicle.params')

delimiter = ', '
delimiter = ' '
for param_key in param_keys:
self.write("1") #sysid
self.write(delimiter)
self.write("1") #compid
self.write(delimiter)
self.write(param_key)
self.write(delimiter)
self.write(str(ulog.initial_parameters[param_key]))

#if the value is an int write a 6, if not write a 9
if isinstance(ulog.initial_parameters[param_key], int):
self.write(delimiter)
self.write("6")
else:
self.write(delimiter)
self.write("9")

self.write('\n')

elif download_type == '2': # download the kml file
Expand Down Expand Up @@ -130,9 +143,10 @@ def kml_colors(flight_mode):
ulog = load_ulog_file(log_file_name)
param_keys = sorted(ulog.initial_parameters.keys())

self.set_header("Content-Type", "text/plain")
self.set_header('Content-Disposition', 'inline; filename=params.txt')
delimiter = ', '
self.set_header('Content-Type', 'application/octet-stream')
self.set_header("Content-Description", "File Transfer")
self.set_header('Content-Disposition', 'attachment; filename=non-default.params')
delimiter = ' '

# Use defaults from log if available
if ulog.has_default_parameters:
Expand All @@ -148,9 +162,22 @@ def kml_colors(flight_mode):
is_default = param_value == system_defaults[param_key]

if not is_default:
self.write("1")
self.write(delimiter)
self.write("1")
self.write(delimiter)
self.write(param_key)
self.write(delimiter)
self.write(str(param_value))

#if the value is an int write a 6, if not write a 9
if isinstance(param_value, int):
self.write(delimiter)
self.write("6")
else:
self.write(delimiter)
self.write("9")

self.write('\n')
except:
pass
Expand Down

0 comments on commit 31a4915

Please sign in to comment.