Skip to content

Commit

Permalink
chore(udp): rename ReceiveMetadata to RxMetadata
Browse files Browse the repository at this point in the history
Signed-off-by: Max SCHMELLER <[email protected]>
  • Loading branch information
mojomex committed Dec 13, 2024
1 parent 11ed243 commit ed904bd
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -115,14 +115,14 @@ class UdpSocket
static constexpr std::string_view broadcast_ip{"255.255.255.255"};

public:
struct ReceiveMetadata
struct RxMetadata
{
std::optional<uint64_t> timestamp_ns;
uint64_t drops_since_last_receive{0};
bool truncated;
};

using callback_t = std::function<void(const std::vector<uint8_t> &, const ReceiveMetadata &)>;
using callback_t = std::function<void(const std::vector<uint8_t> &, const RxMetadata &)>;

/**
* @brief Construct a UDP socket with timestamp measuring enabled. The minimal way to start
Expand Down Expand Up @@ -329,7 +329,7 @@ class UdpSocket

if (!is_accepted_sender(msg_header.sender_addr)) continue;

ReceiveMetadata metadata;
RxMetadata metadata;
get_receive_metadata(msg_header.msg, metadata);
metadata.truncated = untruncated_packet_length > buffer_size_;

Expand All @@ -339,7 +339,7 @@ class UdpSocket
});
}

void get_receive_metadata(msghdr & msg, ReceiveMetadata & inout_metadata)
void get_receive_metadata(msghdr & msg, RxMetadata & inout_metadata)
{
for (cmsghdr * cmsg = CMSG_FIRSTHDR(&msg); cmsg != nullptr; cmsg = CMSG_NXTHDR(&msg, cmsg)) {
if (cmsg->cmsg_level != SOL_SOCKET) continue;
Expand Down
5 changes: 2 additions & 3 deletions nebula_hw_interfaces/test/common/test_udp/utils.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -55,14 +55,13 @@ std::optional<int> udp_send(
}

template <typename _T, typename _R>
std::optional<
std::pair<std::vector<uint8_t>, nebula::drivers::connections::UdpSocket::ReceiveMetadata>>
std::optional<std::pair<std::vector<uint8_t>, nebula::drivers::connections::UdpSocket::RxMetadata>>
receive_once(nebula::drivers::connections::UdpSocket & sock, std::chrono::duration<_T, _R> timeout)
{
std::condition_variable cv_received_result;
std::mutex mtx_result;
std::optional<
std::pair<std::vector<uint8_t>, nebula::drivers::connections::UdpSocket::ReceiveMetadata>>
std::pair<std::vector<uint8_t>, nebula::drivers::connections::UdpSocket::RxMetadata>>
result;

sock.subscribe([&](const auto & data, const auto & metadata) {
Expand Down

0 comments on commit ed904bd

Please sign in to comment.