SoDaRadio-5.0.3-master:8901fb5
USRPFrontEnd.cxx
Go to the documentation of this file.
1 /*
2  Copyright (c) 2017, Matthew H. Reilly (kb1vc)
3  All rights reserved.
4 
5  Redistribution and use in source and binary forms, with or without
6  modification, are permitted provided that the following conditions are
7  met:
8 
9  Redistributions of source code must retain the above copyright
10  notice, this list of conditions and the following disclaimer.
11  Redistributions in binary form must reproduce the above copyright
12  notice, this list of conditions and the following disclaimer in
13  the documentation and/or other materials provided with the
14  distribution.
15 
16  THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
17  "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
18  LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
19  A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
20  HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
21  SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
22  LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
23  DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
24  THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
25  (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
26  OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
27 */
28 
29 #include <string>
30 #include <boost/format.hpp>
31 #include <boost/foreach.hpp>
32 #include <iostream>
33 #include "USRPFrontEnd.hxx"
34 #include "PropTree.hxx"
35 
36 namespace SoDa {
37  PropTree * getUSRPFrontEnd(PropTree * tree, char tr_choice) {
38  // find a daughterboard.
39  std::vector<std::string> dblist = tree->getPropNames("dboards");
40 
41  std::string fe_name;
42  switch(tr_choice) {
43  case 'r':
44  case 'R':
45  fe_name = "/rx_frontends";
46  break;
47  case 't':
48  case 'T':
49  fe_name = "/tx_frontends";
50  break;
51  default:
52  return NULL;
53  }
54 
55  BOOST_FOREACH(std::string dbn, dblist) {
56  // now go down the list of tx/rx front ends
57  std::string fe_listn = "dboards/" + dbn + fe_name;
58  std::vector<std::string> felist = tree->getPropNames(fe_listn);
59  BOOST_FOREACH(std::string fen, felist) {
60  fe_name = fe_listn + "/" + fen;
61  // now see what the connection type is....
62  std::string conn_type = tree->getStringProp(fe_name + "/connection");
63  if((conn_type == "IQ") || (conn_type == "QI")) {
64  return new PropTree(tree, fe_name);
65  }
66  }
67  }
68 
69  return NULL;
70  }
71 
72  PropTree * getUSRPFrontEnd(PropTree & tree, char tr_choice) {
73  return getUSRPFrontEnd(&tree, tr_choice);
74  }
75 }
PropTree * getUSRPFrontEnd(PropTree *tree, char tr_choice)
return a pointer to a PropTree object for the first "T" or "R" front end that provides an IQ or QI st...
PropTree class encapsulates the USRP property tree functions to allow better trap and error recovery ...
Definition: PropTree.hxx:44
std::string getStringProp(const std::string &propname, const std::string defval=std::string("None"))
Definition: PropTree.hxx:117
std::vector< std::string > getPropNames(const std::string &path=std::string(""))
Definition: PropTree.hxx:112
Manage front end settings for Ettus USRP devices Functions that return a property tree corresponding ...