diff options
author | Martin Braun <martin.braun@ettus.com> | 2017-11-20 21:36:55 -0800 |
---|---|---|
committer | Martin Braun <martin.braun@ettus.com> | 2017-12-22 15:05:07 -0800 |
commit | 59ecec43d4120e0b8e5d5d6ede1c673b5575a14f (patch) | |
tree | 999ef41f50139634e4a94f4a43c8c897d97d3d17 /host | |
parent | b14cafd90c84e69cdb77aec2d8553c4d45213b8f (diff) | |
download | uhd-59ecec43d4120e0b8e5d5d6ede1c673b5575a14f.tar.gz uhd-59ecec43d4120e0b8e5d5d6ede1c673b5575a14f.tar.bz2 uhd-59ecec43d4120e0b8e5d5d6ede1c673b5575a14f.zip |
mg: Init dboard sensors via MPM
Reviewed-By: Steven Bingler <steven.bingler@ni.com>
Reviewed-By: Trung Tran <trung.tran@ettus.com>
Diffstat (limited to 'host')
3 files changed, 39 insertions, 9 deletions
diff --git a/host/lib/usrp/dboard/magnesium/magnesium_radio_ctrl_impl.cpp b/host/lib/usrp/dboard/magnesium/magnesium_radio_ctrl_impl.cpp index 290c5f541..8b722e725 100644 --- a/host/lib/usrp/dboard/magnesium/magnesium_radio_ctrl_impl.cpp +++ b/host/lib/usrp/dboard/magnesium/magnesium_radio_ctrl_impl.cpp @@ -414,17 +414,10 @@ void magnesium_radio_ctrl_impl::set_rpc_client( }) ; - // Sensors + // Init sensors for (const auto &dir : std::vector<direction_t>{RX_DIRECTION, TX_DIRECTION}) { for (size_t chan_idx = 0; chan_idx < 1 /* num channels FIXME */; chan_idx++) { - const fs_path fe_path = - fs_path("dboards") / - _radio_slot / - (dir == RX_DIRECTION ? "rx_frontends" : "tx_frontends") / - chan_idx; - UHD_LOG_TRACE(unique_id(), - "Stubbed out adding sensors for fe path " << fe_path); - // FIXME add sensors here + _init_mpm_sensors(dir, chan_idx); } } } diff --git a/host/lib/usrp/dboard/magnesium/magnesium_radio_ctrl_impl.hpp b/host/lib/usrp/dboard/magnesium/magnesium_radio_ctrl_impl.hpp index 91a7060d6..e32c2d5c9 100644 --- a/host/lib/usrp/dboard/magnesium/magnesium_radio_ctrl_impl.hpp +++ b/host/lib/usrp/dboard/magnesium/magnesium_radio_ctrl_impl.hpp @@ -119,6 +119,11 @@ private: //! Initialize property tree void _init_prop_tree(); + void _init_mpm_sensors( + const direction_t dir, + const size_t chan_idx + ); + /************************************************************************** * Sensors *************************************************************************/ diff --git a/host/lib/usrp/dboard/magnesium/magnesium_radio_ctrl_init.cpp b/host/lib/usrp/dboard/magnesium/magnesium_radio_ctrl_init.cpp index 7cfa45bc7..27cf926a2 100644 --- a/host/lib/usrp/dboard/magnesium/magnesium_radio_ctrl_init.cpp +++ b/host/lib/usrp/dboard/magnesium/magnesium_radio_ctrl_init.cpp @@ -401,3 +401,35 @@ void magnesium_radio_ctrl_impl::_init_prop_tree() } } +void magnesium_radio_ctrl_impl::_init_mpm_sensors( + const direction_t dir, + const size_t chan_idx +) { + const std::string trx = (dir == RX_DIRECTION) ? "RX" : "TX"; + const fs_path fe_path = + fs_path("dboards") / _radio_slot / + (dir == RX_DIRECTION ? "rx_frontends" : "tx_frontends") / chan_idx; + auto sensor_list = + _rpcc->request_with_token<std::vector<std::string>>( + this->_rpc_prefix + "get_sensors", trx); + UHD_LOG_TRACE(unique_id(), + "Chan " << chan_idx << ": Found " + << sensor_list.size() << " " << trx << " sensors."); + for (const auto &sensor_name : sensor_list) { + UHD_LOG_TRACE(unique_id(), + "Adding " << trx << " sensor " << sensor_name); + _tree->create<sensor_value_t>(fe_path / "sensors" / sensor_name) + .add_coerced_subscriber([](const sensor_value_t &){ + throw uhd::runtime_error( + "Attempting to write to sensor!"); + }) + .set_publisher([this, trx, sensor_name, chan_idx](){ + return sensor_value_t( + this->_rpcc->request_with_token<sensor_value_t::sensor_map_t>( + this->_rpc_prefix + "get_sensor", + trx, sensor_name, chan_idx) + ); + }) + ; + } +} |