four_multi
Multi-Antenna,Multi-Node,Multi-Band,Multi-Cell
examples/SISO_AMC_OFDM_realtime.cpp
00001 //
00002 // Copyright 2011-2013, Per Zetterberg, KTH Royal Institute of Technology
00003 //
00004 // This program is free software: you can redistribute it and/or modify
00005 // it under the terms of the GNU General Public License as published by
00006 // the Free Software Foundation, either version 3 of the License, or
00007 // (at your option) any later version.
00008 //
00009 // This program is distributed in the hope that it will be useful,
00010 // but WITHOUT ANY WARRANTY; without even the implied warranty of
00011 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00012 // GNU General Public License for more details.
00013 //
00014 // You should have received a copy of the GNU General Public License
00015 // along with this program.  If not, see <http://www.gnu.org/licenses/>.
00016 //
00017 
00018 #include "SISO_AMC_OFDM_node.hpp"
00019 
00020 namespace po = boost::program_options;
00021 using namespace boost;
00022 
00023 
00024 int UHD_SAFE_MAIN(int argc, char *argv[]){
00025 
00026    uint32_t modulation_order, codec_ix, start_time, node_ix, skip_ant;
00027    std::string dev_name;
00028    float gain_rx, gain_tx, frequency, frequency_in;
00029    bool chase;
00030    float delta_time;
00031 
00032     po::options_description desc("Allowed options");
00033     desc.add_options()
00034         ("help", "help message")
00035         ("m",po::value<uint32_t>(&modulation_order)->default_value(16), 
00036           "Modulation 4,16 or 256")
00037         ("codec_ix",po::value<uint32_t>(&codec_ix)->default_value(1), 
00038          "LDPC coder 0,1,2 or 3 means 1/4, 1/2, 5/8 and 3/4 rate")
00039         ("chase",po::value<bool>(&chase)->default_value(false),
00040          "Use chase combining in the receiver")
00041         ("node_ix",po::value<uint32_t>(&node_ix)->default_value(0),
00042          "=0 receiver, =1 transmitter")
00043         ("start_time",po::value<uint32_t>(&start_time)->default_value(0), 
00044             "Start time (GPS ref) h*3600+m*60+s") 
00045         ("d",po::value<std::string>(&dev_name)->default_value("/dev/ttyUSB0"), 
00046            "Serial port name of GPS device") 
00047         ("gain_rx",po::value<float>(&gain_rx)->default_value(15), 
00048           "Receiver chain gain")
00049         ("gain_tx",po::value<float>(&gain_tx)->default_value(0), 
00050           "Transmitter chain gain")
00051         ("skip_ant",po::value<uint32_t>(&skip_ant)->default_value(0), 
00052          "The IP adress of the used USRP assumed to be 192.168.10*(skip_chan+1).2") 
00053         ("freq",po::value<float>(&frequency_in)->default_value(-10), 
00054          "The frequency to be used by the transceiver") 
00055         ("delta_time",po::value<float>(&delta_time)->default_value(0.03), 
00056          "Time between frames") 
00057     ;
00058 
00059 
00060     po::variables_map vm;
00061     po::store(po::parse_command_line(argc, argv, desc), vm);
00062     po::notify(vm);
00063     
00064     if (vm.count("help")){
00065         std::cout << boost::format("SISO_AMC_OFDM_realtime  %s") % desc << 
00066 std::endl;
00067         return ~0;
00068     }
00069 
00070     if (!((modulation_order==4) | (modulation_order==16) | 
00071           (modulation_order==256))) {
00072       std::cout << "Sorry, the only modulation orders allowed are 4,16 and 256";
00073     };   
00074 
00075   node_ix=node_ix % 2;
00076 
00077   if (frequency_in>0)
00078     frequency=frequency_in;
00079   else
00080     if (node_ix==1)
00081       frequency=2490e6;
00082     else
00083       frequency=70e6;
00084  
00085     
00086     
00087   std::vector<four_multi_node*> all_my_nodes;
00088   std::vector<std::string> IP_addresses;
00089   block_fading ch_model;
00090 
00091 
00092   if (!(uhd::set_thread_priority_safe(1,true))) {
00093       std::cout << "Problem setting thread priority" << std::endl;
00094       return 1;
00095   };
00096 
00097 
00098   SISO_AMC_OFDM_node node(gain_rx,gain_tx,node_ix,frequency,false,
00099                           modulation_order,false,codec_ix,chase,delta_time); 
00100 
00101   gps_wait_until(dev_name.c_str(),start_time); // Make nodes start at
00102                                                // defined tine.
00103   node.run();
00104 
00105 
00106   if (node_ix==0) {
00107     cout << "BERraw=" << node.BERraw << std::endl;
00108     cout << "BER=" << node.BER << std::endl;
00109 
00110     it_file d1;
00111     d1.open("SISO_AMC_OFDM_realtime.it");
00112     d1<< Name("const") << node.symbols;
00113     d1<< Name("BERraw") << node.BERraw;
00114     d1<< Name("BER") << node.BER;
00115     d1.close();
00116 
00117 
00118   };
00119   
00120 
00121 
00122 
00123 
00124 
00125   return 0;
00126 
00127 };
 All Classes Functions Variables