Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Q
qgroundcontrol
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Valentin Platzgummer
qgroundcontrol
Commits
26fd536a
Commit
26fd536a
authored
Sep 06, 2014
by
Lorenz Meier
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #859 from DonLakeFlyer/FTP
Sync to latest firmware header changes
parents
cb5117f1
d98faebc
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
71 additions
and
91 deletions
+71
-91
MockMavlinkFileServer.cc
src/qgcunittest/MockMavlinkFileServer.cc
+12
-20
QGCUASFileManager.cc
src/uas/QGCUASFileManager.cc
+25
-33
QGCUASFileManager.h
src/uas/QGCUASFileManager.h
+34
-38
No files found.
src/qgcunittest/MockMavlinkFileServer.cc
View file @
26fd536a
...
...
@@ -66,7 +66,7 @@ void MockMavlinkFileServer::_listCommand(QGCUASFileManager::Request* request, ui
// We only support root path
path
=
(
char
*
)
&
request
->
data
[
0
];
if
(
!
path
.
isEmpty
()
&&
path
!=
"/"
)
{
_sendNak
(
QGCUASFileManager
::
kErr
NotDir
,
outgoingSeqNumber
);
_sendNak
(
QGCUASFileManager
::
kErr
Fail
,
outgoingSeqNumber
);
return
;
}
...
...
@@ -96,7 +96,7 @@ void MockMavlinkFileServer::_listCommand(QGCUASFileManager::Request* request, ui
_emitResponse
(
&
ackResponse
,
outgoingSeqNumber
);
}
else
if
(
_errMode
==
errModeNakSecondResponse
)
{
// Nak error all subsequent requests
_sendNak
(
QGCUASFileManager
::
kErr
Perm
,
outgoingSeqNumber
);
_sendNak
(
QGCUASFileManager
::
kErr
Fail
,
outgoingSeqNumber
);
return
;
}
else
if
(
_errMode
==
errModeNoSecondResponse
)
{
// No response for all subsequent requests
...
...
@@ -130,7 +130,7 @@ void MockMavlinkFileServer::_openCommand(QGCUASFileManager::Request* request, ui
}
}
if
(
!
found
)
{
_sendNak
(
QGCUASFileManager
::
kErr
NotFile
,
outgoingSeqNumber
);
_sendNak
(
QGCUASFileManager
::
kErr
Fail
,
outgoingSeqNumber
);
return
;
}
...
...
@@ -151,7 +151,7 @@ void MockMavlinkFileServer::_readCommand(QGCUASFileManager::Request* request, ui
uint16_t
outgoingSeqNumber
=
_nextSeqNumber
(
seqNumber
);
if
(
request
->
hdr
.
session
!=
_sessionId
)
{
_sendNak
(
QGCUASFileManager
::
kErr
NoSession
,
outgoingSeqNumber
);
_sendNak
(
QGCUASFileManager
::
kErr
Fail
,
outgoingSeqNumber
);
return
;
}
...
...
@@ -162,7 +162,7 @@ void MockMavlinkFileServer::_readCommand(QGCUASFileManager::Request* request, ui
// If we get here it means the client is requesting additional data past the first request
if
(
_errMode
==
errModeNakSecondResponse
)
{
// Nak error all subsequent requests
_sendNak
(
QGCUASFileManager
::
kErr
Perm
,
outgoingSeqNumber
);
_sendNak
(
QGCUASFileManager
::
kErr
Fail
,
outgoingSeqNumber
);
return
;
}
else
if
(
_errMode
==
errModeNoSecondResponse
)
{
// No rsponse for all subsequent requests
...
...
@@ -197,7 +197,7 @@ void MockMavlinkFileServer::_terminateCommand(QGCUASFileManager::Request* reques
uint16_t
outgoingSeqNumber
=
_nextSeqNumber
(
seqNumber
);
if
(
request
->
hdr
.
session
!=
_sessionId
)
{
_sendNak
(
QGCUASFileManager
::
kErr
No
Session
,
outgoingSeqNumber
);
_sendNak
(
QGCUASFileManager
::
kErr
Invalid
Session
,
outgoingSeqNumber
);
return
;
}
...
...
@@ -229,7 +229,7 @@ void MockMavlinkFileServer::sendMessage(mavlink_message_t message)
return
;
}
else
if
(
_errMode
==
errModeNakResponse
)
{
// Nak all requests, the actual error send back doesn't really matter as long as it's an error
_sendNak
(
QGCUASFileManager
::
kErr
Perm
,
outgoingSeqNumber
);
_sendNak
(
QGCUASFileManager
::
kErr
Fail
,
outgoingSeqNumber
);
return
;
}
...
...
@@ -244,7 +244,7 @@ void MockMavlinkFileServer::sendMessage(mavlink_message_t message)
// ignored, ack not sent back, for testing only
break
;
case
QGCUASFileManager
:
:
kCmdReset
:
case
QGCUASFileManager
:
:
kCmdReset
Sessions
:
// terminates all sessions
// Fall through to send back Ack
...
...
@@ -257,30 +257,22 @@ void MockMavlinkFileServer::sendMessage(mavlink_message_t message)
_emitResponse
(
&
ackResponse
,
outgoingSeqNumber
);
break
;
case
QGCUASFileManager
:
:
kCmdList
:
case
QGCUASFileManager
:
:
kCmdList
Directory
:
_listCommand
(
request
,
incomingSeqNumber
);
break
;
case
QGCUASFileManager
:
:
kCmdOpen
:
case
QGCUASFileManager
:
:
kCmdOpen
File
:
_openCommand
(
request
,
incomingSeqNumber
);
break
;
case
QGCUASFileManager
:
:
kCmdRead
:
case
QGCUASFileManager
:
:
kCmdRead
File
:
_readCommand
(
request
,
incomingSeqNumber
);
break
;
case
QGCUASFileManager
:
:
kCmdTerminate
:
case
QGCUASFileManager
:
:
kCmdTerminate
Session
:
_terminateCommand
(
request
,
incomingSeqNumber
);
break
;
// Remainder of commands are NYI
case
QGCUASFileManager
:
:
kCmdCreate
:
// creates <path> for writing, returns <session>
case
QGCUASFileManager
:
:
kCmdWrite
:
// appends <size> bytes at <offset> in <session>
case
QGCUASFileManager
:
:
kCmdRemove
:
// remove file (only if created by server?)
default:
// nack for all NYI opcodes
_sendNak
(
QGCUASFileManager
::
kErrUnknownCommand
,
outgoingSeqNumber
);
...
...
src/uas/QGCUASFileManager.cc
View file @
26fd536a
...
...
@@ -124,7 +124,7 @@ void QGCUASFileManager::_openAckResponse(Request* openAck)
Request
request
;
request
.
hdr
.
session
=
_activeSession
;
request
.
hdr
.
opcode
=
kCmdRead
;
request
.
hdr
.
opcode
=
kCmdRead
File
;
request
.
hdr
.
offset
=
_readOffset
;
request
.
hdr
.
size
=
sizeof
(
request
.
data
);
...
...
@@ -188,7 +188,7 @@ void QGCUASFileManager::_readAckResponse(Request* readAck)
Request
request
;
request
.
hdr
.
session
=
_activeSession
;
request
.
hdr
.
opcode
=
kCmdRead
;
request
.
hdr
.
opcode
=
kCmdRead
File
;
request
.
hdr
.
offset
=
_readOffset
;
request
.
hdr
.
size
=
0
;
...
...
@@ -388,7 +388,7 @@ void QGCUASFileManager::_sendListCommand(void)
Request
request
;
request
.
hdr
.
session
=
0
;
request
.
hdr
.
opcode
=
kCmdList
;
request
.
hdr
.
opcode
=
kCmdList
Directory
;
request
.
hdr
.
offset
=
_listOffset
;
request
.
hdr
.
size
=
0
;
...
...
@@ -423,7 +423,7 @@ void QGCUASFileManager::downloadPath(const QString& from, const QDir& downloadDi
Request
request
;
request
.
hdr
.
session
=
0
;
request
.
hdr
.
opcode
=
kCmdOpen
;
request
.
hdr
.
opcode
=
kCmdOpen
File
;
request
.
hdr
.
offset
=
0
;
request
.
hdr
.
size
=
0
;
_fillRequestWithString
(
&
request
,
from
);
...
...
@@ -433,34 +433,26 @@ void QGCUASFileManager::downloadPath(const QString& from, const QDir& downloadDi
QString
QGCUASFileManager
::
errorString
(
uint8_t
errorCode
)
{
switch
(
errorCode
)
{
case
kErrNone
:
return
QString
(
"no error"
);
case
kErrNoRequest
:
return
QString
(
"bad request"
);
case
kErrNoSession
:
return
QString
(
"bad session"
);
case
kErrSequence
:
return
QString
(
"bad sequence number"
);
case
kErrNotDir
:
return
QString
(
"not a directory"
);
case
kErrNotFile
:
return
QString
(
"not a file"
);
case
kErrEOF
:
return
QString
(
"read beyond end of file"
);
case
kErrNotAppend
:
return
QString
(
"write not at end of file"
);
case
kErrTooBig
:
return
QString
(
"file too big"
);
case
kErrIO
:
return
QString
(
"device I/O error"
);
case
kErrPerm
:
return
QString
(
"permission denied"
);
case
kErrUnknownCommand
:
return
QString
(
"unknown command"
);
case
kErrCrc
:
return
QString
(
"bad crc"
);
default:
return
QString
(
"unknown error code"
);
case
kErrNone
:
return
QString
(
"no error"
);
case
kErrFail
:
return
QString
(
"unknown error"
);
case
kErrEOF
:
return
QString
(
"read beyond end of file"
);
case
kErrUnknownCommand
:
return
QString
(
"unknown command"
);
case
kErrCrc
:
return
QString
(
"bad crc"
);
case
kErrFailErrno
:
return
QString
(
"command failed"
);
case
kErrInvalidDataSize
:
return
QString
(
"invalid data size"
);
case
kErrInvalidSession
:
return
QString
(
"invalid session"
);
case
kErrNoSessionsAvailable
:
return
QString
(
"no sessions availble"
);
default:
return
QString
(
"unknown error code"
);
}
}
...
...
@@ -527,7 +519,7 @@ void QGCUASFileManager::_sendTerminateCommand(void)
{
Request
request
;
request
.
hdr
.
session
=
_activeSession
;
request
.
hdr
.
opcode
=
kCmdTerminate
;
request
.
hdr
.
opcode
=
kCmdTerminate
Session
;
request
.
hdr
.
size
=
0
;
_sendRequest
(
&
request
);
}
...
...
src/uas/QGCUASFileManager.h
View file @
26fd536a
...
...
@@ -38,7 +38,7 @@ public:
/// These methods are only used for testing purposes.
bool
_sendCmdTestAck
(
void
)
{
return
_sendOpcodeOnlyCmd
(
kCmdNone
,
kCOAck
);
};
bool
_sendCmdTestNoAck
(
void
)
{
return
_sendOpcodeOnlyCmd
(
kCmdTestNoAck
,
kCOAck
);
};
bool
_sendCmdReset
(
void
)
{
return
_sendOpcodeOnlyCmd
(
kCmdReset
,
kCOAck
);
};
bool
_sendCmdReset
(
void
)
{
return
_sendOpcodeOnlyCmd
(
kCmdReset
Sessions
,
kCOAck
);
};
/// @brief Timeout in msecs to wait for an Ack time come back. This is public so we can write unit tests which wait long enough
/// for the FileManager to timeout.
...
...
@@ -104,43 +104,39 @@ protected:
};
enum
Opcode
{
// Commands
kCmdNone
,
///< ignored, always acked
kCmdTerminate
,
///< releases sessionID, closes file
kCmdReset
,
///< terminates all sessions
kCmdList
,
///< list files in <path> from <offset>
kCmdOpen
,
///< opens <path> for reading, returns <session>
kCmdRead
,
///< reads <size> bytes from <offset> in <session>
kCmdCreate
,
///< creates <path> for writing, returns <session>
kCmdWrite
,
///< appends <size> bytes at <offset> in <session>
kCmdRemove
,
///< remove file (only if created by server?)
// Responses
kRspAck
,
///< positive acknowledgement of previous command
kRspNak
,
///< negative acknowledgement of previous command
// Used for testing only, not part of protocol
kCmdTestNoAck
,
///< ignored, ack not sent back, should timeout waiting for ack
};
enum
ErrorCode
{
kErrNone
,
kErrNoRequest
,
kErrNoSession
,
kErrSequence
,
kErrNotDir
,
kErrNotFile
,
kErrEOF
,
kErrNotAppend
,
kErrTooBig
,
kErrIO
,
kErrPerm
,
kErrUnknownCommand
,
kErrCrc
};
{
kCmdNone
,
///< ignored, always acked
kCmdTerminateSession
,
///< Terminates open Read session
kCmdResetSessions
,
///< Terminates all open Read sessions
kCmdListDirectory
,
///< List files in <path> from <offset>
kCmdOpenFile
,
///< Opens file at <path> for reading, returns <session>
kCmdReadFile
,
///< Reads <size> bytes from <offset> in <session>
kCmdCreateFile
,
///< Creates file at <path> for writing, returns <session>
kCmdWriteFile
,
///< Appends <size> bytes to file in <session>
kCmdRemoveFile
,
///< Remove file at <path>
kCmdCreateDirectory
,
///< Creates directory at <path>
kCmdRemoveDirectory
,
///< Removes Directory at <path>, must be empty
kRspAck
,
///< Ack response
kRspNak
,
///< Nak response
// Used for testing only, not part of protocol
kCmdTestNoAck
,
///< ignored, ack not sent back, should timeout waiting for ack
};
/// @brief Error codes returned in Nak response PayloadHeader.data[0].
enum
ErrorCode
{
kErrNone
,
kErrFail
,
///< Unknown failure
kErrFailErrno
,
///< errno sent back in PayloadHeader.data[1]
kErrInvalidDataSize
,
///< PayloadHeader.size is invalid
kErrInvalidSession
,
///< Session is not currently open
kErrNoSessionsAvailable
,
///< All available Sessions in use
kErrEOF
,
///< Offset past end of file for List and Read commands
kErrUnknownCommand
,
///< Unknown command opcode
kErrCrc
///< CRC on Payload is incorrect
};
enum
OperationState
{
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment