diff options
Diffstat (limited to 'host/utils')
-rw-r--r-- | host/utils/query_gpsdo_sensors.cpp | 3 | ||||
-rw-r--r-- | host/utils/uhd_cal_rx_iq_balance.cpp | 5 | ||||
-rw-r--r-- | host/utils/uhd_cal_tx_dc_offset.cpp | 5 | ||||
-rw-r--r-- | host/utils/uhd_cal_tx_iq_balance.cpp | 5 | ||||
-rw-r--r-- | host/utils/uhd_images_downloader.py.in | 115 | ||||
-rw-r--r-- | host/utils/usrp_cal_utils.hpp | 28 | ||||
-rw-r--r-- | host/utils/usrp_n2xx_simple_net_burner.cpp | 8 |
7 files changed, 106 insertions, 63 deletions
diff --git a/host/utils/query_gpsdo_sensors.cpp b/host/utils/query_gpsdo_sensors.cpp index d459fd0ec..de6bdcd72 100644 --- a/host/utils/query_gpsdo_sensors.cpp +++ b/host/utils/query_gpsdo_sensors.cpp @@ -100,13 +100,14 @@ int UHD_SAFE_MAIN(int argc, char *argv[]){ std::cout << boost::format("ref_locked sensor not present on this board.\n"); //Check PPS and compare UHD device time to GPS time + boost::this_thread::sleep(boost::posix_time::seconds(1)); uhd::sensor_value_t gps_time = usrp->get_mboard_sensor("gps_time"); const uhd::time_spec_t last_pps_time = usrp->get_time_last_pps(); if (last_pps_time.get_full_secs() == gps_time.to_int()) { std::cout << boost::format("GPS and UHD Device time are aligned.\n"); } else std::cout << boost::format("\nGPS and UHD Device time are NOT aligned. Try re-running the program. Double check 1 PPS connection from GPSDO.\n\n"); - + //print NMEA strings std::cout << boost::format("Printing available NMEA strings:\n"); uhd::sensor_value_t gga_string = usrp->get_mboard_sensor("gps_gpgga"); diff --git a/host/utils/uhd_cal_rx_iq_balance.cpp b/host/utils/uhd_cal_rx_iq_balance.cpp index ab951b754..5fb494114 100644 --- a/host/utils/uhd_cal_rx_iq_balance.cpp +++ b/host/utils/uhd_cal_rx_iq_balance.cpp @@ -1,5 +1,5 @@ // -// Copyright 2010 Ettus Research LLC +// Copyright 2010,2012 Ettus Research LLC // // This program is free software: you can redistribute it and/or modify // it under the terms of the GNU General Public License as published by @@ -136,6 +136,9 @@ int UHD_SAFE_MAIN(int argc, char *argv[]){ usrp->set_rx_antenna("CAL"); usrp->set_tx_antenna("CAL"); + //fail if daughterboard has no serial + check_for_empty_serial(usrp, "RX", "rx", args); + //set optimum defaults set_optimum_defaults(usrp); diff --git a/host/utils/uhd_cal_tx_dc_offset.cpp b/host/utils/uhd_cal_tx_dc_offset.cpp index 152f61918..c9cf757f4 100644 --- a/host/utils/uhd_cal_tx_dc_offset.cpp +++ b/host/utils/uhd_cal_tx_dc_offset.cpp @@ -1,5 +1,5 @@ // -// Copyright 2010 Ettus Research LLC +// Copyright 2010,2012 Ettus Research LLC // // This program is free software: you can redistribute it and/or modify // it under the terms of the GNU General Public License as published by @@ -138,6 +138,9 @@ int UHD_SAFE_MAIN(int argc, char *argv[]){ usrp->set_rx_antenna("CAL"); usrp->set_tx_antenna("CAL"); + //fail if daughterboard has no serial + check_for_empty_serial(usrp, "TX", "tx", args); + //set optimum defaults set_optimum_defaults(usrp); diff --git a/host/utils/uhd_cal_tx_iq_balance.cpp b/host/utils/uhd_cal_tx_iq_balance.cpp index 4c8642660..20d018edf 100644 --- a/host/utils/uhd_cal_tx_iq_balance.cpp +++ b/host/utils/uhd_cal_tx_iq_balance.cpp @@ -1,5 +1,5 @@ // -// Copyright 2010 Ettus Research LLC +// Copyright 2010,2012 Ettus Research LLC // // This program is free software: you can redistribute it and/or modify // it under the terms of the GNU General Public License as published by @@ -139,6 +139,9 @@ int UHD_SAFE_MAIN(int argc, char *argv[]){ usrp->set_rx_antenna("CAL"); usrp->set_tx_antenna("CAL"); + //fail if daughterboard has no serial + check_for_empty_serial(usrp, "TX", "tx", args); + //set optimum defaults set_optimum_defaults(usrp); diff --git a/host/utils/uhd_images_downloader.py.in b/host/utils/uhd_images_downloader.py.in index 59c0fbafe..8c8d2df81 100644 --- a/host/utils/uhd_images_downloader.py.in +++ b/host/utils/uhd_images_downloader.py.in @@ -26,11 +26,19 @@ import tempfile import urllib2 import zipfile +class temp_dir(): + + def __enter__(self): + self.name = tempfile.mkdtemp() + return self.name + def __exit__(self, type, value, traceback): + os.removedirs(self.name) + if __name__ == "__main__": #Command line options parser = OptionParser() - parser.add_option("--install-location", type="string", default="@CMAKE_INSTALL_PREFIX@/share/uhd/images", help="Set custom install location for images, [default=%default]") + parser.add_option("--install-location", type="string", default="", help="Set custom install location for images") parser.add_option("--buffer-size", type="int", default=8192, help="Set download buffer size, [default=%default]",) (options, args) = parser.parse_args() @@ -38,65 +46,64 @@ if __name__ == "__main__": images_src = "@UHD_IMAGES_DOWNLOAD_SRC@" filename = images_src.split("/")[-1] - #Create temporary directory - download_dir = tempfile.mkdtemp() - atexit.register(lambda: shutil.rmtree(download_dir)) - - #Make sure we download into the correct directory - os.chdir(download_dir) + with temp_dir() as dirname: + os.chdir(dirname) - #Configuring image destination - if options.install_location != "": - images_dir = options.install_location - else: - images_dir = "@CMAKE_INSTALL_PREFIX@/share/uhd/images" - - u = urllib2.urlopen(images_src) - f = open(filename, "wb") - meta = u.info() - filesize = float(meta.getheaders("Content-Length")[0]) - - print "Downloading images from: %s" % images_src - - filesize_dl = 0.0 + #Configuring image destination + if options.install_location != "": + images_dir = options.install_location + elif os.environ.get("UHD_IMAGES_DIR") != "" and os.environ.get("UHD_IMAGES_DIR") != None: + images_dir = os.environ.get("UHD_IMAGES_DIR") + else: + images_dir = "@CMAKE_INSTALL_PREFIX@/share/uhd/images" + + u = urllib2.urlopen(images_src) + f = open(filename, "wb") + meta = u.info() + filesize = float(meta.getheaders("Content-Length")[0]) + + print "Downloading images from: %s" % images_src + + filesize_dl = 0.0 - #Downloading file - while True: - buffer = u.read(options.buffer_size) - if not buffer: - break - - filesize_dl -= len(buffer) - f.write(buffer) + #Downloading file + while True: + buffer = u.read(options.buffer_size) + if not buffer: + break + + filesize_dl -= len(buffer) + f.write(buffer) - status = r"%2.2f MB/%2.2f MB (%3.2f" % (-filesize_dl/1e6, filesize/1e6, (-filesize_dl*100.)/filesize) + r"%)" - status += chr(8)*(len(status)+1) - print status, - - f.close() + status = r"%2.2f MB/%2.2f MB (%3.2f" % (-filesize_dl/1e6, filesize/1e6, (-filesize_dl*100.)/filesize) + r"%)" + status += chr(8)*(len(status)+1) + print status, + + f.close() - #Extracting contents of zip file - if os.path.exists("tempdir"): - shutil.rmtree("tempdir") - os.mkdir("tempdir") + #Extracting contents of zip file + if os.path.exists("tempdir"): + shutil.rmtree("tempdir") + os.mkdir("tempdir") - images_zip = zipfile.ZipFile(filename) - images_zip.extractall("tempdir") + images_zip = zipfile.ZipFile(filename) + images_zip.extractall("tempdir") - #Removing images currently in images_dir - if os.path.exists(images_dir): - try: - shutil.rmtree(images_dir) - except: - sys.stderr.write("\nMake sure you have write permissions in the images directory.\n") - sys.exit(0) + #Removing images currently in images_dir + if os.path.exists(images_dir): + try: + shutil.rmtree(images_dir) + except: + sys.stderr.write("\nMake sure you have write permissions in the images directory.\n") + sys.exit(0) - #Copying downloaded images into images_dir - shutil.copytree("tempdir/%s/share/uhd/images" % filename[:-4],images_dir) + #Copying downloaded images into images_dir + shutil.copytree("tempdir/%s/share/uhd/images" % filename[:-4],images_dir) - #Removing tempdir and zip file - shutil.rmtree("tempdir") - images_zip.close() - os.remove(filename) + #Removing tempdir and zip file + shutil.rmtree("tempdir") + images_zip.close() + os.remove(filename) - print "\nImages successfully installed to: %s" % images_dir + os.chdir(images_dir) + print "\nImages successfully installed to: %s" % images_dir diff --git a/host/utils/usrp_cal_utils.hpp b/host/utils/usrp_cal_utils.hpp index 364b68bbe..4a2303d34 100644 --- a/host/utils/usrp_cal_utils.hpp +++ b/host/utils/usrp_cal_utils.hpp @@ -19,11 +19,14 @@ #include <uhd/property_tree.hpp> #include <uhd/usrp/multi_usrp.hpp> #include <uhd/usrp/dboard_eeprom.hpp> +#include <uhd/utils/paths.hpp> #include <boost/filesystem.hpp> +#include <boost/format.hpp> #include <iostream> #include <vector> #include <complex> #include <cmath> +#include <cstdlib> #include <fstream> namespace fs = boost::filesystem; @@ -99,6 +102,30 @@ static inline void set_optimum_defaults(uhd::usrp::multi_usrp::sptr usrp){ } /*********************************************************************** + * Check for empty serial + **********************************************************************/ + +void check_for_empty_serial( + uhd::usrp::multi_usrp::sptr usrp, + std::string XX, + std::string xx, + std::string uhd_args +){ + + //extract eeprom + uhd::property_tree::sptr tree = usrp->get_device()->get_tree(); + const uhd::fs_path db_path = "/mboards/0/dboards/A/" + xx + "_eeprom"; + const uhd::usrp::dboard_eeprom_t db_eeprom = tree->access<uhd::usrp::dboard_eeprom_t>(db_path).get(); + + std::string args_str = ""; + if(uhd_args != "") args_str = str(boost::format(" --args=%s") % uhd_args); + + std::string error_string = str(boost::format("This %s dboard has no serial!\n\nPlease see the Calibration documentation for details on how to fix this.") % XX); + + if (db_eeprom.serial.empty()) throw std::runtime_error(error_string); +} + +/*********************************************************************** * Sinusoid wave table **********************************************************************/ class wave_table{ @@ -160,7 +187,6 @@ static void store_results( uhd::property_tree::sptr tree = usrp->get_device()->get_tree(); const uhd::fs_path db_path = "/mboards/0/dboards/A/" + xx + "_eeprom"; const uhd::usrp::dboard_eeprom_t db_eeprom = tree->access<uhd::usrp::dboard_eeprom_t>(db_path).get(); - if (db_eeprom.serial.empty()) throw std::runtime_error(XX + " dboard has empty serial!"); //make the calibration file path fs::path cal_data_path = fs::path(uhd::get_app_path()) / ".uhd"; diff --git a/host/utils/usrp_n2xx_simple_net_burner.cpp b/host/utils/usrp_n2xx_simple_net_burner.cpp index ce2e9a9fc..901842538 100644 --- a/host/utils/usrp_n2xx_simple_net_burner.cpp +++ b/host/utils/usrp_n2xx_simple_net_burner.cpp @@ -502,13 +502,13 @@ int UHD_SAFE_MAIN(int argc, char *argv[]){ } //Prompt user to reset USRP - std::string user_response = ""; + std::string user_response = "foo"; bool reset = false; - while(user_response != "yes" and user_response != "no" and user_response != "y" and user_response != "n"){ - std::cout << std::endl << "Image burning successful. Reset USRP (yes/no)? "; + while(user_response != "y" and user_response != "" and user_response != "n"){ + std::cout << std::endl << "Image burning successful. Reset USRP (Y/n)? "; std::getline(std::cin, user_response); std::transform(user_response.begin(), user_response.end(), user_response.begin(), ::tolower); - reset = (user_response == "yes" or user_response == "y"); + reset = (user_response == "" or user_response == "y"); } std::cout << std::endl; //Formatting if(reset) reset_usrp(udp_transport); |