USRP Hardware Driver and USRP Manual  Version: 003.008.002-0-ge9d11b35
UHD and USRP Manual
msg_task.hpp
Go to the documentation of this file.
1 //
2 // Copyright 2011-2014 Ettus Research LLC
3 //
4 // This program is free software: you can redistribute it and/or modify
5 // it under the terms of the GNU General Public License as published by
6 // the Free Software Foundation, either version 3 of the License, or
7 // (at your option) any later version.
8 //
9 // This program is distributed in the hope that it will be useful,
10 // but WITHOUT ANY WARRANTY; without even the implied warranty of
11 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 // GNU General Public License for more details.
13 //
14 // You should have received a copy of the GNU General Public License
15 // along with this program. If not, see <http://www.gnu.org/licenses/>.
16 //
17 
18 #ifndef INCLUDED_UHD_UTILS_MSG_TASK_HPP
19 #define INCLUDED_UHD_UTILS_MSG_TASK_HPP
20 
21 #include <uhd/config.hpp>
23 #include <boost/shared_ptr.hpp>
24 #include <boost/function.hpp>
25 #include <boost/utility.hpp>
26 #include <boost/optional/optional.hpp>
27 #include <boost/cstdint.hpp>
28 #include <vector>
29 
30 namespace uhd{
31  class UHD_API msg_task : boost::noncopyable{
32  public:
33  typedef boost::shared_ptr<msg_task> sptr;
34  typedef std::vector<boost::uint8_t> msg_payload_t;
35  typedef std::pair<boost::uint32_t, msg_payload_t > msg_type_t;
36  typedef boost::function<boost::optional<msg_type_t>(void)> task_fcn_type;
37 
38  /*
39  * During shutdown message queues for radio control cores might not be available anymore.
40  * Such stranded messages get pushed into a dump queue.
41  * With this function radio_ctrl_core can check if one of the messages meant for it got stranded.
42  */
43  virtual msg_payload_t get_msg_from_dump_queue(boost::uint32_t sid) = 0;
44 
45  inline static std::vector<boost::uint8_t> buff_to_vector(boost::uint8_t* p, size_t n) {
46  if(p and n > 0){
47  std::vector<boost::uint8_t> v(n);
48  memcpy(&v.front(), p, n);
49  return v;
50  }
51  return std::vector<boost::uint8_t>();
52  }
53 
54  virtual ~msg_task(void) = 0;
55 
72  static sptr make(const task_fcn_type &task_fcn);
73  };
74 } //namespace uhd
75 
76 #endif /* INCLUDED_UHD_UTILS_MSG_TASK_HPP */
77 
boost::shared_ptr< msg_task > sptr
Definition: msg_task.hpp:33
std::vector< boost::uint8_t > msg_payload_t
Definition: msg_task.hpp:34
boost::function< boost::optional< msg_type_t >void)> task_fcn_type
Definition: msg_task.hpp:36
Definition: msg_task.hpp:31
#define UHD_API
Definition: config.hpp:79
Definition: convert.hpp:28
std::pair< boost::uint32_t, msg_payload_t > msg_type_t
Definition: msg_task.hpp:35
static std::vector< boost::uint8_t > buff_to_vector(boost::uint8_t *p, size_t n)
Definition: msg_task.hpp:45