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

QGC Parameters #265

Merged
merged 6 commits into from
Dec 5, 2023
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
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
Loading