forked from UAVGCSTeam/GCS
-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathMavLinkReceiver.cpp
More file actions
29 lines (25 loc) · 890 Bytes
/
MavLinkReceiver.cpp
File metadata and controls
29 lines (25 loc) · 890 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
#include "MavlinkReceiver.h"
extern "C" {
#if __has_include(<mavlink/common/mavlink.h>)
#include <mavlink/common/mavlink.h>
#else
#include <common/mavlink.h>
#endif
}
struct MavlinkReceiver::Impl {
mavlink_status_t status{};
};
MavlinkReceiver::MavlinkReceiver(QObject* parent)
: QObject(parent), d_(std::make_unique<Impl>()) {}
MavlinkReceiver::~MavlinkReceiver() = default; // ← now Impl is complete
void MavlinkReceiver::onBytes(const QByteArray& data) {
mavlink_message_t msg;
for (unsigned char b : data) {
if (mavlink_parse_char(MAVLINK_COMM_0, b, &msg, &d_->status)) {
RxMavlinkMsg out{ msg.sysid, msg.compid, msg.msgid,
QByteArray(reinterpret_cast<const char*>(_MAV_PAYLOAD(&msg)),
static_cast<int>(msg.len)) };
emit messageReceived(out);
}
}
}