From 1ade1f94cb5aaf038d4914fb5cece82f055b8f0e Mon Sep 17 00:00:00 2001 From: Josh Blum Date: Wed, 29 Jun 2011 13:02:42 -0700 Subject: uhd: implement prop tree usage in utils --- host/utils/usrp1_init_eeprom.cpp | 6 +++--- host/utils/usrp_burn_db_eeprom.cpp | 36 +++++++++++------------------------- host/utils/usrp_burn_mb_eeprom.cpp | 11 ++++------- 3 files changed, 18 insertions(+), 35 deletions(-) (limited to 'host/utils') diff --git a/host/utils/usrp1_init_eeprom.cpp b/host/utils/usrp1_init_eeprom.cpp index 39f091af4..5bc07daf6 100644 --- a/host/utils/usrp1_init_eeprom.cpp +++ b/host/utils/usrp1_init_eeprom.cpp @@ -17,7 +17,7 @@ #include #include -#include +#include #include #include #include @@ -65,8 +65,8 @@ int UHD_SAFE_MAIN(int argc, char *argv[]){ std::cout << "Writing EEPROM data..." << std::endl; //uhd::device_addrs_t devs = uhd::device::find(found_addrs[i]); uhd::device::sptr dev = uhd::device::make(found_addrs[i]); - wax::obj mb = (*dev)[uhd::usrp::DEVICE_PROP_MBOARD]; - mb[std::string("load_eeprom")] = vm["image"].as(); + uhd::property_tree::sptr tree = (*dev)[0].as(); + tree->access("/mboards/0/load_eeprom").set(vm["image"].as()); } diff --git a/host/utils/usrp_burn_db_eeprom.cpp b/host/utils/usrp_burn_db_eeprom.cpp index 58417bd68..7ebbe7756 100644 --- a/host/utils/usrp_burn_db_eeprom.cpp +++ b/host/utils/usrp_burn_db_eeprom.cpp @@ -20,10 +20,9 @@ #include #include #include +#include #include -#include -#include -#include +#include #include #include #include @@ -36,15 +35,6 @@ namespace po = boost::program_options; int UHD_SAFE_MAIN(int argc, char *argv[]){ //command line variables std::string args, slot, unit; - static const uhd::dict unit_to_db_prop = boost::assign::map_list_of - ("RX", MBOARD_PROP_RX_DBOARD) ("TX", MBOARD_PROP_TX_DBOARD) ("GDB", MBOARD_PROP_TX_DBOARD) - ; - static const uhd::dict unit_to_db_names_prop = boost::assign::map_list_of - ("RX", MBOARD_PROP_RX_DBOARD_NAMES) ("TX", MBOARD_PROP_TX_DBOARD_NAMES) ("GDB", MBOARD_PROP_TX_DBOARD_NAMES) - ; - static const uhd::dict unit_to_db_eeprom_prop = boost::assign::map_list_of - ("RX", DBOARD_PROP_DBOARD_EEPROM) ("TX", DBOARD_PROP_DBOARD_EEPROM) ("GDB", DBOARD_PROP_GBOARD_EEPROM) - ; po::options_description desc("Allowed options"); desc.add_options() @@ -70,34 +60,30 @@ int UHD_SAFE_MAIN(int argc, char *argv[]){ return ~0; } - //check inputs - if (not unit_to_db_prop.has_key(unit)){ - std::cout << "Error: specify RX or TX for unit" << std::endl; - return ~0; - } - //make the device and extract the dboard w/ property device::sptr dev = device::make(args); - uhd::prop_names_t dboard_names = (*dev)[DEVICE_PROP_MBOARD][unit_to_db_names_prop[unit]].as(); + uhd::property_tree::sptr tree = (*dev)[0].as(); + const uhd::property_tree::path_type db_root = "/mboards/0/dboards"; + std::vector dboard_names = tree->list(db_root); if (dboard_names.size() == 1 and slot.empty()) slot = dboard_names.front(); uhd::assert_has(dboard_names, slot, "dboard slot name"); - wax::obj dboard = (*dev)[DEVICE_PROP_MBOARD][named_prop_t(unit_to_db_prop[unit], slot)]; - std::string prefix = unit + ":" + slot; - std::cout << boost::format("Reading EEPROM on %s dboard...") % prefix << std::endl; - dboard_eeprom_t db_eeprom = dboard[unit_to_db_eeprom_prop[unit]].as(); + std::cout << boost::format("Reading %s EEPROM on %s dboard...") % unit % slot << std::endl; + boost::to_lower(unit); + const uhd::property_tree::path_type db_path = db_root / slot / (unit + "_eeprom"); + dboard_eeprom_t db_eeprom = tree->access(db_path).get(); //------------- handle the dboard ID -----------------------------// if (vm.count("id")){ db_eeprom.id = dboard_id_t::from_string(vm["id"].as()); - dboard[unit_to_db_eeprom_prop[unit]] = db_eeprom; + tree->access(db_path).set(db_eeprom); } std::cout << boost::format(" Current ID: %s") % db_eeprom.id.to_pp_string() << std::endl; //------------- handle the dboard serial--------------------------// if (vm.count("ser")){ db_eeprom.serial = vm["ser"].as(); - dboard[unit_to_db_eeprom_prop[unit]] = db_eeprom; + tree->access(db_path).set(db_eeprom); } std::cout << boost::format(" Current serial: \"%s\"") % db_eeprom.serial << std::endl; diff --git a/host/utils/usrp_burn_mb_eeprom.cpp b/host/utils/usrp_burn_mb_eeprom.cpp index 20e1b58b1..9f2fa611a 100644 --- a/host/utils/usrp_burn_mb_eeprom.cpp +++ b/host/utils/usrp_burn_mb_eeprom.cpp @@ -17,8 +17,7 @@ #include #include -#include -#include +#include #include #include #include @@ -53,14 +52,12 @@ int UHD_SAFE_MAIN(int argc, char *argv[]){ std::cout << "Creating USRP device from address: " + args << std::endl; uhd::device::sptr dev = uhd::device::make(args); - //FIXME the default mboard for now (may be others) - wax::obj mboard = (*dev)[uhd::usrp::DEVICE_PROP_MBOARD]; + uhd::property_tree::sptr tree = (*dev)[0].as(); std::cout << std::endl; if (true /*always readback*/){ std::cout << "Fetching current settings from EEPROM..." << std::endl; - uhd::usrp::mboard_eeprom_t mb_eeprom = \ - mboard[uhd::usrp::MBOARD_PROP_EEPROM_MAP].as(); + uhd::usrp::mboard_eeprom_t mb_eeprom = tree->access("/mboards/0/eeprom").get(); if (not mb_eeprom.has_key(key)){ std::cerr << boost::format("Cannot find value for EEPROM[%s]") % key << std::endl; return ~0; @@ -71,7 +68,7 @@ int UHD_SAFE_MAIN(int argc, char *argv[]){ if (vm.count("val")){ uhd::usrp::mboard_eeprom_t mb_eeprom; mb_eeprom[key] = val; std::cout << boost::format("Setting EEPROM [\"%s\"] to \"%s\"...") % key % val << std::endl; - mboard[uhd::usrp::MBOARD_PROP_EEPROM_MAP] = mb_eeprom; + tree->access("/mboards/0/eeprom").set(mb_eeprom); std::cout << "Power-cycle the USRP device for the changes to take effect." << std::endl; std::cout << std::endl; } -- cgit v1.2.3