From bcad3f377c488df6a861caf98026adbeb84d7a2c Mon Sep 17 00:00:00 2001 From: Trung N Tran Date: Mon, 2 Apr 2018 14:57:26 -0700 Subject: multi_usrp: Update get_usrp_?x_info() In MPM devices, daughterboard EEPROMs now use eeprom_map_t instead of dboard_eeprom_t. The eeprom also is under rfnoc path. This change will allow ?x_info() to reach that rfnoc path and pull information from the new eeprom_map_t. --- host/lib/usrp/multi_usrp.cpp | 93 +++++++++++++++++++++++++++++++++++++------- 1 file changed, 78 insertions(+), 15 deletions(-) (limited to 'host/lib/usrp/multi_usrp.cpp') diff --git a/host/lib/usrp/multi_usrp.cpp b/host/lib/usrp/multi_usrp.cpp index 6c758e07e..2a3e2e80f 100644 --- a/host/lib/usrp/multi_usrp.cpp +++ b/host/lib/usrp/multi_usrp.cpp @@ -6,6 +6,7 @@ // #include +#include #include #include #include @@ -409,38 +410,82 @@ public: dict get_usrp_rx_info(size_t chan){ mboard_chan_pair mcp = rx_chan_to_mcp(chan); dict usrp_info; - - mboard_eeprom_t mb_eeprom = _tree->access(mb_root(mcp.mboard) / "eeprom").get(); - dboard_eeprom_t db_eeprom = _tree->access(rx_rf_fe_root(chan).branch_path().branch_path() / "rx_eeprom").get(); - + const auto mb_eeprom = + _tree->access(mb_root(mcp.mboard) / "eeprom").get(); usrp_info["mboard_id"] = _tree->access(mb_root(mcp.mboard) / "name").get(); - usrp_info["mboard_name"] = mb_eeprom["name"]; + usrp_info["mboard_name"] = mb_eeprom.get("name", "n/a"); usrp_info["mboard_serial"] = mb_eeprom["serial"]; - usrp_info["rx_id"] = db_eeprom.id.to_pp_string(); usrp_info["rx_subdev_name"] = _tree->access(rx_rf_fe_root(chan) / "name").get(); usrp_info["rx_subdev_spec"] = _tree->access(mb_root(mcp.mboard) / "rx_subdev_spec").get().to_string(); - usrp_info["rx_serial"] = db_eeprom.serial; usrp_info["rx_antenna"] = _tree->access(rx_rf_fe_root(chan) / "antenna" / "value").get(); - + if (_tree->exists(rx_rf_fe_root(chan).branch_path().branch_path() / "rx_eeprom")) { + const auto db_eeprom = + _tree->access( + rx_rf_fe_root(chan).branch_path().branch_path() + / "rx_eeprom" + ).get(); + usrp_info["rx_serial"] = db_eeprom.serial; + usrp_info["rx_id"] = db_eeprom.id.to_pp_string(); + } + const auto rfnoc_path = mb_root(mcp.mboard) / "xbar"; + if (_tree->exists(rfnoc_path)) { + const auto spec = get_rx_subdev_spec(mcp.mboard).at(mcp.chan); + const auto radio_index = get_radio_index(spec.db_name); + const auto radio_path = rfnoc_path / str(boost::format("Radio_%d") % radio_index); + const auto eeprom_path = radio_path / "eeprom"; + if (_tree->exists(radio_path)) { + const auto db_eeprom = _tree->access(eeprom_path).get(); + usrp_info["rx_serial"] = db_eeprom.count("serial") ? + std::string(db_eeprom.at("serial").begin(), db_eeprom.at("serial").end()) + : "n/a" + ; + usrp_info["rx_id"] = db_eeprom.count("pid") ? + std::string(db_eeprom.at("pid").begin(), db_eeprom.at("pid").end()) + : "n/a" + ; + } + } return usrp_info; } dict get_usrp_tx_info(size_t chan){ mboard_chan_pair mcp = tx_chan_to_mcp(chan); dict usrp_info; - - mboard_eeprom_t mb_eeprom = _tree->access(mb_root(mcp.mboard) / "eeprom").get(); - dboard_eeprom_t db_eeprom = _tree->access(tx_rf_fe_root(chan).branch_path().branch_path() / "tx_eeprom").get(); - + const auto mb_eeprom = + _tree->access(mb_root(mcp.mboard) / "eeprom").get(); usrp_info["mboard_id"] = _tree->access(mb_root(mcp.mboard) / "name").get(); usrp_info["mboard_name"] = mb_eeprom["name"]; usrp_info["mboard_serial"] = mb_eeprom["serial"]; - usrp_info["tx_id"] = db_eeprom.id.to_pp_string(); usrp_info["tx_subdev_name"] = _tree->access(tx_rf_fe_root(chan) / "name").get(); usrp_info["tx_subdev_spec"] = _tree->access(mb_root(mcp.mboard) / "tx_subdev_spec").get().to_string(); - usrp_info["tx_serial"] = db_eeprom.serial; usrp_info["tx_antenna"] = _tree->access(tx_rf_fe_root(chan) / "antenna" / "value").get(); - + if (_tree->exists(tx_rf_fe_root(chan).branch_path().branch_path() / "tx_eeprom")) { + const auto db_eeprom = + _tree->access( + tx_rf_fe_root(chan).branch_path().branch_path() + / "tx_eeprom" + ).get(); + usrp_info["tx_serial"] = db_eeprom.serial; + usrp_info["tx_id"] = db_eeprom.id.to_pp_string(); + } + const auto rfnoc_path = mb_root(mcp.mboard) / "xbar"; + if (_tree->exists(rfnoc_path)) { + const auto spec = get_tx_subdev_spec(mcp.mboard).at(mcp.chan); + const auto radio_index = get_radio_index(spec.db_name); + const auto radio_path = rfnoc_path / str(boost::format("Radio_%d")%radio_index); + const auto path = radio_path / "eeprom"; + if(_tree->exists(radio_path)) { + const auto db_eeprom = _tree->access(path).get(); + usrp_info["tx_serial"] = db_eeprom.count("serial") ? + std::string(db_eeprom.at("serial").begin(), db_eeprom.at("serial").end()) + : "n/a" + ; + usrp_info["tx_id"] = db_eeprom.count("pid") ? + std::string(db_eeprom.at("pid").begin(), db_eeprom.at("pid").end()) + : "n/a" + ; + } + } return usrp_info; } @@ -2382,6 +2427,24 @@ private: } } + size_t get_radio_index(const std::string slot_name) + { + if (slot_name == "A") { + return 0; + } else if (slot_name == "B") { + return 1; + } else if (slot_name == "C") { + return 2; + } else if (slot_name == "D") { + return 3; + } else { + throw uhd::key_error(str( + boost::format("[multi_usrp]: radio slot name %s out of supported range.") + % slot_name + )); + } + } + fs_path rx_rf_fe_root(const size_t chan) { mboard_chan_pair mcp = rx_chan_to_mcp(chan); -- cgit v1.2.3