From e2f8f8e0bd36171246e99d96a5155a5b098f6700 Mon Sep 17 00:00:00 2001 From: Martin Braun Date: Fri, 29 Sep 2017 13:58:43 -0700 Subject: 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 --- host/lib/usrp/mpmd/mpmd_impl.cpp | 30 ++++++++++++++++++++++++++++++ 1 file changed, 30 insertions(+) (limited to 'host/lib/usrp/mpmd') 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>( + "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( + mb_path / "sensors" / sensor_name) + .set_publisher([mb, sensor_name](){ + return sensor_value_t( + mb->rpc->request_with_token( + "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) -- cgit v1.2.3