list
R2026bDescription
[
lists the names and attributes of files and subdirectories within the directory
status,directory] = list(ftp,mavlinkclient,directoryPath)directoryPath on the remote MAVLink client.
Examples
Download and delete flight logs from a Pixhawk® 4 board running PX4® firmware by using the FTP microservice.
Download the latest version of common.xml file from the MAVLINK Common Message Set
(common.xml) section of the MAVLink documentation, then create a mavlinkdialect
object using the file.
dialect = mavlinkdialect("common.xml");Create a local MAVLink client by using the mavlinkio object.
gcs = mavlinkio(dialect);
Store the remote MAVLink client information by using the mavlinkclient object. This Pixhawk board has a system ID of 1 and a component ID of 1.
uav = mavlinkclient(gcs,1,1);
Connect the local MAVLink client to the same serial port as the Pixhawk board by using the connect function. This Pixhawk board uses the COM5 port.
connect(gcs,"Serial",SerialPort="COM5");
Create a heartbeat microservice object.
heartbeat = mavlinkmicroservice(gcs,"heartbeat");Start sending the HEARTBEAT messages to the Pixhawk board by using the start function.
start(heartbeat,uav,"Serial",SerialPort="COM5")
If the Pixhawk board replies with HEARTBEAT messages, a connection is established.
Verify that the connection has been established by using the listClients function.
listClients(gcs)
ans = 2×4 table
SystemID ComponentID ComponentType AutopilotType
________ ___________ ____________________ _______________________
255 1 "MAV_TYPE_GCS" "MAV_AUTOPILOT_INVALID"
1 1 "MAV_TYPE_QUADROTOR" "MAV_AUTOPILOT_PX4"Create an FTP microservice object.
ftp = mavlinkmicroservice(gcs,"ftp");List the available flight logs stored in the /fs/microsd/log directory of the Pixhawk board by using the list function.
[status,directory] = list(ftp,uav,"/fs/microsd/log")status = true
directory = 4×3 table
Type Name Size
________ _______________ _________
File 2026-03-01.ulg 7340032
File 2026-03-02.ulg 7540432
File 2026-03-03.ulg 6320031
File 2026-03-04.ulg 8221332
Download the 2026-03-02.ulg flight log into the
Documents/logs directory by using the read
function.
[status,~] = read(ftp,uav,"/fs/microsd/log/2026-03-02.ulg", ... LocalPath="Document/logs/2026-03-02.ulg")
status = true
After you have downloaded the 2026-03-02.ulg flight log, delete the
flight log from the Pixhawk board to save memory space by using the remove
function.
status = remove(ftp,uav,"/fs/microsd/log/2026-03-02.ulg")status = true
Verify that the file has been deleted by using the list function
again.
[status,directory] = list(ftp,uav,"/fs/microsd/log")status = true
directory = 3×3 table
Type Name Size
________ _______________ _________
File 2026-03-01.ulg 7340032
File 2026-03-03.ulg 6320031
File 2026-03-04.ulg 8221332
Input Arguments
FTP microservice, specified as a ftpMicroservice
object.
Remote MAVLink client information, specified as a mavlinkclient object.
Remote directory path, specified as a string scalar. This argument specifies the path of the directory to list on the remote MAVLink client.
Example:
"/fs/microsd/log"
Data Types: string
Output Arguments
List status, returned as a 1 or 0 of data type
logical. The value is 1 (true)
when all files and folders in the specified directory are listed.
Data Types: logical
Directory listing, returned as a table with these columns:
Type— Returned asDirectoryorFile.Name— Name of folder or file.Size— File size, in bytes.
Version History
Introduced in R2026b
See Also
read | upload | remove | heartbeatMicroservice | parameterMicroservice | commandMicroservice | missionMicroservice
External Websites
MATLAB Command
You clicked a link that corresponds to this MATLAB command:
Run the command by entering it in the MATLAB Command Window. Web browsers do not support MATLAB commands.
웹사이트 선택
번역된 콘텐츠를 보고 지역별 이벤트와 혜택을 살펴보려면 웹사이트를 선택하십시오. 현재 계신 지역에 따라 다음 웹사이트를 권장합니다:
또한 다음 목록에서 웹사이트를 선택하실 수도 있습니다.
사이트 성능 최적화 방법
최고의 사이트 성능을 위해 중국 사이트(중국어 또는 영어)를 선택하십시오. 현재 계신 지역에서는 다른 국가의 MathWorks 사이트 방문이 최적화되지 않았습니다.
미주
- América Latina (Español)
- Canada (English)
- United States (English)
유럽
- Belgium (English)
- Denmark (English)
- Deutschland (Deutsch)
- España (Español)
- Finland (English)
- France (Français)
- Ireland (English)
- Italia (Italiano)
- Luxembourg (English)
- Netherlands (English)
- Norway (English)
- Österreich (Deutsch)
- Portugal (English)
- Sweden (English)
- Switzerland
- United Kingdom (English)