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