Changeset e9df566 in WISERD


Ignore:
Timestamp:
09/08/15 13:56:31 (2 years ago)
Author:
Dragoslav Stojadinovic <stojadin@…>
Branches:
master
Parents:
976dce0
Message:

Radio selection option added, bug fixes

Files:
2 added
1 edited

Legend:

Unmodified
Added
Removed
  • main.cpp

    r6e01477 re9df566  
    2424#include "radio.h" 
    2525#include "usrp.h" 
     26#include "zynq.h" 
    2627#include "recv.h" 
    2728#include "tran.h" 
     
    307308  // Configure the logger 
    308309  //log4cxx::PropertyConfigurator::configure("./logconf.prop"); 
    309   log4cxx::FileAppender *fileAppender = new log4cxx::FileAppender(log4cxx::LayoutPtr(new log4cxx::SimpleLayout()), "/var/log/usrpd.log", false); 
     310  log4cxx::FileAppender *fileAppender = new log4cxx::FileAppender(log4cxx::LayoutPtr(new log4cxx::SimpleLayout()), "/var/log/wiserd.log", false); 
    310311  log4cxx::helpers::Pool p; 
    311312  fileAppender->activateOptions(p); 
    312313  log4cxx::BasicConfigurator::configure(log4cxx::AppenderPtr(fileAppender)); 
    313314  log4cxx::Logger::getRootLogger()->setLevel(log4cxx::Level::getDebug()); 
    314   log4cxx::LoggerPtr logger = log4cxx::Logger::getLogger("usrpd"); 
    315  
    316   Usrp radio_module(logger); 
    317   Recv receiver_module(&radio_module, logger); 
    318   Tran transmitter_module(&radio_module, logger); 
     315  log4cxx::LoggerPtr logger = log4cxx::Logger::getLogger("wiserd"); 
     316 
     317  std::unordered_map<std::string, std::string> params; 
     318   
     319  po::options_description desc("Allowed options"); 
     320  desc.add_options() 
     321    ("radio", po::value<std::string>(), "Select a radio module ('usrp' - default, 'zynq')") 
     322    ; 
     323  po::variables_map vm; 
     324  po::store(po::command_line_parser(argc, argv).options(desc).allow_unregistered().run(), vm); 
     325  po::notify(vm); 
     326 
     327  Radio *radio_module; 
     328  if (vm.count("radio")) { 
     329    if (vm["radio"].as<std::string>() == "usrp") { 
     330      radio_module = new Usrp(logger); 
     331    } else if (vm["radio"].as<std::string>() == "zynq") { 
     332      radio_module = new Zynq(logger); 
     333    } else { 
     334      radio_module = new Usrp(logger); 
     335    } 
     336  } else { 
     337    radio_module = new Usrp(logger); 
     338  } 
     339  Recv receiver_module(radio_module, logger); 
     340  Tran transmitter_module(radio_module, logger); 
    319341 
    320342  //setup the program options 
     
    323345    request = request + std::string(argv[i]) + " "; 
    324346  } 
    325   std::string response = CommandParse(request, &radio_module, &receiver_module, &transmitter_module, logger); 
     347  std::string response = CommandParse(request, radio_module, &receiver_module, &transmitter_module, logger); 
    326348  std::cout << response << std::endl; 
    327349 
    328350  port_number = BasePortNumber; 
    329351  base_port = boost::lexical_cast<int>(port_number); 
    330   boost::thread cmds(CommandServer, base_port, &radio_module, &receiver_module, &transmitter_module, logger); 
    331   boost::thread cmdl(CommandLine, &radio_module, &receiver_module, &transmitter_module, logger); 
     352  boost::thread cmds(CommandServer, base_port, radio_module, &receiver_module, &transmitter_module, logger); 
     353  boost::thread cmdl(CommandLine, radio_module, &receiver_module, &transmitter_module, logger); 
    332354  std::cout << "Ready!" << std::endl; 
    333355  cmds.join(); 
Note: See TracChangeset for help on using the changeset viewer.