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
85d15747
Commit
85d15747
authored
Jun 19, 2014
by
Don Gagne
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Start of mock FileSever for unit testing
parent
9557ba9d
Changes
5
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
227 additions
and
0 deletions
+227
-0
qgroundcontrol.pro
qgroundcontrol.pro
+3
-0
MockMavlinkFileServer.cc
src/qgcunittest/MockMavlinkFileServer.cc
+87
-0
MockMavlinkFileServer.h
src/qgcunittest/MockMavlinkFileServer.h
+85
-0
MockMavlinkInterface.cc
src/qgcunittest/MockMavlinkInterface.cc
+9
-0
MockMavlinkInterface.h
src/qgcunittest/MockMavlinkInterface.h
+43
-0
No files found.
qgroundcontrol.pro
View file @
85d15747
...
...
@@ -186,6 +186,8 @@ DebugBuild {
src
/
qgcunittest
/
MockUASManager
.
h
\
src
/
qgcunittest
/
MockUAS
.
h
\
src
/
qgcunittest
/
MockQGCUASParamManager
.
h
\
src
/
qgcunittest
/
MockMavlinkInterface
.
h
\
src
/
qgcunittest
/
MockMavlinkFileServer
.
h
\
src
/
qgcunittest
/
MultiSignalSpy
.
h
\
src
/
qgcunittest
/
FlightModeConfigTest
.
h
...
...
@@ -194,6 +196,7 @@ DebugBuild {
src
/
qgcunittest
/
MockUASManager
.
cc
\
src
/
qgcunittest
/
MockUAS
.
cc
\
src
/
qgcunittest
/
MockQGCUASParamManager
.
cc
\
src
/
qgcunittest
/
MockMavlinkFileServer
.
cc
\
src
/
qgcunittest
/
MultiSignalSpy
.
cc
\
src
/
qgcunittest
/
FlightModeConfigTest
.
cc
}
...
...
src/qgcunittest/MockMavlinkFileServer.cc
0 → 100644
View file @
85d15747
/*=====================================================================
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/>.
======================================================================*/
#include "MockMavlinkFileServer.h"
void
MockMavlinkFileServer
::
sendMessage
(
mavlink_message_t
message
)
{
Q_ASSERT
(
message
.
msgid
==
MAVLINK_MSG_ID_ENCAPSULATED_DATA
);
mavlink_encapsulated_data_t
data
;
mavlink_msg_encapsulated_data_decode
(
&
message
,
&
data
);
const
RequestHeader
*
hdr
=
(
const
RequestHeader
*
)
&
data
.
data
[
0
];
// FIXME: Check CRC
switch
(
hdr
->
opcode
)
{
case
kCmdNone
:
// ignored, always acked
RequestHeader
ackHdr
;
ackHdr
.
magic
=
'f'
;
ackHdr
.
opcode
=
kRspAck
;
ackHdr
.
session
=
0
;
ackHdr
.
crc32
=
0
;
ackHdr
.
size
=
0
;
// FIXME: Add CRC
//ackHdr.crc32 = crc32((uint8_t*)&hdr, sizeof(hdr) + hdr.size, 0);
mavlink_message_t
ackMessage
;
mavlink_msg_encapsulated_data_pack
(
250
,
0
,
&
ackMessage
,
0
/*_encdata_seq*/
,
(
uint8_t
*
)
&
ackHdr
);
emit
messageReceived
(
NULL
,
ackMessage
);
break
;
case
kCmdTerminate
:
// releases sessionID, closes file
case
kCmdReset
:
// terminates all sessions
case
kCmdList
:
// list files in <path> from <offset>
case
kCmdOpen
:
// opens <path> for reading, returns <session>
case
kCmdRead
:
// reads <size> bytes from <offset> in <session>
case
kCmdCreate
:
// creates <path> for writing, returns <session>
case
kCmdWrite
:
// appends <size> bytes at <offset> in <session>
case
kCmdRemove
:
// remove file (only if created by server?)
default:
// nack for all NYI opcodes
RequestHeader
nakHdr
;
nakHdr
.
opcode
=
kRspNak
;
nakHdr
.
magic
=
'f'
;
nakHdr
.
session
=
0
;
nakHdr
.
crc32
=
0
;
nakHdr
.
size
=
0
;
// FIXME: Add CRC
//ackHdr.crc32 = crc32((uint8_t*)&hdr, sizeof(hdr) + hdr.size, 0);
mavlink_message_t
nakMessage
;
mavlink_msg_encapsulated_data_pack
(
250
,
0
,
&
nakMessage
,
0
/*_encdata_seq*/
,
(
uint8_t
*
)
&
nakHdr
);
emit
messageReceived
(
NULL
,
nakMessage
);
break
;
}
}
src/qgcunittest/MockMavlinkFileServer.h
0 → 100644
View file @
85d15747
/*=====================================================================
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 MOCKMAVLINKFILESERVER_H
#define MOCKMAVLINKFILESERVER_H
#include "MockMavlinkInterface.h"
class
MockMavlinkFileServer
:
public
MockMavlinkInterface
{
Q_OBJECT
public:
MockMavlinkFileServer
(
void
)
{
};
virtual
void
sendMessage
(
mavlink_message_t
message
);
private:
// FIXME: These should be in a mavlink header somewhere shouldn't they?
struct
RequestHeader
{
uint8_t
magic
;
uint8_t
session
;
uint8_t
opcode
;
uint8_t
size
;
uint32_t
crc32
;
uint32_t
offset
;
uint8_t
data
[];
};
enum
Opcode
{
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?)
kRspAck
,
kRspNak
};
enum
ErrorCode
{
kErrNone
,
kErrNoRequest
,
kErrNoSession
,
kErrSequence
,
kErrNotDir
,
kErrNotFile
,
kErrEOF
,
kErrNotAppend
,
kErrTooBig
,
kErrIO
,
kErrPerm
};
};
#endif
src/qgcunittest/MockMavlinkInterface.cc
0 → 100644
View file @
85d15747
//
// MockMavlinkInterface.cc
// QGroundControl
//
// Created by Donald Gagne on 6/19/14.
// Copyright (c) 2014 Donald Gagne. All rights reserved.
//
#include "MockMavlinkInterface.h"
src/qgcunittest/MockMavlinkInterface.h
0 → 100644
View file @
85d15747
/*=====================================================================
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/>.
======================================================================*/
#include <QObject>
#include "QGCMAVLink.h"
#include "LinkInterface.h"
#ifndef MOCKMAVLINKINTERFACE_H
#define MOCKMAVLINKINTERFACE_H
class
MockMavlinkInterface
:
public
QObject
{
Q_OBJECT
public:
virtual
void
sendMessage
(
mavlink_message_t
message
)
=
0
;
signals:
void
messageReceived
(
LinkInterface
*
link
,
mavlink_message_t
message
);
};
#endif
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