Skip to content

GCS_MAVLink: add support for ListDirectoryWithTime#33290

Open
julianoes wants to merge 2 commits into
ArduPilot:masterfrom
julianoes:pr-ftp-list-dir-with-time
Open

GCS_MAVLink: add support for ListDirectoryWithTime#33290
julianoes wants to merge 2 commits into
ArduPilot:masterfrom
julianoes:pr-ftp-list-dir-with-time

Conversation

@julianoes

@julianoes julianoes commented Jun 2, 2026

Copy link
Copy Markdown
Contributor

Summary

This extends MAVLink FTP to support the new opcode that allows to list files with modification time in UTC.

This is according to the new spec in:
mavlink/mavlink-devguide#701

Classification & Testing (check all that apply and add your own)

  • Checked by a human programmer
  • Non-functional change
  • No-binary change
  • Infrastructure change (e.g. unit tests, helper scripts)
  • Automated test(s) verify changes (e.g. unit test, autotest)
  • Tested manually, description below (e.g. SITL)
  • Tested on hardware
  • Logs attached
  • Logs available on request

Description

Tested using SITL, MAVSDK (mavlink/MAVSDK#2891), and QGC (mavlink/qgroundcontrol#14495)

Comment thread libraries/GCS_MAVLink/GCS_FTP.h
@julianoes

Copy link
Copy Markdown
Contributor Author

FYI @peterbarker

@julianoes julianoes force-pushed the pr-ftp-list-dir-with-time branch from 2170289 to 623000c Compare June 8, 2026 03:03
@julianoes

Copy link
Copy Markdown
Contributor Author

@hunt0r I've implemented this in QGroundControl and when testing it I found that I was missing log entries when using the FTP method!

Claude narrowed the bug down to an issue where there are two null terminations between directory listings. The fix is to avoid the additional null termination.

I checked MissionPlanner, pymavlink, and QGC, and they all ignore/skip additional nulls, so this fix should be backwards compatible.

@julianoes

Copy link
Copy Markdown
Contributor Author

Gentle bump. QGC and MAVSDK has been merged, would be good to get this in, or closed if it's no good. Thanks!

This extends MAVLink FTP to support the new opcode that allows to list
files with modification time in UTC.

This is according to the new spec in:
mavlink/mavlink-devguide#701
Each directory entry was terminated with two null bytes instead of one:
required_space already counts the trailing "%c" null from the snprintf
format, so the additional "+ 1" left the snprintf-appended terminator in
place as a stray second null.

Clients that walk the listing as null-separated strings (e.g. QGC) read
that stray null as an empty entry and advance their offset by one extra
per entry. For listings that fit in a single packet this is harmless, but
once a listing spans multiple packets the inflated offset causes the
client to skip real entries, so the tail of the directory goes missing.

This was latent for plain ListDirectory (short entries usually fit one
packet) and is reliably triggered by ListDirectoryWithTime, whose longer
entries make multi-packet listings the common case.
@julianoes julianoes force-pushed the pr-ftp-list-dir-with-time branch from 623000c to 3f3b6bc Compare June 16, 2026 21:11
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants