SoDaRadio-5.0.3-master:8901fb5
Params.cxx
Go to the documentation of this file.
1 /*
2 Copyright (c) 2013, 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 "Params.hxx"
30 #include <iostream>
31 
32 SoDa::Params::Params(int argc, char * argv[])
33 {
34  namespace po = boost::program_options;
35  po::options_description desc("Allowed options");
36  desc.add_options()
37  ("help", "help message")
38  ("uhdargs", po::value<std::string>(&radio_args)->default_value(""),
39  "extra parameters to pass to device creator (e.g. device id, address, type)")
40  ("config", po::value<std::string>(&config_filename)->default_value("~/.soda/config.xml"),
41  "configuration file for initial settings")
42  ("uds_name", po::value<std::string>(&server_sock_basename)->default_value("/tmp/SoDa_"),
43  "unix domain socket name for server to UI client message channels")
44  ("audio", po::value<std::string>(&audio_portname)->default_value("default"),
45  "Audio device name for ALSA audio.")
46  ("intN", po::value<bool>(&force_integer_N_mode)->default_value(false)->implicit_value(true),
47  "Force Integer-N synthesis for front-end local oscillators")
48  ("fracN", po::value<bool>(&force_frac_N_mode)->default_value(false)->implicit_value(true),
49  "Force Fractional-N synthesis for front-end local oscillators")
50  ("debug", po::value<unsigned int>(&debug_level)->default_value(0)->implicit_value(1),
51  "Enable debug messages for value > 0. Higher values may produce more detail.")
52  ("radio", po::value<std::string>(&radio_type)->default_value("USRP"),
53  "the radio type (USRP, Lime)")
54  ("gps_host", po::value<std::string>(&gps_hostname)->default_value("localhost"),
55  "hostname for gpsd server")
56  ("gps_port", po::value<std::string>(&gps_portname)->default_value("2947"),
57  "port number for gpsd server")
58  ("lockfile", po::value<std::string>(&lock_file_name)->default_value("SoDa.lock"),
59  "lock file to signal that a sodaradio server is active")
60  ("report_file", po::value<std::string>(&report_file_name),
61  "report file for memory statistics. Report only if a file name is supplied.")
62  ;
63 
64  po::store(po::parse_command_line(argc, argv, desc), pmap);
65  po::notify(pmap);
66 
67  // do we need a help message?
68  if(pmap.count("help")) {
69  std::cout << "SoDa -- The 'SoD' stands for Software Defined. The 'a' doesn't stand for anything. " << desc << std::endl;
70  exit(-1);
71  }
72 
73  report_mem_info = (pmap.count("report_file") != 0);
74 
75  // now we fill in the parameters.
77 }
78 
79 void SoDa::Params::readConfigFile(std::string & cf_name)
80 {
81  (void)cf_name;
82  // do nothing for now... later this will be the .xml file.
83  clock_source = "internal";
84  rx_rate = 625000.0; // 100.0e6/256.;
85  tx_rate = 625000.0 / 2.0 ; //100.0e6/2048.;
86  rx_ant = "RX2";
87  tx_ant = "TX/RX";
88 }
89 
90 void SoDa::Params::saveConfigFile(std::string & cf_name)
91 {
92  (void) cf_name;
93  // do nothing for now... later this will be the .xml file.
94 }
std::string report_file_name
Definition: Params.hxx:142
std::string server_sock_basename
Definition: Params.hxx:157
std::string rx_ant
Definition: Params.hxx:154
void saveConfigFile(std::string &cf_name)
save config data to a configuration file (for now, do nothing.)
Definition: Params.cxx:90
std::string config_filename
Definition: Params.hxx:148
double rx_rate
Definition: Params.hxx:153
boost::program_options::variables_map pmap
Definition: Params.hxx:139
std::string tx_ant
Definition: Params.hxx:154
Params(int argc, char *argv[])
Constructor.
Definition: Params.cxx:32
std::string lock_file_name
Definition: Params.hxx:150
unsigned int debug_level
Definition: Params.hxx:166
std::string gps_hostname
Definition: Params.hxx:144
std::string radio_args
Definition: Params.hxx:147
std::string radio_type
Definition: Params.hxx:146
std::string audio_portname
Definition: Params.hxx:160
bool report_mem_info
Definition: Params.hxx:141
std::string clock_source
Definition: Params.hxx:152
bool force_frac_N_mode
Definition: Params.hxx:163
std::string gps_portname
Definition: Params.hxx:145
void readConfigFile(std::string &cf_name)
read a configuration file (for now, just setup the default config.)
Definition: Params.cxx:79
double tx_rate
Definition: Params.hxx:153
bool force_integer_N_mode
Definition: Params.hxx:164