mavlink/qgroundcontrol — pull request #731 by DonLakeFlyer (2014-06-27 02:28:11+00:00)
Title: FTP: Support Open/Read/Terminate commands, plus protocol changes

QGC side of Open/Read/Terminate commands now working with unit tests and mock file server support. This pull also updates the Mavlink FTP Protocol to handles problems I found while implementing. PX4Firmware:mavlink-ftp must be updated to this new spec as well. That will be my next work item.

Protocol Changes:
Added errCode to RequestHeader instead of sending error code in data. This allows return codes to be sent in Ack responses. This is used to indicate when there is more data available to the Read and List commands. Without this is requires an extra mavlink message sent in order to just get an empty EOF back. I figure wire bits are precious, hence the modification.

List Command
Request
offset - directory offset
data/size - path to list
session - ignored
Ack response
kErrNone - All directory entries in this packet (NEW)
kErrMore - More directory entries available at next offset (NEW)
data/size - null terminated strings (always null terminated, even at end of buffer) (NEW)
offset - offset which corresponds to this data
Nak response
kErrEOF - offset is past last directory entry
kErrNotDir - path not a directory

Read Command
Request
session - open file session
offset - offset into file to start reading from
data/size - ignored (as many bytes as possible always returned) (NEW)
Ack response
kErrNone - All file contents in this packet (NEW)
kErrMore - More file contents after this offset (NEW)
data/size - file contents
offset - offset which corresponds to this data
Nak response
kErrEOF - offset is past end of file
kErrIO - IO error while reading file