• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

mavlink / MAVSDK / 18324155869

07 Oct 2025 07:38PM UTC coverage: 47.532% (-0.1%) from 47.638%
18324155869

Pull #2680

github

web-flow
Merge 1f04eb271 into b65a17519
Pull Request #2680: mavlink_direct: handle (u)int > 2^32

2 of 24 new or added lines in 1 file covered. (8.33%)

185 existing lines in 12 files now uncovered.

17022 of 35812 relevant lines covered (47.53%)

454.71 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

87.93
/src/mavsdk/core/connection.cpp
1
#include "connection.h"
2

3
#include <memory>
4
#include <utility>
5
#include "mavsdk_impl.h"
6
#include "log.h"
7

8
namespace mavsdk {
9

10
std::atomic<unsigned> Connection::_forwarding_connections_count = 0;
11

12
Connection::Connection(
124✔
13
    ReceiverCallback receiver_callback,
14
    LibmavReceiverCallback libmav_receiver_callback,
15
    MavsdkImpl& mavsdk_impl,
16
    ForwardingOption forwarding_option) :
124✔
17
    _receiver_callback(std::move(receiver_callback)),
124✔
18
    _libmav_receiver_callback(std::move(libmav_receiver_callback)),
124✔
19
    _mavsdk_impl(mavsdk_impl),
124✔
20
    _mavlink_receiver(),
124✔
21
    _libmav_receiver(),
124✔
22
    _forwarding_option(forwarding_option)
248✔
23
{
24
    // Insert system ID 0 in all connections for broadcast.
25
    _system_ids.insert(0);
124✔
26

27
    if (forwarding_option == ForwardingOption::ForwardingOn) {
124✔
28
        _forwarding_connections_count++;
6✔
29
    }
30

31
    if (const char* env_p = std::getenv("MAVSDK_MAVLINK_DIRECT_DEBUGGING")) {
124✔
UNCOV
32
        if (std::string(env_p) == "1") {
×
UNCOV
33
            _debugging = true;
×
34
        }
35
    }
36
}
124✔
37

38
Connection::~Connection()
124✔
39
{
40
    // Just in case a specific connection didn't call it already.
41
    stop_mavlink_receiver();
124✔
42
    stop_libmav_receiver();
124✔
43
    _receiver_callback = {};
124✔
44
    _libmav_receiver_callback = {};
124✔
45
}
124✔
46

47
bool Connection::start_mavlink_receiver()
124✔
48
{
49
    _mavlink_receiver = std::make_unique<MavlinkReceiver>();
124✔
50
    return true;
124✔
51
}
52

53
void Connection::stop_mavlink_receiver()
248✔
54
{
55
    if (_mavlink_receiver) {
248✔
56
        _mavlink_receiver.reset();
124✔
57
    }
58
}
248✔
59

60
bool Connection::start_libmav_receiver()
124✔
61
{
62
    _libmav_receiver = std::make_unique<LibmavReceiver>(_mavsdk_impl);
124✔
63
    return true;
124✔
64
}
65

66
void Connection::stop_libmav_receiver()
124✔
67
{
68
    if (_libmav_receiver) {
124✔
69
        _libmav_receiver.reset();
124✔
70
    }
71
}
124✔
72

73
void Connection::receive_libmav_message(
2,365✔
74
    const Mavsdk::MavlinkMessage& message, Connection* connection)
75
{
76
    // Register system ID when receiving a message from a new system.
77
    if (_system_ids.find(message.system_id) == _system_ids.end()) {
2,365✔
UNCOV
78
        _system_ids.insert(message.system_id);
×
79
    }
80

81
    if (_debugging) {
2,363✔
82
        LogDebug() << "Connection::receive_libmav_message: " << message.message_name
×
UNCOV
83
                   << " from system " << message.system_id;
×
84
    }
85

86
    if (_libmav_receiver_callback) {
2,363✔
87
        if (_debugging) {
2,362✔
UNCOV
88
            LogDebug() << "Calling libmav receiver callback for: " << message.message_name;
×
89
        }
90
        _libmav_receiver_callback(message, connection);
2,362✔
91
    } else {
92
        LogWarn() << "No libmav receiver callback set!";
×
93
    }
94
}
2,364✔
95

96
void Connection::receive_message(mavlink_message_t& message, Connection* connection)
2,367✔
97
{
98
    // Register system ID when receiving a message from a new system.
99
    if (_system_ids.find(message.sysid) == _system_ids.end()) {
2,367✔
100
        _system_ids.insert(message.sysid);
126✔
101
    }
102
    _receiver_callback(message, connection);
2,366✔
103
}
2,367✔
104

105
bool Connection::should_forward_messages() const
42✔
106
{
107
    return _forwarding_option == ForwardingOption::ForwardingOn;
42✔
108
}
109

110
unsigned Connection::forwarding_connections_count()
102✔
111
{
112
    return _forwarding_connections_count;
102✔
113
}
114

115
bool Connection::has_system_id(uint8_t system_id)
1,779✔
116
{
117
    return _system_ids.find(system_id) != _system_ids.end();
1,779✔
118
}
119

120
} // namespace mavsdk
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2026 Coveralls, Inc