USRP Hardware Driver and USRP Manual  Version: 4.7.0.0
UHD and USRP Manual
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>
14 #include <stdint.h>
15 #include <boost/optional/optional.hpp>
16 #include <cstring>
17 #include <functional>
18 #include <memory>
19 #include <vector>
20 
21 namespace uhd {
23 {
24 public:
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
std::pair< uint32_t, msg_payload_t > msg_type_t
Definition: msg_task.hpp:27
std::vector< uint8_t > msg_payload_t
Definition: msg_task.hpp:26
boost::noncopyable noncopyable
Definition: noncopyable.hpp:45
Definition: msg_task.hpp:22
Definition: build_info.hpp:12
std::function< boost::optional< msg_type_t >void)> task_fcn_type
Definition: msg_task.hpp:28
#define UHD_INLINE
Definition: config.h:65
std::shared_ptr< msg_task > sptr
Definition: msg_task.hpp:25
#define UHD_API
Definition: config.h:87
static UHD_INLINE std::vector< uint8_t > buff_to_vector(uint8_t *p, size_t n)
Definition: msg_task.hpp:37