Commit 89f0da26 authored by hengli's avatar hengli

Added support for Google Protocol Buffers.

parent b0fd22a1
......@@ -179,6 +179,17 @@ message("Compiling for linux 32")
DEFINES += QGC_OSG_ENABLED
}
exists(/usr/local/include/google/protobuf) {
message("Building support for Protocol Buffers")
DEPENDENCIES_PRESENT += protobuf
# Include Protocol Buffers libraries
LIBS += -lprotobuf \
-lprotobuf-lite \
-lprotoc
DEFINES += QGC_PROTOBUF_ENABLED
}
exists(/usr/local/include/libfreenect/libfreenect.h) {
message("Building support for libfreenect")
DEPENDENCIES_PRESENT += libfreenect
......@@ -249,6 +260,17 @@ linux-g++-64 {
DEFINES += QGC_OSG_ENABLED
}
exists(/usr/local/include/google/protobuf) {
message("Building support for Protocol Buffers")
DEPENDENCIES_PRESENT += protobuf
# Include Protocol Buffers libraries
LIBS += -lprotobuf \
-lprotobuf-lite \
-lprotoc
DEFINES += QGC_PROTOBUF_ENABLED
}
exists(/usr/local/include/libfreenect) {
message("Building support for libfreenect")
DEPENDENCIES_PRESENT += libfreenect
......
......@@ -95,7 +95,7 @@ contains(MAVLINK_CONF, pixhawk) {
# Remove the default set - it is included anyway
INCLUDEPATH -= $$BASEDIR/../mavlink/include/common
INCLUDEPATH -= $$BASEDIR/thirdParty/mavlink/include/common
# PIXHAWK SPECIAL MESSAGES
INCLUDEPATH += $$BASEDIR/../mavlink/include/pixhawk
INCLUDEPATH += $$BASEDIR/thirdParty/mavlink/include/pixhawk
......@@ -372,6 +372,12 @@ contains(DEPENDENCIES_PRESENT, osg) {
src/ui/map3D/HUDScaleGeode.h \
src/ui/map3D/WaypointGroupNode.h
}
contains(DEPENDENCIES_PRESENT, protobuf):contains(MAVLINK_CONF, pixhawk) {
message("Including headers for Protocol Buffers")
# Enable only if protobuf is available
HEADERS += ../mavlink/include/pixhawk/pixhawk.pb.h
}
contains(DEPENDENCIES_PRESENT, libfreenect) {
message("Including headers for libfreenect")
......@@ -501,6 +507,12 @@ contains(DEPENDENCIES_PRESENT, osg) {
SOURCES += src/ui/map3D/QMap3D.cc
}
}
contains(DEPENDENCIES_PRESENT, protobuf):contains(MAVLINK_CONF, pixhawk) {
message("Including sources for Protocol Buffers")
# Enable only if protobuf is available
SOURCES += ../mavlink/src/pixhawk/pixhawk.pb.cc
}
contains(DEPENDENCIES_PRESENT, libfreenect) {
message("Including sources for libfreenect")
......
......@@ -31,6 +31,10 @@
#include "QGCMAVLinkUASFactory.h"
#include "QGC.h"
#ifdef QGC_PROTOBUF_ENABLED
#include "mavlink_protobuf_manager.hpp"
#endif
/**
* The default constructor will create a new MAVLink object sending heartbeats at
* the MAVLINK_HEARTBEAT_DEFAULT_RATE to all connected links.
......@@ -169,6 +173,7 @@ void MAVLinkProtocol::receiveBytes(LinkInterface* link, QByteArray b)
// receiveMutex.lock();
mavlink_message_t message;
mavlink_status_t status;
for (int position = 0; position < b.size(); position++) {
unsigned int decodeState = mavlink_parse_char(link->getId(), (uint8_t)(b.at(position)), &message, &status);
......@@ -181,6 +186,13 @@ void MAVLinkProtocol::receiveBytes(LinkInterface* link, QByteArray b)
// continue;
// }
//#endif
#ifdef QGC_PROTOBUF_ENABLED
if (message.msgid == MAVLINK_MSG_ID_EXTENDED_MESSAGE)
{
mavlink::ProtobufManager::instance();
}
#endif
// Log data
if (m_loggingEnabled && m_logfile) {
const int len = MAVLINK_MAX_PACKET_LEN+sizeof(quint64);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment