SoDaRadio-5.0.3-master:8901fb5
TRControl.cxx
Go to the documentation of this file.
1 /*
2  Copyright (c) 2015, 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 "TRControl.hxx"
30 #include "N200Control.hxx"
31 #include "B200Control.hxx"
32 #include "PropTree.hxx"
33 
34 #include <uhd/version.hpp>
35 #include <uhd/device.hpp>
36 #include <uhd/types/ranges.hpp>
37 #include <uhd/property_tree.hpp>
38 #include <boost/algorithm/string.hpp> //for split
39 #include <uhd/usrp/dboard_id.hpp>
40 #include <uhd/usrp/mboard_eeprom.hpp>
41 #include <uhd/usrp/dboard_eeprom.hpp>
42 
43 namespace SoDa {
44 
45  TRControl * TRControl::makeTRControl(uhd::usrp::multi_usrp::sptr usrp, int mboard) {
46  // first figure out what kind of device we are...
47  PropTree tree(usrp, "TRControl");
48  std::string modelname = tree.getStringProp("name", "unknown");
49 
50  // now do something different for each one...
51  if ((modelname == std::string("N200")) ||
52  (modelname == std::string("N210"))) {
53  // find the IP address.
54  std::string ip_address;
55  ip_address = tree.getProperty<uhd::usrp::mboard_eeprom_t>("/eeprom")["ip-addr"];
56  // std::cerr << boost::format("Got address = %s\n") % ip_address;
57  std::string gpsdo = tree.getProperty<uhd::usrp::mboard_eeprom_t>("/eeprom")["gpsdo"];
58  if(gpsdo == std::string("none")) {
59  return new N200Control(usrp, mboard, ip_address);
60  }
61  else {
62  return new NoopControl;
63  }
64 
65  }
66  else if ((modelname == std::string("B200")) ||
67  (modelname == std::string("B210"))) {
68  return new B200Control(usrp, mboard);
69  }
70  else {
71  return new NoopControl;
72  }
73  }
74 }
Transmit/Receive switch control for N200/N210 via the GPS serial or EXP serial io port...
Definition: N200Control.hxx:48
T getProperty(const std::string &propname, const T defval)
Definition: PropTree.hxx:157
Generic Control class to activate T/R switching, band switching, and other control functions...
Definition: TRControl.hxx:51
PropTree class encapsulates the USRP property tree functions to allow better trap and error recovery ...
Definition: PropTree.hxx:44
Transmit/Receive switch control for B200/B210 via the FX3 debug GPIO pins.
Definition: B200Control.hxx:54
std::string getStringProp(const std::string &propname, const std::string defval=std::string("None"))
Definition: PropTree.hxx:117
a null control class that returns happily for everyone.
Definition: TRControl.hxx:112
static TRControl * makeTRControl(uhd::usrp::multi_usrp::sptr usrp, int mboard=0)
make the appropriate TR control widget given a pointer to a USRP device.
Definition: TRControl.cxx:45