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

mavlink / MAVSDK / 18330687927

08 Oct 2025 01:12AM UTC coverage: 47.859% (+0.2%) from 47.68%
18330687927

Pull #2682

github

web-flow
Merge 71946e649 into cafb83cb6
Pull Request #2682: core: add raw connection

133 of 150 new or added lines in 6 files covered. (88.67%)

12 existing lines in 5 files now uncovered.

17223 of 35987 relevant lines covered (47.86%)

447.68 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)
130✔
9
{
10
    _system_impl.register_mavlink_message_handler(
130✔
11
        MAVLINK_MSG_ID_PING,
12
        [this](const mavlink_message_t& message) { Ping::process_ping(message); },
17✔
13
        this);
14
}
130✔
15

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

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

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

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

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

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

67
        if (message.compid != MAV_COMP_ID_AUTOPILOT1) {
9✔
68
            // We're currently only interested in the ping of the autopilot.
69
            return;
9✔
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