Revision 08fad28f host/include/uhd/transport/vrt.hpp
| b/host/include/uhd/transport/vrt.hpp | ||
|---|---|---|
| 19 | 19 |
#define INCLUDED_UHD_TRANSPORT_VRT_HPP |
| 20 | 20 |
|
| 21 | 21 |
#include <uhd/config.hpp> |
| 22 |
#include <uhd/types/metadata.hpp>
|
|
| 23 |
#include <cstddef> |
|
| 22 |
#include <boost/cstdint.hpp>
|
|
| 23 |
#include <cstddef> //size_t
|
|
| 24 | 24 |
|
| 25 | 25 |
namespace uhd{ namespace transport{
|
| 26 | 26 |
|
| 27 | 27 |
namespace vrt{
|
| 28 | 28 |
|
| 29 |
static const size_t max_header_words32 = 5; //hdr+sid+tsi+tsf (no class id supported) |
|
| 29 |
//! The maximum number of 32-bit words in a vrt if packet header |
|
| 30 |
static const size_t max_if_hdr_words32 = 7; //hdr+sid+cid+tsi+tsf |
|
| 31 |
|
|
| 32 |
/*! |
|
| 33 |
* Definition for fields that can be packed into a vrt if header. |
|
| 34 |
* The size fields are used for input and output depending upon |
|
| 35 |
* the operation used (ie the pack or unpack function call). |
|
| 36 |
*/ |
|
| 37 |
struct UHD_API if_packet_info_t{
|
|
| 38 |
//size fields |
|
| 39 |
size_t num_payload_words32; //required in pack, derived in unpack |
|
| 40 |
size_t num_header_words32; //derived in pack, derived in unpack |
|
| 41 |
size_t num_packet_words32; //derived in pack, required in unpack |
|
| 42 |
|
|
| 43 |
//header fields |
|
| 44 |
size_t packet_count; |
|
| 45 |
bool sob, eob; |
|
| 46 |
|
|
| 47 |
//optional fields |
|
| 48 |
bool has_sid; boost::uint32_t sid; |
|
| 49 |
bool has_cid; boost::uint64_t cid; |
|
| 50 |
bool has_tsi; boost::uint32_t tsi; |
|
| 51 |
bool has_tsf; boost::uint64_t tsf; |
|
| 52 |
bool has_tlr; boost::uint32_t tlr; |
|
| 53 |
}; |
|
| 30 | 54 |
|
| 31 | 55 |
/*! |
| 32 | 56 |
* Pack a vrt header from metadata (big endian format). |
| 33 |
* \param metadata the tx metadata with flags and timestamps |
|
| 34 |
* \param header_buff memory to write the packed vrt header |
|
| 35 |
* \param num_header_words32 number of words in the vrt header |
|
| 36 |
* \param num_payload_words32 the length of the payload |
|
| 37 |
* \param num_packet_words32 the length of the packet |
|
| 38 |
* \param packet_count the packet count sequence number |
|
| 39 |
* \param tick_rate ticks per second used in time conversion |
|
| 57 |
* \param packet_buff memory to write the packed vrt header |
|
| 58 |
* \param if_packet_info the if packet info (read/write) |
|
| 40 | 59 |
*/ |
| 41 |
UHD_API void pack_be( |
|
| 42 |
const tx_metadata_t &metadata, //input |
|
| 43 |
boost::uint32_t *header_buff, //output |
|
| 44 |
size_t &num_header_words32, //output |
|
| 45 |
size_t num_payload_words32, //input |
|
| 46 |
size_t &num_packet_words32, //output |
|
| 47 |
size_t packet_count, //input |
|
| 48 |
double tick_rate //input |
|
| 60 |
UHD_API void if_hdr_pack_be( |
|
| 61 |
boost::uint32_t *packet_buff, |
|
| 62 |
if_packet_info_t &if_packet_info |
|
| 49 | 63 |
); |
| 50 | 64 |
|
| 51 | 65 |
/*! |
| 52 | 66 |
* Unpack a vrt header to metadata (big endian format). |
| 53 |
* \param metadata the rx metadata with flags and timestamps |
|
| 54 |
* \param header_buff memory to read the packed vrt header |
|
| 55 |
* \param num_header_words32 number of words in the vrt header |
|
| 56 |
* \param num_payload_words32 the length of the payload |
|
| 57 |
* \param num_packet_words32 the length of the packet |
|
| 58 |
* \param packet_count the packet count sequence number |
|
| 59 |
* \param tick_rate ticks per second used in time conversion |
|
| 67 |
* \param packet_buff memory to read the packed vrt header |
|
| 68 |
* \param if_packet_info the if packet info (read/write) |
|
| 60 | 69 |
*/ |
| 61 |
UHD_API void unpack_be( |
|
| 62 |
rx_metadata_t &metadata, //output |
|
| 63 |
const boost::uint32_t *header_buff, //input |
|
| 64 |
size_t &num_header_words32, //output |
|
| 65 |
size_t &num_payload_words32, //output |
|
| 66 |
size_t num_packet_words32, //input |
|
| 67 |
size_t &packet_count, //output |
|
| 68 |
double tick_rate //input |
|
| 70 |
UHD_API void if_hdr_unpack_be( |
|
| 71 |
const boost::uint32_t *packet_buff, |
|
| 72 |
if_packet_info_t &if_packet_info |
|
| 69 | 73 |
); |
| 70 | 74 |
|
| 71 | 75 |
/*! |
| 72 | 76 |
* Pack a vrt header from metadata (little endian format). |
| 73 |
* \param metadata the tx metadata with flags and timestamps |
|
| 74 |
* \param header_buff memory to write the packed vrt header |
|
| 75 |
* \param num_header_words32 number of words in the vrt header |
|
| 76 |
* \param num_payload_words32 the length of the payload |
|
| 77 |
* \param num_packet_words32 the length of the packet |
|
| 78 |
* \param packet_count the packet count sequence number |
|
| 79 |
* \param tick_rate ticks per second used in time conversion |
|
| 77 |
* \param packet_buff memory to write the packed vrt header |
|
| 78 |
* \param if_packet_info the if packet info (read/write) |
|
| 80 | 79 |
*/ |
| 81 |
UHD_API void pack_le( |
|
| 82 |
const tx_metadata_t &metadata, //input |
|
| 83 |
boost::uint32_t *header_buff, //output |
|
| 84 |
size_t &num_header_words32, //output |
|
| 85 |
size_t num_payload_words32, //input |
|
| 86 |
size_t &num_packet_words32, //output |
|
| 87 |
size_t packet_count, //input |
|
| 88 |
double tick_rate //input |
|
| 80 |
UHD_API void if_hdr_pack_le( |
|
| 81 |
boost::uint32_t *packet_buff, |
|
| 82 |
if_packet_info_t &if_packet_info |
|
| 89 | 83 |
); |
| 90 | 84 |
|
| 91 | 85 |
/*! |
| 92 | 86 |
* Unpack a vrt header to metadata (little endian format). |
| 93 |
* \param metadata the rx metadata with flags and timestamps |
|
| 94 |
* \param header_buff memory to read the packed vrt header |
|
| 95 |
* \param num_header_words32 number of words in the vrt header |
|
| 96 |
* \param num_payload_words32 the length of the payload |
|
| 97 |
* \param num_packet_words32 the length of the packet |
|
| 98 |
* \param packet_count the packet count sequence number |
|
| 99 |
* \param tick_rate ticks per second used in time conversion |
|
| 87 |
* \param packet_buff memory to read the packed vrt header |
|
| 88 |
* \param if_packet_info the if packet info (read/write) |
|
| 100 | 89 |
*/ |
| 101 |
UHD_API void unpack_le( |
|
| 102 |
rx_metadata_t &metadata, //output |
|
| 103 |
const boost::uint32_t *header_buff, //input |
|
| 104 |
size_t &num_header_words32, //output |
|
| 105 |
size_t &num_payload_words32, //output |
|
| 106 |
size_t num_packet_words32, //input |
|
| 107 |
size_t &packet_count, //output |
|
| 108 |
double tick_rate //input |
|
| 90 |
UHD_API void if_hdr_unpack_le( |
|
| 91 |
const boost::uint32_t *packet_buff, |
|
| 92 |
if_packet_info_t &if_packet_info |
|
| 109 | 93 |
); |
| 110 | 94 |
|
| 111 | 95 |
} //namespace vrt |
Also available in: Unified diff