Python MAVFtp implementation

Hi there. I’m on the way to realize my own project that needs to automatically (from my own python script) send and receive files to/from pixhawk runned by arducopter. There aren’t any methods for ftp requests in mavutil.py, but MAVProxy can do this. I’ve checked the code of MAVProxy and found that i can upload files by sending network id + component id + payload via the file_transfer_protocol_send() function called from the connection object (i just caught their while debugging mavproxy code), but i have no ideas howto receive response from flight controller. Where is the response stream and how i can receive it? May somebody give me an example?

I don’t know but you could consider using MAVSDK instead. Soon, when v2 comes out, the FTP code should be better having gone through a complete refactor (see Split Ftp plugin into Ftp and FtpServer by julianoes · Pull Request #2060 · mavlink/MAVSDK · GitHub).

Thanks, there is a ftp_client.cpp module, in general it does the same functionality as mavproxy_ftp.py, but both can be used only manually, from console, by typing commands such as “ftp put file.txt”. How can i use ftp_client.cpp in external script and how i can send files by calling ftp function? Do i need to make my own fork from ftp_client.cpp for this?

You don’t have to fork it. The way it’s done is that you install the library and then build the example against the installed library, and then you just run it from cli.