Skip to content

Add button to download the last .bin file from the FC#774

Merged
amilcarlucas merged 1 commit into
masterfrom
download_last_bin_log
Sep 23, 2025
Merged

Add button to download the last .bin file from the FC#774
amilcarlucas merged 1 commit into
masterfrom
download_last_bin_log

Conversation

@amilcarlucas

Copy link
Copy Markdown
Collaborator

No description provided.

Copilot AI review requested due to automatic review settings September 7, 2025 10:46

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

This PR adds functionality to download the last flight log (.bin file) from an ArduPilot flight controller using MAVFTP. The feature provides a GUI button for users to download flight logs for analysis purposes.

Key changes:

  • Adds a new "Download last flight log" button to the parameter editor interface
  • Implements comprehensive flight log download functionality with multiple fallback methods for log discovery
  • Includes progress tracking and error handling for the download process

Reviewed Changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 4 comments.

File Description
frontend_tkinter_parameter_editor.py Adds GUI button and threading logic for flight log downloads
backend_flightcontroller.py Implements flight log download methods with fallback strategies for log number detection

# Test if this log file exists
temp_test_file = f"temp_test_{mid}.tmp"
mavftp.cmd_get([remote_filename, temp_test_file])
ret = mavftp.process_ftp_reply("OpenFileRO", timeout=5) # Must be > idle_detection_time (3.7s)

Copilot AI Sep 7, 2025

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The comment references idle_detection_time (3.7s) but uses a timeout of 5 seconds. This magic number relationship should be documented more clearly or the idle_detection_time should be referenced as a constant.

Copilot uses AI. Check for mistakes.

# Binary search to find the highest log number
low = 1
high = 9999 # Reasonable upper bound for log numbers

Copilot AI Sep 7, 2025

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The magic number 9999 should be defined as a named constant (e.g., MAX_LOG_NUMBER = 9999) to improve maintainability and make the upper bound configurable.

Copilot uses AI. Check for mistakes.

# Download the actual log file
mavftp.cmd_get([remote_filename, local_filename], progress_callback=get_progress_callback)
ret = mavftp.process_ftp_reply("OpenFileRO", timeout=0) # No timeout for large log files

Copilot AI Sep 7, 2025

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Using timeout=0 (infinite timeout) for large log files could cause the application to hang indefinitely if there are network issues. Consider using a reasonable large timeout value instead.

Copilot uses AI. Check for mistakes.

# Start the download in a separate thread to avoid blocking the GUI
def download_thread() -> None:
error_msg = ""

Copilot AI Sep 7, 2025

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The variable 'error_msg' is declared but only used in the exception handler. It should be declared closer to where it's used or removed if not needed for the initial empty string assignment.

Suggested change
error_msg = ""

Copilot uses AI. Check for mistakes.
@github-actions

github-actions Bot commented Sep 7, 2025

Copy link
Copy Markdown
Contributor

☂️ Python Coverage

current status: ✅

Overall Coverage

Lines Covered Coverage Threshold Status
8055 6291 78% 73% 🟢

New Files

No new covered files...

Modified Files

File Coverage Status
ardupilot_methodic_configurator/backend_flightcontroller.py 35% 🟢
ardupilot_methodic_configurator/frontend_tkinter_parameter_editor.py 23% 🟢
TOTAL 29% 🟢

updated for commit: ca75300 by action🐍

@github-actions

github-actions Bot commented Sep 7, 2025

Copy link
Copy Markdown
Contributor

Test Results

    2 files  ±0      2 suites  ±0   1m 37s ⏱️ +2s
1 743 tests ±0  1 742 ✅ ±0  1 💤 ±0  0 ❌ ±0 
3 486 runs  ±0  3 484 ✅ ±0  2 💤 ±0  0 ❌ ±0 

Results for commit 3e2c230. ± Comparison against base commit 4fa3c1c.

♻️ This comment has been updated with latest results.

@amilcarlucas amilcarlucas force-pushed the download_last_bin_log branch 5 times, most recently from 31ccb9c to 08b2cd2 Compare September 8, 2025 23:01
@amilcarlucas amilcarlucas merged commit d225757 into master Sep 23, 2025
19 of 23 checks passed
@amilcarlucas amilcarlucas deleted the download_last_bin_log branch September 23, 2025 23:10
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants