USRP Hardware Driver and USRP Manual  Version: 3.13.0.HEAD-0-gf114cfa0
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 //
5 // SPDX-License-Identifier: GPL-3.0-or-later
6 //
7 
8 #ifndef INCLUDED_UHD_UTILS_MSG_TASK_HPP
9 #define INCLUDED_UHD_UTILS_MSG_TASK_HPP
10 
11 #include <uhd/config.hpp>
13 #include <boost/shared_ptr.hpp>
14 #include <boost/function.hpp>
15 #include <boost/utility.hpp>
16 #include <boost/optional/optional.hpp>
17 #include <stdint.h>
18 #include <vector>
19 
20 namespace uhd{
21  class UHD_API msg_task : boost::noncopyable{
22  public:
23  typedef boost::shared_ptr<msg_task> sptr;
24  typedef std::vector<uint8_t> msg_payload_t;
25  typedef std::pair<uint32_t, msg_payload_t > msg_type_t;
26  typedef boost::function<boost::optional<msg_type_t>(void)> task_fcn_type;
27 
28  /*
29  * During shutdown message queues for radio control cores might not be available anymore.
30  * Such stranded messages get pushed into a dump queue.
31  * With this function radio_ctrl_core can check if one of the messages meant for it got stranded.
32  */
33  virtual msg_payload_t get_msg_from_dump_queue(uint32_t sid) = 0;
34 
35  UHD_INLINE static std::vector<uint8_t> buff_to_vector(uint8_t* p, size_t n) {
36  if(p and n > 0){
37  std::vector<uint8_t> v(n);
38  memcpy(&v.front(), p, n);
39  return v;
40  }
41  return std::vector<uint8_t>();
42  }
43 
44  virtual ~msg_task(void) = 0;
45 
62  static sptr make(const task_fcn_type &task_fcn);
63  };
64 } //namespace uhd
65 
66 #endif /* INCLUDED_UHD_UTILS_MSG_TASK_HPP */
67 
boost::shared_ptr< msg_task > sptr
Definition: msg_task.hpp:23
std::vector< uint8_t > msg_payload_t
Definition: msg_task.hpp:24
boost::function< boost::optional< msg_type_t >void)> task_fcn_type
Definition: msg_task.hpp:26
Definition: msg_task.hpp:21
Definition: build_info.hpp:14
#define UHD_INLINE
Definition: config.h:53
#define UHD_API
Definition: config.h:63
static UHD_INLINE std::vector< uint8_t > buff_to_vector(uint8_t *p, size_t n)
Definition: msg_task.hpp:35
std::pair< uint32_t, msg_payload_t > msg_type_t
Definition: msg_task.hpp:25