aboutsummaryrefslogtreecommitdiffstats
path: root/host/lib/include/uhdlib/usrp/common/async_packet_handler.hpp
diff options
context:
space:
mode:
authorMartin Braun <martin.braun@ettus.com>2018-01-31 20:20:14 +0100
committerMartin Braun <martin.braun@ettus.com>2018-03-14 15:17:44 -0700
commit6652eb4a033b38bd952563f3544eb11e98f27327 (patch)
treec1b0af72cbaceaa1df462f18194f4063fb13ae17 /host/lib/include/uhdlib/usrp/common/async_packet_handler.hpp
parent86b95486ed6d68e2772d79f20feddbef5439981b (diff)
downloaduhd-6652eb4a033b38bd952563f3544eb11e98f27327.tar.gz
uhd-6652eb4a033b38bd952563f3544eb11e98f27327.tar.bz2
uhd-6652eb4a033b38bd952563f3544eb11e98f27327.zip
uhd: Move internal headers to uhdlib/
To avoid the proliferation of additional include directories and multiple ways of including project-local headers, we now default to moving all headers that are used across UHD into the uhdlib/ subdirectory. Some #include statements were also reordered as they were modified for closer compliance with the coding guidelines. Internal cpp source files should now include files like this: #include <uhdlib/rfnoc/ctrl_iface.hpp> Reviewed-by: Ashish Chaudhari <ashish.chaudhari@ettus.com>
Diffstat (limited to 'host/lib/include/uhdlib/usrp/common/async_packet_handler.hpp')
-rw-r--r--host/lib/include/uhdlib/usrp/common/async_packet_handler.hpp74
1 files changed, 74 insertions, 0 deletions
diff --git a/host/lib/include/uhdlib/usrp/common/async_packet_handler.hpp b/host/lib/include/uhdlib/usrp/common/async_packet_handler.hpp
new file mode 100644
index 000000000..de9d17001
--- /dev/null
+++ b/host/lib/include/uhdlib/usrp/common/async_packet_handler.hpp
@@ -0,0 +1,74 @@
+//
+// Copyright 2012 Ettus Research LLC
+// Copyright 2018 Ettus Research, a National Instruments Company
+//
+// SPDX-License-Identifier: GPL-3.0-or-later
+//
+
+#ifndef INCLUDED_LIBUHD_USRP_COMMON_ASYNC_PACKET_HANDLER_HPP
+#define INCLUDED_LIBUHD_USRP_COMMON_ASYNC_PACKET_HANDLER_HPP
+
+#include <uhd/config.hpp>
+#include <uhd/transport/vrt_if_packet.hpp>
+#include <uhd/types/metadata.hpp>
+#include <uhd/utils/byteswap.hpp>
+#include <uhd/utils/log.hpp>
+
+namespace uhd{ namespace usrp{
+
+ template <typename to_host_type>
+ void load_metadata_from_buff(
+ const to_host_type &to_host,
+ async_metadata_t &metadata,
+ const transport::vrt::if_packet_info_t &if_packet_info,
+ const uint32_t *vrt_hdr,
+ const double tick_rate,
+ const size_t channel = 0
+ ){
+ const uint32_t *payload = vrt_hdr + if_packet_info.num_header_words32;
+
+ //load into metadata
+ metadata.channel = channel;
+ metadata.has_time_spec = if_packet_info.has_tsf;
+ if (tick_rate == 0.0) {
+ metadata.time_spec = 0.0;
+ } else {
+ metadata.time_spec = time_spec_t::from_ticks(if_packet_info.tsf, tick_rate);
+ }
+ metadata.event_code = async_metadata_t::event_code_t(to_host(payload[0]) & 0xff);
+
+ //load user payload
+ for (size_t i = 1; i < if_packet_info.num_payload_words32; i++){
+ if (i-1 == 4) break; //limit of 4 words32
+ metadata.user_payload[i-1] = to_host(payload[i]);
+ }
+ }
+
+ UHD_INLINE void standard_async_msg_prints(const async_metadata_t &metadata)
+ {
+ if (metadata.event_code &
+ ( async_metadata_t::EVENT_CODE_UNDERFLOW
+ | async_metadata_t::EVENT_CODE_UNDERFLOW_IN_PACKET)
+ )
+ {
+ UHD_LOG_FASTPATH("U")
+ }
+ else if (metadata.event_code &
+ ( async_metadata_t::EVENT_CODE_SEQ_ERROR
+ | async_metadata_t::EVENT_CODE_SEQ_ERROR_IN_BURST)
+ )
+ {
+ UHD_LOG_FASTPATH("S")
+ }
+ else if (metadata.event_code &
+ async_metadata_t::EVENT_CODE_TIME_ERROR
+ )
+ {
+ UHD_LOG_FASTPATH("L")
+ }
+ }
+
+
+}} //namespace uhd::usrp
+
+#endif /* INCLUDED_LIBUHD_USRP_COMMON_ASYNC_PACKET_HANDLER_HPP */