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

mavlink / MAVSDK / 11767930807

10 Nov 2024 07:33PM UTC coverage: 38.608% (+0.7%) from 37.921%
11767930807

push

github

web-flow
Merge pull request #2394 from mavlink/pr-consolidate-ci

Consolidate CI

12030 of 31159 relevant lines covered (38.61%)

243.33 hits per line

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

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

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

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

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

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

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

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

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

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