diff options
author | Martin Braun <martin.braun@ettus.com> | 2017-09-29 13:58:43 -0700 |
---|---|---|
committer | Martin Braun <martin.braun@ettus.com> | 2017-12-22 15:04:02 -0800 |
commit | e2f8f8e0bd36171246e99d96a5155a5b098f6700 (patch) | |
tree | 1ac23209444fba1b32529d0498f7d3ef048763dd /host/lib/usrp/mpmd | |
parent | 21605b4e8b58053f4fa91a0a5136261da33e3bfb (diff) | |
download | uhd-e2f8f8e0bd36171246e99d96a5155a5b098f6700.tar.gz uhd-e2f8f8e0bd36171246e99d96a5155a5b098f6700.tar.bz2 uhd-e2f8f8e0bd36171246e99d96a5155a5b098f6700.zip |
mpm: Added sensor API
- Motherboard sensors are automatically populated into the property
tree, they can be automatically enumerated and queried
- Daughterboard sensors have an API for querying and enumerating
sensors, but this commit does not automatically add them to the
property tree
Diffstat (limited to 'host/lib/usrp/mpmd')
-rw-r--r-- | host/lib/usrp/mpmd/mpmd_impl.cpp | 30 |
1 files changed, 30 insertions, 0 deletions
diff --git a/host/lib/usrp/mpmd/mpmd_impl.cpp b/host/lib/usrp/mpmd/mpmd_impl.cpp index 38a089788..93e777af2 100644 --- a/host/lib/usrp/mpmd/mpmd_impl.cpp +++ b/host/lib/usrp/mpmd/mpmd_impl.cpp @@ -106,6 +106,36 @@ namespace { ); }) ; + + /*** Sensors ********************************************************/ + auto sensor_list = + mb->rpc->request_with_token<std::vector<std::string>>( + "get_mb_sensors" + ); + UHD_LOG_DEBUG("MPMD", + "Found " << sensor_list.size() << " motherboard sensors." + ); + for (const auto& sensor_name : sensor_list) { + UHD_LOG_TRACE("MPMD", + "Adding motherboard sensor `" << sensor_name << "'" + ); + tree->create<sensor_value_t>( + mb_path / "sensors" / sensor_name) + .set_publisher([mb, sensor_name](){ + return sensor_value_t( + mb->rpc->request_with_token<sensor_value_t::sensor_map_t>( + "get_mb_sensor", sensor_name + ) + ); + }) + .set_coercer([](const sensor_value_t &){ + throw uhd::runtime_error( + "Trying to write read-only sensor value!" + ); + return sensor_value_t("", "", ""); + }) + ; + } } void reset_time_synchronized(uhd::property_tree::sptr tree) |