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
39b47e54
Commit
39b47e54
authored
Jan 15, 2011
by
pixhawk
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Minor compile fixed, added permanent storage of UAS name
parent
c5e1a67a
Changes
7
Hide whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
41 additions
and
219 deletions
+41
-219
qgroundcontrol.pro
qgroundcontrol.pro
+0
-2
MAVLinkLightProtocol.cc
src/comm/MAVLinkLightProtocol.cc
+0
-144
MAVLinkLightProtocol.h
src/comm/MAVLinkLightProtocol.h
+0
-67
UAS.cc
src/uas/UAS.cc
+22
-1
UAS.h
src/uas/UAS.h
+4
-0
QGCParamSlider.cc
src/ui/designer/QGCParamSlider.cc
+14
-4
UASView.cc
src/ui/uas/UASView.cc
+1
-1
No files found.
qgroundcontrol.pro
View file @
39b47e54
...
...
@@ -234,7 +234,6 @@ HEADERS += src/MG.h \
src
/
QGC
.
h
\
src
/
ui
/
QGCFirmwareUpdate
.
h
\
src
/
ui
/
QGCPxImuFirmwareUpdate
.
h
\
src
/
comm
/
MAVLinkLightProtocol
.
h
\
src
/
ui
/
QGCDataPlot2D
.
h
\
src
/
ui
/
linechart
/
IncrementalPlot
.
h
\
src
/
ui
/
map
/
Waypoint2DIcon
.
h
\
...
...
@@ -359,7 +358,6 @@ SOURCES += src/main.cc \
src
/
QGC
.
cc
\
src
/
ui
/
QGCFirmwareUpdate
.
cc
\
src
/
ui
/
QGCPxImuFirmwareUpdate
.
cc
\
src
/
comm
/
MAVLinkLightProtocol
.
cc
\
src
/
ui
/
QGCDataPlot2D
.
cc
\
src
/
ui
/
linechart
/
IncrementalPlot
.
cc
\
src
/
ui
/
map
/
Waypoint2DIcon
.
cc
\
...
...
src/comm/MAVLinkLightProtocol.cc
deleted
100644 → 0
View file @
c5e1a67a
/*=====================================================================
QGroundControl Open Source Ground Control Station
(c) 2009, 2010 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/>.
======================================================================*/
/**
* @file
* @brief Example implementation of a different protocol than the default MAVLink.
* @author Lorenz Meier <mail@qgroundcontrol.org>
*/
#include "MAVLinkLightProtocol.h"
#include "UASManager.h"
#include "ArduPilotMegaMAV.h"
#include "LinkManager.h"
MAVLinkLightProtocol
::
MAVLinkLightProtocol
()
:
MAVLinkProtocol
()
{
}
/**
* @param message message to send
*/
void
MAVLinkLightProtocol
::
sendMessage
(
mavlink_light_message_t
message
)
{
// Get all links connected to this unit
QList
<
LinkInterface
*>
links
=
LinkManager
::
instance
()
->
getLinksForProtocol
(
this
);
// Emit message on all links that are currently connected
QList
<
LinkInterface
*>::
iterator
i
;
for
(
i
=
links
.
begin
();
i
!=
links
.
end
();
++
i
)
{
sendMessage
(
*
i
,
message
);
}
}
/**
* @param link the link to send the message over
* @param message message to send
*/
void
MAVLinkLightProtocol
::
sendMessage
(
LinkInterface
*
link
,
mavlink_light_message_t
message
)
{
// Create buffer
uint8_t
buffer
[
100
];
// MAXIMUM PACKET LENGTH, INCLUDING STX BYTES
// Write message into buffer, prepending start sign
//int len = mavlink_msg_to_send_buffer(buffer, &message);
// FIXME TO SEND BUFFER FUNCTION MISSING
Q_UNUSED
(
message
);
int
len
=
0
;
// If link is connected
if
(
link
->
isConnected
())
{
// Send the portion of the buffer now occupied by the message
link
->
writeBytes
((
const
char
*
)
buffer
,
len
);
}
}
/**
* The bytes are copied by calling the LinkInterface::readBytes() method.
* This method parses all incoming bytes and constructs a MAVLink packet.
* It can handle multiple links in parallel, as each link has it's own buffer/
* parsing state machine.
* @param link The interface to read from
* @see LinkInterface
**/
void
MAVLinkLightProtocol
::
receiveBytes
(
LinkInterface
*
link
,
QByteArray
b
)
{
Q_UNUSED
(
link
);
Q_UNUSED
(
b
);
// receiveMutex.lock();
// // Prepare buffer
// static const int maxlen = 4096 * 100;
// static char buffer[maxlen];
// qint64 bytesToRead = link->bytesAvailable();
//
// // Get all data at once, let link read the bytes in the buffer array
// link->readBytes(buffer, maxlen);
//
// // Run through all bytes
// for (int position = 0; position < bytesToRead; position++)
// {
// mavlink_light_message_t msg;
// // FIXME PARSE
// if (1 == 0/* parsing returned a message */)
// {
//
// int sysid = 0; // system id from message, or always null if only one MAV is supported
// UASInterface* uas = UASManager::instance()->getUASForId(sysid);
//
// // Check and (if necessary) create UAS object
// if (uas == NULL)
// {
// ArduPilotMegaMAV* mav = new ArduPilotMAV(this, sysid); // FIXME change to msg.sysid if this field exists
// // Connect this robot to the UAS object
// // it is IMPORTANT here to use the right object type,
// // else the slot of the parent object is called (and thus the special
// // packets never reach their goal)
// connect(this, SIGNAL(messageReceived(LinkInterface*, mavlink_message_t)), mav, SLOT(receiveMessage(LinkInterface*, mavlink_message_t)));
// uas = mav;
// // Make UAS aware that this link can be used to communicate with the actual robot
// uas->addLink(link);
// // Now add UAS to "official" list, which makes the whole application aware of it
// UASManager::instance()->addUAS(uas);
// }
//
// // The packet is emitted as a whole, as it is only 255 - 261 bytes short
// // kind of inefficient, but no issue for a groundstation pc.
// // It buys as reentrancy for the whole code over all threads
// emit messageReceived(link, msg);
// }
// }
// receiveMutex.unlock();
}
/**
* @return The name of this protocol
**/
QString
MAVLinkLightProtocol
::
getName
()
{
return
QString
(
tr
(
"MAVLinkLight protocol"
));
}
src/comm/MAVLinkLightProtocol.h
deleted
100644 → 0
View file @
c5e1a67a
/*=====================================================================
QGroundControl Open Source Ground Control Station
(c) 2009 - 2011 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/>.
======================================================================*/
/**
* @file
* @brief Example implementation of a different protocol than the default MAVLink.
* @author Lorenz Meier <mail@qgroundcontrol.org>
*/
#ifndef MAVLINKLIGHTPROTOCOL_H
#define MAVLINKLIGHTPROTOCOL_H
#include <inttypes.h>
#include <QByteArray>
#include <MAVLinkProtocol.h>
#define MAVLINK_LIGHT_MAX_PAYLOAD_LEN 50
// Not part of message struct, but sent on link
// uint8_t stx1;
// uint8_t stx2;
typedef
struct
{
uint8_t
msgid
;
///< ID of message in payload
uint8_t
payload
[
MAVLINK_LIGHT_MAX_PAYLOAD_LEN
];
///< Payload data, ALIGNMENT IMPORTANT ON MCU
uint8_t
ck_a
;
///< Checksum high byte
uint8_t
ck_b
;
///< Checksum low byte
}
mavlink_light_message_t
;
class
MAVLinkLightProtocol
:
public
MAVLinkProtocol
{
Q_OBJECT
public:
explicit
MAVLinkLightProtocol
();
QString
getName
();
signals:
/** @brief Message received and directly copied via signal */
void
messageReceived
(
LinkInterface
*
link
,
mavlink_light_message_t
message
);
public
slots
:
void
sendMessage
(
mavlink_light_message_t
message
);
void
sendMessage
(
LinkInterface
*
link
,
mavlink_light_message_t
message
);
void
receiveBytes
(
LinkInterface
*
link
,
QByteArray
b
);
};
#endif // MAVLINKLIGHTPROTOCOL_H
src/uas/UAS.cc
View file @
39b47e54
...
...
@@ -12,13 +12,14 @@
#include <QList>
#include <QMessageBox>
#include <QTimer>
#include <QSettings>
#include <iostream>
#include <QDebug>
#include <cmath>
#include "UAS.h"
#include "LinkInterface.h"
#include "UASManager.h"
#include "MG.h"
//
#include "MG.h"
#include "QGC.h"
#include "GAudioOutput.h"
#include "MAVLinkProtocol.h"
...
...
@@ -86,14 +87,33 @@ paramsOnceRequested(false)
setBattery
(
LIPOLY
,
3
);
connect
(
statusTimeout
,
SIGNAL
(
timeout
()),
this
,
SLOT
(
updateState
()));
statusTimeout
->
start
(
500
);
readSettings
();
}
UAS
::~
UAS
()
{
writeSettings
();
delete
links
;
links
=
NULL
;
}
void
UAS
::
writeSettings
()
{
QSettings
settings
;
settings
.
beginGroup
(
QString
(
"MAV%1"
).
arg
(
uasId
));
settings
.
setValue
(
"NAME"
,
this
->
name
);
settings
.
endGroup
();
settings
.
sync
();
}
void
UAS
::
readSettings
()
{
QSettings
settings
;
settings
.
beginGroup
(
QString
(
"MAV%1"
).
arg
(
uasId
));
this
->
name
=
settings
.
value
(
"NAME"
,
this
->
name
).
toString
();
settings
.
endGroup
();
}
int
UAS
::
getUASID
()
const
{
return
uasId
;
...
...
@@ -1329,6 +1349,7 @@ void UAS::setParameter(const int component, const QString& id, const float value
void
UAS
::
setUASName
(
const
QString
&
name
)
{
this
->
name
=
name
;
writeSettings
();
emit
nameChanged
(
name
);
}
...
...
src/uas/UAS.h
View file @
39b47e54
...
...
@@ -303,6 +303,10 @@ signals:
protected:
/** @brief Get the UNIX timestamp in microseconds */
quint64
getUnixTime
(
quint64
time
);
/** @brief Write settings to disk */
void
writeSettings
();
/** @brief Read settings from disk */
void
readSettings
();
};
...
...
src/ui/designer/QGCParamSlider.cc
View file @
39b47e54
...
...
@@ -92,12 +92,22 @@ void QGCParamSlider::setSliderValue(int sliderValue)
ui
->
valueLabel
->
setText
(
QString
(
"%1 %2"
).
arg
(
parameterValue
,
0
,
'f'
,
3
).
arg
(
unit
));
}
/**
* @brief uas Unmanned system sending the parameter
* @brief component UAS component sending the parameter
* @brief parameterName Key/name of the parameter
* @brief value Value of the parameter
*/
void
QGCParamSlider
::
setParameterValue
(
int
uas
,
int
component
,
QString
parameterName
,
float
value
)
{
parameterValue
=
value
;
QString
unit
(
""
);
ui
->
valueLabel
->
setText
(
QString
(
"%1 %2"
).
arg
(
value
,
0
,
'f'
,
3
).
arg
(
unit
));
ui
->
valueSlider
->
setValue
(
floatToScaledInt
(
value
));
Q_UNUSED
(
uas
);
if
(
component
==
this
->
component
&&
parameterName
==
this
->
parameterName
)
{
parameterValue
=
value
;
QString
unit
(
""
);
ui
->
valueLabel
->
setText
(
QString
(
"%1 %2"
).
arg
(
value
,
0
,
'f'
,
3
).
arg
(
unit
));
ui
->
valueSlider
->
setValue
(
floatToScaledInt
(
value
));
}
}
void
QGCParamSlider
::
changeEvent
(
QEvent
*
e
)
...
...
src/ui/uas/UASView.cc
View file @
39b47e54
...
...
@@ -258,7 +258,7 @@ void UASView::receiveHeartbeat(UASInterface* uas)
void
UASView
::
updateName
(
const
QString
&
name
)
{
if
(
uas
)
m_ui
->
nameLabel
->
setText
(
uas
->
getUASName
()
);
if
(
uas
)
m_ui
->
nameLabel
->
setText
(
name
);
}
/**
...
...
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