|
QGroundControl
Ground Control Station for MAVLink Drones
|
Mock implementation of Mavlink FTP server. More...
#include <MockLinkFTP.h>
Inheritance diagram for MockLinkFTP:
Collaboration diagram for MockLinkFTP:Classes | |
| struct | LogFile |
| Describes a simulated onboard log file served from the @MAV_LOG virtual directory. More... | |
Public Types | |
| enum | ErrorMode_t { errModeNone , errModeNoResponse , errModeNakResponse , errModeNoSecondResponse , errModeNoSecondResponseAllowRetry , errModeNakSecondResponse , errModeBadSequence } |
| By calling setErrorMode with one of these modes you can cause the server to simulate an error. More... | |
Signals | |
| void | terminateCommandReceived () |
| You can connect to this signal to be notified when the server receives a Terminate command. | |
| void | resetCommandReceived () |
| You can connect to this signal to be notified when the server receives a Reset command. | |
Public Member Functions | |
| MockLinkFTP (uint8_t systemIdServer, uint8_t componentIdServer, MockLink *mockLink) | |
| ~MockLinkFTP () | |
| void | setFileList (const QStringList &fileList) |
| void | setLogFiles (const QList< LogFile > &logFiles) |
| QList< LogFile > | logFiles () const |
| Returns the log files served from the @MAV_LOG virtual directory. | |
| QByteArray | logFileContents (const QString &name) const |
| void | setBurstReadDelayMs (int delayMs) |
| void | mavlinkMessageReceived (const mavlink_message_t &message) |
| Called to handle an FTP message. | |
| void | enableRandomDrops (bool enable) |
| QStringList | uploadedFiles () const |
| Returns the list of remote paths which have been uploaded in this session. | |
| QByteArray | uploadedFileContents (const QString &remotePath) const |
| Returns the contents of an uploaded file. Empty if the path is unknown. | |
| void | clearUploadedFiles () |
| Clears the stored uploaded file contents. | |
| void | setErrorMode (ErrorMode_t errMode) |
| Sets the error mode for command responses. This allows you to simulate various server errors. | |
| void | setListDirectoryWithTimeSupported (bool supported) |
Static Public Attributes | |
| static constexpr const ErrorMode_t | rgFailureModes [] |
| static constexpr const size_t | cFailureModes = std::size(MockLinkFTP::rgFailureModes) |
| The number of ErrorModes in the rgFailureModes array. | |
| static constexpr const char * | sizeFilenamePrefix = "mocklink-size-" |
| static constexpr uint32_t | kMockModificationTime = 1700000000 |
Mock implementation of Mavlink FTP server.
Definition at line 15 of file MockLinkFTP.h.
By calling setErrorMode with one of these modes you can cause the server to simulate an error.
Definition at line 64 of file MockLinkFTP.h.
| MockLinkFTP::MockLinkFTP | ( | uint8_t | systemIdServer, |
| uint8_t | componentIdServer, | ||
| MockLink * | mockLink | ||
| ) |
Definition at line 12 of file MockLinkFTP.cc.
| MockLinkFTP::~MockLinkFTP | ( | ) |
Definition at line 21 of file MockLinkFTP.cc.
|
inline |
Clears the stored uploaded file contents.
Definition at line 61 of file MockLinkFTP.h.
|
inline |
Definition at line 52 of file MockLinkFTP.h.
| QByteArray MockLinkFTP::logFileContents | ( | const QString & | name | ) | const |
Returns the deterministic contents served for the named @MAV_LOG log file. Empty if the name is unknown.
Definition at line 645 of file MockLinkFTP.cc.
|
inline |
Returns the log files served from the @MAV_LOG virtual directory.
Definition at line 39 of file MockLinkFTP.h.
Referenced by setLogFiles().
| void MockLinkFTP::mavlinkMessageReceived | ( | const mavlink_message_t & | message | ) |
Called to handle an FTP message.
Definition at line 454 of file MockLinkFTP.cc.
References errModeNakResponse, errModeNoResponse, MavlinkFTP::kCmdBurstReadFile, MavlinkFTP::kCmdCreateFile, MavlinkFTP::kCmdListDirectory, MavlinkFTP::kCmdListDirectoryWithTime, MavlinkFTP::kCmdNone, MavlinkFTP::kCmdOpenFileRO, MavlinkFTP::kCmdOpenFileWO, MavlinkFTP::kCmdReadFile, MavlinkFTP::kCmdRemoveFile, MavlinkFTP::kCmdResetSessions, MavlinkFTP::kCmdTerminateSession, MavlinkFTP::kCmdWriteFile, MavlinkFTP::kErrFail, MavlinkFTP::kErrUnknownCommand, MavlinkFTP::kRspAck, and MockLink::respondWithMavlinkMessage().
|
signal |
You can connect to this signal to be notified when the server receives a Reset command.
|
inline |
Delays each burst read by delayMs to simulate a slow link. Runs on the MockLink worker thread so it paces transfers without blocking the main thread.
Definition at line 47 of file MockLinkFTP.h.
|
inline |
Sets the error mode for command responses. This allows you to simulate various server errors.
Definition at line 75 of file MockLinkFTP.h.
|
inline |
Sets the list of files returned by the List command. Prepend names with F or D to indicate (F)ile or (D)irectory.
Definition at line 25 of file MockLinkFTP.h.
|
inline |
Controls whether the server implements the kCmdListDirectoryWithTime command. When false the server Naks it with kErrUnknownCommand so the client fallback to kCmdListDirectory can be tested.
Definition at line 79 of file MockLinkFTP.h.
| void MockLinkFTP::setLogFiles | ( | const QList< LogFile > & | logFiles | ) |
Sets the log files listed in and downloadable from the @MAV_LOG virtual directory. Removes any temp files cached for the previous log set.
Definition at line 665 of file MockLinkFTP.cc.
References logFiles().
|
signal |
You can connect to this signal to be notified when the server receives a Terminate command.
|
inline |
Returns the contents of an uploaded file. Empty if the path is unknown.
Definition at line 58 of file MockLinkFTP.h.
|
inline |
Returns the list of remote paths which have been uploaded in this session.
Definition at line 55 of file MockLinkFTP.h.
|
staticconstexpr |
The number of ErrorModes in the rgFailureModes array.
Definition at line 93 of file MockLinkFTP.h.
|
staticconstexpr |
Base modification time (seconds since UNIX epoch UTC) reported by the kCmdListDirectoryWithTime mock listing. Entry N reports kMockModificationTime + N.
Definition at line 99 of file MockLinkFTP.h.
|
staticconstexpr |
Array of failure modes you can cycle through for testing. By looping through this array you can avoid hardcoding the specific error modes in your unit test. This way when new error modes are added your unit test code may not need to be modified.
Definition at line 84 of file MockLinkFTP.h.
|
staticconstexpr |
Definition at line 95 of file MockLinkFTP.h.