uhd/host/examples/init_usrp/init_usrp.cpp

51 lines
1.5 KiB
C++
Raw Normal View History

2014-09-25 23:01:05 +00:00
//
// Copyright 2014 Ettus Research LLC
// Copyright 2018 Ettus Research, a National Instruments Company
2014-09-25 23:01:05 +00:00
//
// SPDX-License-Identifier: GPL-3.0-or-later
2014-09-25 23:01:05 +00:00
//
// This tiny program is meant as an example on how to set up UHD
// projects using CMake.
// The program itself only initializes a USRP. For more elaborate examples,
// have a look at the files in host/examples/.
#include <uhd/usrp/multi_usrp.hpp>
#include <uhd/utils/safe_main.hpp>
#include <uhd/utils/thread.hpp>
2014-09-25 23:01:05 +00:00
#include <boost/format.hpp>
#include <boost/program_options.hpp>
2014-09-25 23:01:05 +00:00
#include <iostream>
namespace po = boost::program_options;
int UHD_SAFE_MAIN(int argc, char* argv[])
{
// variables to be set by po
2014-09-25 23:01:05 +00:00
std::string args;
// setup the program options
2014-09-25 23:01:05 +00:00
po::options_description desc("Allowed options");
desc.add_options()("help", "help message")("args",
po::value<std::string>(&args)->default_value(""),
"multi uhd device address args");
2014-09-25 23:01:05 +00:00
po::variables_map vm;
po::store(po::parse_command_line(argc, argv, desc), vm);
po::notify(vm);
// print the help message
if (vm.count("help")) {
std::cout << boost::format("Mini-example to initialize a USRP (args==%s).") % args
<< std::endl;
2014-09-25 23:01:05 +00:00
return ~0;
}
// create a usrp device
2014-09-25 23:01:05 +00:00
std::cout << std::endl;
std::cout << boost::format("Creating the usrp device with: %s...") % args
<< std::endl;
2014-09-25 23:01:05 +00:00
uhd::usrp::multi_usrp::sptr usrp = uhd::usrp::multi_usrp::make(args);
return EXIT_SUCCESS;
}