主要内容

upload

R2026b

Upload file to remote MAVLink client

Since R2026b

    Description

    status = upload(ftp,mavlinkclient,localPath,remotePath) uploads the file localPath to the remote file path remotePath on the remote MAVLink client mavlinkclient.

    example

    Examples

    collapse all

    Upload a file to 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");

    Upload the camera_intrinsics.json file located in the calib directory into the /fs/microsd/system/calibration directory by using the upload function.

    localPath = "calib/camera_intrinsics.json";
    remotePath = "/fs/microsd/system/calibration/camera_intrinsics.json"
    status = upload(ftp,uav,localPath,remotePath)
    status = true

    Input Arguments

    collapse all

    FTP microservice, specified as a ftpMicroservice object.

    Remote MAVLink client information, specified as a mavlinkclient object.

    Local path of the file to upload, specified as a string scalar.

    Example: "configs/camera_intrinsics.json"

    Data Types: string

    Destination file path on the remote MAVLink client.

    Example: "/fs/microsd/system/camera_intrinsics.json"

    Data Types: string

    Output Arguments

    collapse all

    File upload status, returned as a 1 or 0 of data type logical. The value is 1 (true) when all specified file chunks are uploaded.

    Data Types: logical

    Version History

    Introduced in R2026b