USRP Hardware Driver and USRP Manual: msg_task.hpp Source File

| USRP Hardware Driver and USRP Manual Version: 4.9.0.makepkg-0-g9ec1f582 UHD and USRP Manual |

Loading...
Searching...
No Matches
msg_task.hpp
Go to the documentation of this file.
1//
2// Copyright 2011-2015 Ettus Research LLC
3// Copyright 2018 Ettus Research, a National Instruments Company
4// Copyright 2019 Ettus Research, a National Instruments Brand
5//
6// SPDX-License-Identifier: GPL-3.0-or-later
7//
8
9#pragma once
10
11#include <uhd/config.hpp>
12#include <uhd/transport/zero_copy.hpp>
13#include <uhd/utils/noncopyable.hpp>
14#include <stdint.h>
15#include <boost/optional/optional.hpp>
16#include <cstring>
17#include <functional>
18#include <memory>
19#include <vector>
20
21namespace uhd {
22 class UHD_API msg_task : uhd::noncopyable
23{
24public:
25 typedef std::shared_ptr<msg_task> sptr;
26 typedef std::vector<uint8_t> msg_payload_t;
27 typedef std::pair<uint32_t, msg_payload_t> msg_type_t;
28 typedef std::function<boost::optional<msg_type_t>(void)> task_fcn_type;
29
30 /*
31 * During shutdown message queues for radio control cores might not be available
32 * anymore. Such stranded messages get pushed into a dump queue. With this function
33 * radio_ctrl_core can check if one of the messages meant for it got stranded.
34 */
35 virtual msg_payload_t get_msg_from_dump_queue(uint32_t sid) = 0;
36
37 UHD_INLINE static std::vector<uint8_t> buff_to_vector(uint8_t* p, size_t n)
38 {
39 if (p and n > 0) {
40 std::vector<uint8_t> v(n);
41 memcpy(&v.front(), p, n);
42 return v;
43 }
44 return std::vector<uint8_t>();
45 }
46
47 virtual ~msg_task(void) = 0;
48
65 static sptr make(const task_fcn_type& task_fcn);
66};
67} // namespace uhd
uhd::msg_task
Definition msg_task.hpp:23
uhd::msg_task::sptr
std::shared_ptr< msg_task > sptr
Definition msg_task.hpp:25
uhd::msg_task::get_msg_from_dump_queue
virtual msg_payload_t get_msg_from_dump_queue(uint32_t sid)=0
uhd::msg_task::msg_payload_t
std::vector< uint8_t > msg_payload_t
Definition msg_task.hpp:26
uhd::msg_task::msg_type_t
std::pair< uint32_t, msg_payload_t > msg_type_t
Definition msg_task.hpp:27
uhd::msg_task::~msg_task
virtual ~msg_task(void)=0
uhd::msg_task::make
static sptr make(const task_fcn_type &task_fcn)
uhd::msg_task::buff_to_vector
static UHD_INLINE std::vector< uint8_t > buff_to_vector(uint8_t *p, size_t n)
Definition msg_task.hpp:37
uhd::msg_task::task_fcn_type
std::function< boost::optional< msg_type_t >(void)> task_fcn_type
Definition msg_task.hpp:28
UHD_INLINE
#define UHD_INLINE
Definition config.h:65
UHD_API
#define UHD_API
Definition config.h:87
config.hpp
uhd
Definition build_info.hpp:12
uhd::noncopyable
boost::noncopyable noncopyable
Definition noncopyable.hpp:45
noncopyable.hpp
zero_copy.hpp