• 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

0.0
/src/mavsdk/plugins/rtk/rtk_impl.cpp
1
#include "rtk_impl.h"
2
#include "base64.h"
3

4
namespace mavsdk {
5

6
RtkImpl::RtkImpl(System& system) : PluginImplBase(system)
×
7
{
8
    _system_impl->register_plugin(this);
×
9
}
×
10

11
RtkImpl::RtkImpl(std::shared_ptr<System> system) : PluginImplBase(std::move(system))
×
12
{
13
    _system_impl->register_plugin(this);
×
14
}
×
15

16
RtkImpl::~RtkImpl()
×
17
{
18
    _system_impl->unregister_plugin(this);
×
19
}
×
20

21
void RtkImpl::init() {}
×
22

23
void RtkImpl::deinit() {}
×
24

25
void RtkImpl::enable() {}
×
26

27
void RtkImpl::disable() {}
×
28

29
Rtk::Result RtkImpl::send_rtcm_data(Rtk::RtcmData rtcm_data)
×
30
{
31
    constexpr size_t field_len = MAVLINK_MSG_GPS_RTCM_DATA_FIELD_DATA_LEN;
×
32

33
    std::vector<uint8_t> decoded = base64_decode(rtcm_data.data_base64);
×
34

35
    const size_t num_packets_required =
36
        decoded.size() / field_len + (decoded.size() % field_len == 0 ? 0 : 1);
×
37

38
    // The maximum is 4 times the 180 bytes because we only have two bits to
39
    // denote the fragment ID.
40
    if (num_packets_required > 4) {
×
41
        return Rtk::Result::TooLong;
×
42
    }
43

44
    // Copy length before we change it.
45
    size_t bytes_to_send = decoded.size();
×
46

47
    // The mavlink helpers memcpy, so we need to make sure we're not
48
    // copying from where we shouldn't.
49
    decoded.resize(num_packets_required * field_len);
×
50

51
    for (size_t i = 0; i < num_packets_required; ++i) {
×
52
        const uint8_t flags =
×
53
            (num_packets_required > 1 ? 0x1 : 0x0) | ((i & 0x3) << 1) | ((_sequence & 0x1F) << 3);
×
54

55
        if (!_system_impl->queue_message([&](MavlinkAddress mavlink_address, uint8_t channel) {
×
56
                mavlink_message_t message;
57
                mavlink_msg_gps_rtcm_data_pack_chan(
×
58
                    mavlink_address.system_id,
×
59
                    mavlink_address.component_id,
×
60
                    channel,
61
                    &message,
62
                    flags,
×
63
                    static_cast<uint8_t>(std::min(field_len, bytes_to_send)),
×
64
                    (decoded.data() + (i * field_len)));
×
65
                return message;
×
66
            })) {
67
            ++_sequence;
×
68
            return Rtk::Result::ConnectionError;
×
69
        }
70

71
        bytes_to_send -= field_len;
×
72
    }
73

74
    ++_sequence;
×
75
    return Rtk::Result::Success;
×
76
}
×
77

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

© 2025 Coveralls, Inc