Skip to content

Add notes module - #1717

Merged
tridge merged 3 commits into
ArduPilot:masterfrom
tridge:pr-notes
Jul 30, 2026
Merged

Add notes module#1717
tridge merged 3 commits into
ArduPilot:masterfrom
tridge:pr-notes

Conversation

@tridge

@tridge tridge commented Jul 30, 2026

Copy link
Copy Markdown
Contributor

This allow you to collect notes in flight ready for next flight. Added as I wanted to keep notes together with logs and be able to quickly refer to past flight notes while flyin
Appears in MAVProxy menu when --aircraft is used
image

tridge added 3 commits July 30, 2026 10:22
There was no way to take a single item back out of a submenu once added.
MPMenuSubMenu.remove() only works on the submenu you already hold, and
nothing walks a menu path to reach it, so a module that adds an item with
console menu add had no way to tidy up after itself on unload.

Add remove_from_submenu() alongside add_to_submenu() on both MPMenuTop and
MPMenuSubMenu, and a console menu remove command using it. Separators have
no name, so the item match reads the attribute defensively.
Lets an operator flying with --aircraft keep notes about a flight, stored
beside the logs at AIRCRAFTNAME/logs/DATE/notes.txt. There is one file per
aircraft per day, so a day of several flights, or one flown with --mission,
shares the one file.

A Notes item is added to the console's MAVProxy menu, which opens a window
with a collapsible section per date, latest first. The current date is
expanded and editable and saves as you type; earlier dates that have notes
can be expanded and read but not edited, and are only read from disk when
first opened. An Insert time button, and ctrl-T, stamp the time at the
cursor for an in flight entry.

The path is built from aircraft_dir rather than by walking up from logdir,
as logdir is the flight subdirectory and sits one level deeper again with
--mission. Only real dates earlier than today are offered as history.

Saving is done in the GUI child process, which is the only place holding
the text. A write goes to a temporary file of our own and is then renamed,
with the directory synced, so a crash cannot truncate the notes and two
MAVProxy instances cannot write through the same temporary file. An empty
file is never created, as that would make the date look like one that has
notes.

Content we did not write is copied to notes.txt.bak before being replaced.
That covers the file changing under us, appearing while the window is open,
and being unreadable or not valid UTF-8, in which case the bytes are kept
as they are. A copy that cannot be made fails the save rather than going
ahead without it. Note that two MAVProxy instances saving the same notes in
the same instant can still race, as the check and the rename are not one
operation.

A failed write is reported in the window and retried. If it is still
failing as the window closes, the first close is refused with the reason
shown, and closing again writes the notes beside the file, or into the
.mavproxy directory, or prints them, under a name of this process so a
rescue copy never lands on another.

The menu item is added from idle_task, as the console may be loaded and
unloaded at any time, and goes in with add_to_submenu: adding a submenu of
the same name would replace the existing MAVProxy menu items. The command
is removed on unload, as MAVProxy leaves commands registered otherwise.

Each side closes the pipe end it does not use, so the window notices
MAVProxy going away and shuts down saving as it goes. Closing waits for the
window to finish writing rather than killing it while it may still hold
unsaved notes.
Flight notes are stored per aircraft and per date, so the module has
nowhere to put them without --aircraft, and they are state, so are not
wanted with --no-state. Load it just after aircraft_dir is worked out,
which is also after the console has loaded so the Notes menu item appears
straight away.
@tridge
tridge merged commit 849823c into ArduPilot:master Jul 30, 2026
2 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant