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
e2ce56dc
Commit
e2ce56dc
authored
Jun 25, 2014
by
Don Gagne
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
List command is now fully working
Also changes for Ack timeouts and unit testing
parent
1a4a9f4f
Changes
2
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
263 additions
and
111 deletions
+263
-111
QGCUASFileManager.cc
src/uas/QGCUASFileManager.cc
+185
-84
QGCUASFileManager.h
src/uas/QGCUASFileManager.h
+78
-27
No files found.
src/uas/QGCUASFileManager.cc
View file @
e2ce56dc
This diff is collapsed.
Click to expand it.
src/uas/QGCUASFileManager.h
View file @
e2ce56dc
/*=====================================================================
QGroundControl Open Source Ground Control Station
(c) 2009 - 2014 QGROUNDCONTROL PROJECT <http://www.qgroundcontrol.org>
This file is part of the QGROUNDCONTROL project
QGROUNDCONTROL is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
QGROUNDCONTROL is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with QGROUNDCONTROL. If not, see <http://www.gnu.org/licenses/>.
======================================================================*/
#ifndef QGCUASFILEMANAGER_H
#define QGCUASFILEMANAGER_H
#include <QObject>
#include "UASInterface.h"
class
QGCUASFileManager
:
public
QObject
...
...
@@ -9,17 +33,22 @@ class QGCUASFileManager : public QObject
Q_OBJECT
public:
QGCUASFileManager
(
QObject
*
parent
,
UASInterface
*
uas
);
/// 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
);
};
signals:
void
statusMessage
(
const
QString
&
msg
);
void
resetStatusMessages
();
void
errorMessage
(
const
QString
&
ms
);
public
slots
:
void
receiveMessage
(
LinkInterface
*
link
,
mavlink_message_t
message
);
void
nothingMessage
();
void
listRecursively
(
const
QString
&
from
);
void
downloadPath
(
const
QString
&
from
,
const
QString
&
to
);
// void timedOut();
protected:
struct
RequestHeader
...
...
@@ -30,23 +59,32 @@ protected:
uint8_t
size
;
uint32_t
crc32
;
uint32_t
offset
;
uint8_t
data
[];
};
struct
Request
{
struct
RequestHeader
hdr
;
// The entire Request must fit into the data member of the mavlink_encapsulated_data_t structure. We use as many leftover bytes
// after we use up space for the RequestHeader for the data portion of the Request.
uint8_t
data
[
sizeof
(((
mavlink_encapsulated_data_t
*
)
0
)
->
data
)
-
sizeof
(
RequestHeader
)];
};
enum
Opcode
{
kCmdNone
,
// ignored, always acked
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?)
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?)
kRspAck
,
kRspNak
kRspNak
,
kCmdTestNoAck
,
// ignored, ack not sent back, for testing only, should timeout waiting for ack
};
enum
ErrorCode
...
...
@@ -61,36 +99,49 @@ protected:
kErrNotAppend
,
kErrTooBig
,
kErrIO
,
kErrPerm
kErrPerm
,
kErrUnknownCommand
,
kErrCrc
};
enum
OperationState
{
kCOIdle
,
// not doing anything
kCOAck
,
// waiting for an Ack
kCOList
,
// waiting for a List response
};
OperationState
_current_operation
;
unsigned
_retry_counter
;
UASInterface
*
_mav
;
quint16
_encdata_seq
;
unsigned
_session_id
;
// session ID for current session
unsigned
_list_offset
;
// offset for the current List operation
QString
_list_path
;
// path for the current List operation
void
sendTerminate
();
void
sendReset
();
protected
slots
:
void
_ackTimeout
(
void
);
protected:
bool
_sendOpcodeOnlyCmd
(
uint8_t
opcode
,
OperationState
newOpState
);
void
_setupAckTimeout
(
void
);
void
_clearAckTimeout
(
void
);
void
_emitErrorMessage
(
const
QString
&
msg
);
void
_sendRequest
(
Request
*
request
);
void
sendList
();
void
listDecode
(
const
uint8_t
*
data
,
unsigned
len
);
static
quint32
crc32
(
const
uint8_t
*
src
,
unsigned
len
,
unsigned
state
);
static
quint32
crc32
(
Request
*
request
,
unsigned
state
=
0
);
static
QString
errorString
(
uint8_t
errorCode
);
OperationState
_currentOperation
;
///> Current operation of state machine
QTimer
_ackTimer
;
///> Used to signal a timeout waiting for an ack
static
const
int
_ackTimerTimeoutMsecs
=
1000
;
///> Timeout in msecs for ack timer
UASInterface
*
_mav
;
quint16
_encdata_seq
;
unsigned
_listOffset
;
// offset for the current List operation
QString
_listPath
;
// path for the current List operation
// We give MockMavlinkFileServer friend access so that it can use the data structures and opcodes
// to build a mock mavlink file server for testing.
friend
class
MockMavlinkFileServer
;
};
#endif // QGCUASFILEMANAGER_H
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