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

mavlink / MAVSDK / 18295167004

06 Oct 2025 09:36PM UTC coverage: 47.601% (-0.006%) from 47.607%
18295167004

Pull #2678

github

web-flow
Merge 9fe4f9b58 into b65a17519
Pull Request #2678: core: improve connection error strings, fix threading issue

4 of 24 new or added lines in 3 files covered. (16.67%)

17 existing lines in 6 files now uncovered.

17037 of 35791 relevant lines covered (47.6%)

449.69 hits per line

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

96.88
/src/mavsdk/core/ping.cpp
1
#include "log.h"
2
#include "mavlink_address.h"
3
#include "ping.h"
4
#include "system_impl.h"
5

6
namespace mavsdk {
7

8
Ping::Ping(SystemImpl& system_impl) : _system_impl(system_impl)
127✔
9
{
10
    _system_impl.register_mavlink_message_handler(
127✔
11
        MAVLINK_MSG_ID_PING,
12
        [this](const mavlink_message_t& message) { Ping::process_ping(message); },
28✔
13
        this);
14
}
127✔
15

16
Ping::~Ping()
127✔
17
{
18
    _system_impl.unregister_all_mavlink_message_handlers(this);
127✔
19
}
127✔
20

21
void Ping::run_once()
11✔
22
{
23
    _system_impl.queue_message([&](MavlinkAddress mavlink_address, uint8_t channel) {
11✔
24
        mavlink_message_t message;
25
        mavlink_msg_ping_pack_chan(
11✔
26
            mavlink_address.system_id,
11✔
27
            mavlink_address.component_id,
11✔
28
            channel,
29
            &message,
30
            _system_impl.get_time().elapsed_us(),
11✔
31
            _ping_sequence,
32
            0,
33
            0); // to all
34
        return message;
11✔
35
    });
36
}
11✔
37

38
void Ping::process_ping(const mavlink_message_t& message)
28✔
39
{
40
    mavlink_ping_t ping;
41
    mavlink_msg_ping_decode(&message, &ping);
28✔
42

43
    if (ping.target_system == 0 && ping.target_component == 0) {
28✔
44
        // Response to ping request.
45

46
        _system_impl.queue_message([&](MavlinkAddress mavlink_address, uint8_t channel) {
13✔
47
            mavlink_message_t response_message;
48
            mavlink_msg_ping_pack_chan(
13✔
49
                mavlink_address.system_id,
13✔
50
                mavlink_address.component_id,
13✔
51
                channel,
52
                &response_message,
53
                ping.time_usec,
13✔
54
                ping.seq,
55
                message.sysid,
13✔
56
                message.compid);
13✔
57
            return response_message;
13✔
58
        });
59

60
    } else {
13✔
61
        // Answer from ping request.
62
        if (ping.seq != _ping_sequence) {
15✔
63
            // Ignoring unknown ping sequence.
64
            return;
15✔
65
        }
66

67
        if (message.compid != MAV_COMP_ID_AUTOPILOT1) {
15✔
68
            // We're currently only interested in the ping of the autopilot.
69
            return;
15✔
70
        }
71

UNCOV
72
        _last_ping_time_us = _system_impl.get_time().elapsed_us() - ping.time_usec;
×
73
    }
74
}
75

76
} // 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