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

mavlink / MAVSDK / 16685732933

01 Aug 2025 09:41PM UTC coverage: 46.108% (-0.06%) from 46.17%
16685732933

push

github

web-flow
Merge pull request #2636 from mavlink/pr-mavlinkdirect-tsan

mavlink_direct: unregister messages on deinit

5 of 5 new or added lines in 1 file covered. (100.0%)

36 existing lines in 8 files now uncovered.

16083 of 34881 relevant lines covered (46.11%)

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

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

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

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

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

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

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

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