diff options
author | Trung N Tran <trung.tran@ettus.com> | 2018-04-02 14:57:26 -0700 |
---|---|---|
committer | Martin Braun <martin.braun@ettus.com> | 2018-05-01 08:55:08 -0700 |
commit | bcad3f377c488df6a861caf98026adbeb84d7a2c (patch) | |
tree | 6e754d0c0b707d91b94e237cdcbf9ca4befd4f2b /host/lib | |
parent | da1117175663ed746aa5583856fd1a990a40385e (diff) | |
download | uhd-bcad3f377c488df6a861caf98026adbeb84d7a2c.tar.gz uhd-bcad3f377c488df6a861caf98026adbeb84d7a2c.tar.bz2 uhd-bcad3f377c488df6a861caf98026adbeb84d7a2c.zip |
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.
Diffstat (limited to 'host/lib')
-rw-r--r-- | host/lib/usrp/multi_usrp.cpp | 93 |
1 files changed, 78 insertions, 15 deletions
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 <uhd/property_tree.hpp> +#include <uhd/types/eeprom.hpp> #include <uhd/usrp/multi_usrp.hpp> #include <uhd/usrp/gpio_defs.hpp> #include <uhd/exception.hpp> @@ -409,38 +410,82 @@ public: dict<std::string, std::string> get_usrp_rx_info(size_t chan){ mboard_chan_pair mcp = rx_chan_to_mcp(chan); dict<std::string, std::string> usrp_info; - - mboard_eeprom_t mb_eeprom = _tree->access<mboard_eeprom_t>(mb_root(mcp.mboard) / "eeprom").get(); - dboard_eeprom_t db_eeprom = _tree->access<dboard_eeprom_t>(rx_rf_fe_root(chan).branch_path().branch_path() / "rx_eeprom").get(); - + const auto mb_eeprom = + _tree->access<mboard_eeprom_t>(mb_root(mcp.mboard) / "eeprom").get(); usrp_info["mboard_id"] = _tree->access<std::string>(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<std::string>(rx_rf_fe_root(chan) / "name").get(); usrp_info["rx_subdev_spec"] = _tree->access<subdev_spec_t>(mb_root(mcp.mboard) / "rx_subdev_spec").get().to_string(); - usrp_info["rx_serial"] = db_eeprom.serial; usrp_info["rx_antenna"] = _tree->access<std::string>(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<dboard_eeprom_t>( + 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_map_t>(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<std::string, std::string> get_usrp_tx_info(size_t chan){ mboard_chan_pair mcp = tx_chan_to_mcp(chan); dict<std::string, std::string> usrp_info; - - mboard_eeprom_t mb_eeprom = _tree->access<mboard_eeprom_t>(mb_root(mcp.mboard) / "eeprom").get(); - dboard_eeprom_t db_eeprom = _tree->access<dboard_eeprom_t>(tx_rf_fe_root(chan).branch_path().branch_path() / "tx_eeprom").get(); - + const auto mb_eeprom = + _tree->access<mboard_eeprom_t>(mb_root(mcp.mboard) / "eeprom").get(); usrp_info["mboard_id"] = _tree->access<std::string>(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<std::string>(tx_rf_fe_root(chan) / "name").get(); usrp_info["tx_subdev_spec"] = _tree->access<subdev_spec_t>(mb_root(mcp.mboard) / "tx_subdev_spec").get().to_string(); - usrp_info["tx_serial"] = db_eeprom.serial; usrp_info["tx_antenna"] = _tree->access<std::string>(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<dboard_eeprom_t>( + 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<eeprom_map_t>(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); |