#include <uhd/utils/chdr/chdr_packet.hpp>
Public Member Functions | |
template<typename payload_t > | |
chdr_packet (uhd::rfnoc::chdr_w_t chdr_w, uhd::rfnoc::chdr::chdr_header header, payload_t payload, boost::optional< uint64_t > timestamp=boost::none, std::vector< uint64_t > metadata={}) | |
chdr_packet (uhd::rfnoc::chdr_w_t chdr_w, uhd::rfnoc::chdr::chdr_header header, std::vector< uint8_t > payload_data, boost::optional< uint64_t > timestamp=boost::none, std::vector< uint64_t > mdata={}) | |
uhd::rfnoc::chdr::chdr_header | get_header () const |
void | set_header (uhd::rfnoc::chdr::chdr_header header) |
boost::optional< uint64_t > | get_timestamp () const |
void | set_timestamp (boost::optional< uint64_t > timestamp) |
const std::vector< uint64_t > & | get_metadata () const |
void | set_metadata (std::vector< uint64_t > metadata) |
std::vector< uint8_t > | serialize_to_byte_vector (endianness_t endianness=uhd::ENDIANNESS_LITTLE) const |
template<typename OutputIterator > | |
void | serialize (OutputIterator first, OutputIterator last, endianness_t endianness=uhd::ENDIANNESS_LITTLE) const |
size_t | get_packet_len () const |
const std::vector< uint8_t > & | get_payload_bytes () const |
void | set_payload_bytes (std::vector< uint8_t > bytes) |
template<typename payload_t > | |
payload_t | get_payload (uhd::endianness_t endianness=uhd::ENDIANNESS_LITTLE) const |
template<typename payload_t > | |
void | set_payload (payload_t payload, uhd::endianness_t endianness=uhd::ENDIANNESS_LITTLE) |
const std::string | to_string () const |
Return a string representation of this object. More... | |
template<typename payload_t > | |
const std::string | to_string_with_payload (uhd::endianness_t endianness=uhd::ENDIANNESS_LITTLE) const |
Return a string representation of this object and deserialize its payload. More... | |
Static Public Member Functions | |
template<typename InputIterator > | |
static chdr_packet | deserialize (uhd::rfnoc::chdr_w_t chdr_w, InputIterator first, InputIterator last, endianness_t endianness=uhd::ENDIANNESS_LITTLE) |
A Generic class that represents a CHDR Packet
Whether the packet has a specific type of payload is not specified
uhd::utils::chdr::chdr_packet::chdr_packet | ( | uhd::rfnoc::chdr_w_t | chdr_w, |
uhd::rfnoc::chdr::chdr_header | header, | ||
payload_t | payload, | ||
boost::optional< uint64_t > | timestamp = boost::none , |
||
std::vector< uint64_t > | metadata = {} |
||
) |
Constructs a CHDR Packet from a header and a payload
timestamp and metadata are optional and will be empty if omitted
uhd::utils::chdr::chdr_packet::chdr_packet | ( | uhd::rfnoc::chdr_w_t | chdr_w, |
uhd::rfnoc::chdr::chdr_header | header, | ||
std::vector< uint8_t > | payload_data, | ||
boost::optional< uint64_t > | timestamp = boost::none , |
||
std::vector< uint64_t > | mdata = {} |
||
) |
Construct a CHDR Packet from a header and raw payload words
timestamp and metadata are optional and will be empty if omitted
|
static |
Deserialize a CHDR Packet from a buffer of bytes
chdr_w | the CHDR_W of the incoming packet |
endianness | the endianness of the input buffer (link endianness) |
first | the start of the input buffer |
last | the end of the input buffer |
uhd::rfnoc::chdr::chdr_header uhd::utils::chdr::chdr_packet::get_header | ( | ) | const |
Returns the contents of the CHDR header
const std::vector<uint64_t>& uhd::utils::chdr::chdr_packet::get_metadata | ( | ) | const |
Returns a const reference to the metadata
size_t uhd::utils::chdr::chdr_packet::get_packet_len | ( | ) | const |
Get the total serialized length of the packet
payload_t uhd::utils::chdr::chdr_packet::get_payload | ( | uhd::endianness_t | endianness = uhd::ENDIANNESS_LITTLE | ) | const |
Parses the data out of this objects payload field into a payload_t object
endianness | The link endianness of the CHDR Link |
const std::vector<uint8_t>& uhd::utils::chdr::chdr_packet::get_payload_bytes | ( | ) | const |
Returns a const reference to the payload bytes
boost::optional<uint64_t> uhd::utils::chdr::chdr_packet::get_timestamp | ( | ) | const |
Returns the timestamp in the packet as an optional value
void uhd::utils::chdr::chdr_packet::serialize | ( | OutputIterator | first, |
OutputIterator | last, | ||
uhd::endianness_t | endianness = uhd::ENDIANNESS_LITTLE |
||
) | const |
Serialize a CHDR Packet into a buffer
endianness | the endianness of the output buffer (link endianness) |
first | the start of the output buffer |
last | the end of the output buffer |
std::vector<uint8_t> uhd::utils::chdr::chdr_packet::serialize_to_byte_vector | ( | endianness_t | endianness = uhd::ENDIANNESS_LITTLE | ) | const |
Serialize a CHDR Packet into a vector of bytes
endianness | the endianness of the returned vector (link endianness) |
void uhd::utils::chdr::chdr_packet::set_header | ( | uhd::rfnoc::chdr::chdr_header | header | ) |
Change this object's header
header | The new CHDR header |
void uhd::utils::chdr::chdr_packet::set_metadata | ( | std::vector< uint64_t > | metadata | ) |
Sets the metadata for a CHDR packet and updates the headers
metadata | A vector containing the new metadata |
void uhd::utils::chdr::chdr_packet::set_payload | ( | payload_t | payload, |
uhd::endianness_t | endianness = uhd::ENDIANNESS_LITTLE |
||
) |
Serializes the payload object into bytes and stores it in this object's payload field
payload | the payload object to store |
endianness | The link endianness of the CHDR Link |
void uhd::utils::chdr::chdr_packet::set_payload_bytes | ( | std::vector< uint8_t > | bytes | ) |
Sets the current payload
bytes | the payload to store inside this object (It is moved from) |
void uhd::utils::chdr::chdr_packet::set_timestamp | ( | boost::optional< uint64_t > | timestamp | ) |
Sets the timestamp in the packet
timestamp | the timestamp to set, or boost::none for no timestamp |
const std::string uhd::utils::chdr::chdr_packet::to_string | ( | ) | const |
Return a string representation of this object.
const std::string uhd::utils::chdr::chdr_packet::to_string_with_payload | ( | uhd::endianness_t | endianness = uhd::ENDIANNESS_LITTLE | ) | const |
Return a string representation of this object and deserialize its payload.