diff options
-rw-r--r-- | host/include/uhd/types/eeprom.hpp | 20 | ||||
-rw-r--r-- | host/lib/usrp/mpmd/mpmd_impl.cpp | 25 | ||||
-rw-r--r-- | mpm/python/usrp_mpm/dboard_manager/base.py | 6 | ||||
-rw-r--r-- | mpm/python/usrp_mpm/periph_manager/base.py | 26 |
4 files changed, 71 insertions, 6 deletions
diff --git a/host/include/uhd/types/eeprom.hpp b/host/include/uhd/types/eeprom.hpp new file mode 100644 index 000000000..814d429c8 --- /dev/null +++ b/host/include/uhd/types/eeprom.hpp @@ -0,0 +1,20 @@ +// +// Copyright 2017 Ettus Research (National Instruments Corp.) +// +// SPDX-License-Identifier: GPL-3.0 +// + +#ifndef INCLUDED_UHD_EEPROM_HPP +#define INCLUDED_UHD_EEPROM_HPP + +#include <map> +#include <string> + +namespace uhd { + + typedef std::map<std::string, std::string> eeprom_map_t; + + +} /* namespace uhd */ + +#endif /* INCLUDED_UHD_EEPROM_HPP */ diff --git a/host/lib/usrp/mpmd/mpmd_impl.cpp b/host/lib/usrp/mpmd/mpmd_impl.cpp index 1b22ed294..965ede6f5 100644 --- a/host/lib/usrp/mpmd/mpmd_impl.cpp +++ b/host/lib/usrp/mpmd/mpmd_impl.cpp @@ -26,6 +26,8 @@ #include <uhd/utils/static.hpp> #include <uhd/utils/tasks.hpp> #include <uhd/types/sensors.hpp> +#include <uhd/types/eeprom.hpp> +#include <uhd/usrp/mboard_eeprom.hpp> #include <boost/algorithm/string.hpp> #include <boost/asio.hpp> #include <boost/make_shared.hpp> @@ -128,6 +130,27 @@ namespace { }) ; } + + /*** EEPROM *********************************************************/ + tree->create<uhd::usrp::mboard_eeprom_t>(mb_path / "eeprom") + .add_coerced_subscriber([mb](const uhd::usrp::mboard_eeprom_t& mb_eeprom){ + eeprom_map_t eeprom_map; + for (const auto& key : mb_eeprom.keys()) { + eeprom_map[key] = mb_eeprom[key]; + } + mb->rpc->notify_with_token("set_mb_eeprom", eeprom_map); + }) + .set_publisher([mb](){ + auto mb_eeprom = + mb->rpc->request_with_token<std::map<std::string, std::string>>( + "get_mb_eeprom" + ); + uhd::usrp::mboard_eeprom_t mb_eeprom_dict( + mb_eeprom.cbegin(), mb_eeprom.cend() + ); + return mb_eeprom_dict; + }) + ; } void reset_time_synchronized(uhd::property_tree::sptr tree) @@ -284,8 +307,6 @@ mpmd_mboard_impl::uptr mpmd_impl::setup_mb( // query more information about FPGA/MPM - // Call init on periph_manager, this will init the dboards/mboard, maybe - // even selfcal and everything // Query time/clock sources on mboards/dboards // Throw rpc calls with boost bind into the property tree? diff --git a/mpm/python/usrp_mpm/dboard_manager/base.py b/mpm/python/usrp_mpm/dboard_manager/base.py index b87033860..cf3510abf 100644 --- a/mpm/python/usrp_mpm/dboard_manager/base.py +++ b/mpm/python/usrp_mpm/dboard_manager/base.py @@ -134,8 +134,8 @@ class DboardManagerBase(object): format. """ callback_map = \ - rx_sensor_callback_map if direction.lower() == 'rx' \ - else tx_sensor_callback_map + self.rx_sensor_callback_map if direction.lower() == 'rx' \ + else self.tx_sensor_callback_map if sensor_name not in callback_map: error_msg = "Was asked for non-existent sensor `{}'.".format( sensor_name @@ -143,6 +143,6 @@ class DboardManagerBase(object): self.log.error(error_msg) raise RuntimeError(error_msg) return getattr( - self, self.callback_map.get('sensor_name') + self, callback_map.get('sensor_name') )() diff --git a/mpm/python/usrp_mpm/periph_manager/base.py b/mpm/python/usrp_mpm/periph_manager/base.py index 72066b9ef..dc52b3a1b 100644 --- a/mpm/python/usrp_mpm/periph_manager/base.py +++ b/mpm/python/usrp_mpm/periph_manager/base.py @@ -174,7 +174,7 @@ class PeriphManagerBase(object): ) self.log.trace("Found EEPROM metadata: `{}'".format(str(self._eeprom_head))) self.log.trace("Read {} bytes of EEPROM data.".format(len(self._eeprom_rawdata))) - for key in ('pid', 'serial', 'rev'): + for key in ('pid', 'serial', 'rev', 'eeprom_version'): # In C++, we can only handle dicts if all the values are of the # same type. So we must convert them all to strings here: try: @@ -464,6 +464,9 @@ class PeriphManagerBase(object): xbar_file.write(laddr_value) return True + ########################################################################## + # Mboard Sensors + ########################################################################## def get_mb_sensors(self): """ Return a list of sensor names. @@ -499,3 +502,24 @@ class PeriphManagerBase(object): self, self.mboard_sensor_callback_map.get(sensor_name) )() + ########################################################################## + # EEPROMS + ########################################################################## + def get_mb_eeprom(self): + """ + Return a dictionary with EEPROM contents + + All key/value pairs are string -> string + """ + return {k: str(v) for k, v in iteritems(self._eeprom_head)} + + def set_mb_eeprom(self, eeprom_vals): + """ + eeprom_vals is a dictionary (string -> string) + + By default, we do nothing. Writing EEPROMs is highly device specific + and is thus defined in the individual device classes. + """ + self.log.warn("Called set_mb_eeprom(), but not implemented!") + raise NotImplementedError + |