• 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

77.42
/src/mavsdk/core/raw_connection.cpp
1
#include "raw_connection.h"
2
#include "mavsdk_impl.h"
3
#include "log.h"
4

5
namespace mavsdk {
6

7
RawConnection::RawConnection(
1✔
8
    ReceiverCallback receiver_callback,
9
    LibmavReceiverCallback libmav_receiver_callback,
10
    MavsdkImpl& mavsdk_impl,
11
    ForwardingOption forwarding_option) :
1✔
12
    Connection(receiver_callback, libmav_receiver_callback, mavsdk_impl, forwarding_option)
1✔
13
{}
1✔
14

15
RawConnection::~RawConnection() = default;
2✔
16

17
ConnectionResult RawConnection::start()
1✔
18
{
19
    if (!start_mavlink_receiver()) {
1✔
NEW
20
        return ConnectionResult::ConnectionError;
×
21
    }
22

23
    if (!start_libmav_receiver()) {
1✔
NEW
24
        return ConnectionResult::ConnectionError;
×
25
    }
26

27
    return ConnectionResult::Success;
1✔
28
}
29

NEW
30
ConnectionResult RawConnection::stop()
×
31
{
NEW
32
    stop_mavlink_receiver();
×
NEW
33
    stop_libmav_receiver();
×
NEW
34
    return ConnectionResult::Success;
×
35
}
36

37
std::pair<bool, std::string> RawConnection::send_message(const mavlink_message_t& message)
1✔
38
{
39
    // Convert message to raw bytes and use common send path
40
    uint8_t buffer[MAVLINK_MAX_PACKET_LEN];
41
    uint16_t buffer_len = mavlink_msg_to_send_buffer(buffer, &message);
1✔
42
    return send_raw_bytes(reinterpret_cast<const char*>(buffer), buffer_len);
1✔
43
}
44

45
std::pair<bool, std::string> RawConnection::send_raw_bytes(const char* bytes, size_t length)
1✔
46
{
47
    if (_mavsdk_impl.notify_raw_bytes_sent(bytes, length)) {
1✔
48
        return {true, ""};
1✔
49
    } else {
NEW
50
        return {false, "no raw_bytes sender"};
×
51
    }
52
}
53

54
void RawConnection::receive(const char* bytes, size_t length)
1✔
55
{
56
    // set_new_datagram expects char*, not const char*, so we need to cast
57
    // This is safe because the receivers only read from the buffer
58
    _mavlink_receiver->set_new_datagram(const_cast<char*>(bytes), static_cast<int>(length));
1✔
59

60
    // Parse all mavlink messages in one datagram. Once exhausted, we'll exit while.
61
    while (_mavlink_receiver->parse_message()) {
2✔
62
        // Handle parsed message
63
        receive_message(_mavlink_receiver->get_last_message(), this);
1✔
64
    }
65

66
    // Also parse with libmav if available
67
    if (_libmav_receiver) {
1✔
68
        _libmav_receiver->set_new_datagram(const_cast<char*>(bytes), static_cast<int>(length));
1✔
69

70
        while (_libmav_receiver->parse_message()) {
2✔
71
            receive_libmav_message(_libmav_receiver->get_last_message(), this);
1✔
72
        }
73
    }
74
}
1✔
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