// // Copyright 2020 Ettus Research, a National Instruments Brand // // SPDX-License-Identifier: GPL-3.0-or-later // #include #include #include #include #include #include #include #include namespace po = boost::program_options; using namespace uhd; /**************************************************************************** * main ***************************************************************************/ int UHD_SAFE_MAIN(int argc, char* argv[]) { po::options_description desc("Allowed options"); // clang-format off desc.add_options() ("help", "help message") ("version", "print the version string and exit") ("args", po::value()->default_value(""), "device address args") ; // clang-format on 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 << "UHD ADC self calibration " << desc << std::endl; return EXIT_FAILURE; } if (vm.count("version")) { std::cout << uhd::get_version_string() << std::endl; return EXIT_SUCCESS; } rfnoc::rfnoc_graph::sptr graph = rfnoc::rfnoc_graph::make(vm["args"].as()); size_t num_calibrations = 0; for (auto radio_id : graph->find_blocks("Radio")) { auto radio_blk = graph->get_block(radio_id); if (radio_blk->has_feature()) { auto& feature = radio_blk->get_feature(); // Run it on all channels const size_t num_channels = radio_blk->get_num_output_ports(); for (size_t i = 0; i < num_channels; i++) { std::cout << "Calibrating on channel " << i << " of " << radio_id << "..." << std::endl; feature.run(i); std::cout << "Finished!" << std::endl; num_calibrations++; } } } if (num_calibrations > 0) { std::cout << "Calibrated " << num_calibrations << " channels" << std::endl; } else { std::cerr << "WARNING: Did not find any channels to calibrate!" << std::endl; } return EXIT_SUCCESS; }