From b1e8fba50af2310136c6f92ab8765bf27aa5cec2 Mon Sep 17 00:00:00 2001 From: Deepak Kodihalli Date: Wed, 24 Jan 2018 04:57:10 -0600 Subject: dcmi: get temperature readings: read temp sensors This commit adds the code to read temperatures from various sensors. A JSON config file tells what D-Bus object(s) to look up for a specific temperature reading. Resolves openbmc/openbmc#2626 Change-Id: Ic357ec2a53ff250a2517d68defe5850ef353568a Signed-off-by: Deepak Kodihalli --- dcmihandler.hpp | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) (limited to 'dcmihandler.hpp') diff --git a/dcmihandler.hpp b/dcmihandler.hpp index a7cfe8a..e23c8da 100644 --- a/dcmihandler.hpp +++ b/dcmihandler.hpp @@ -5,6 +5,7 @@ #include #include #include +#include "nlohmann/json.hpp" namespace dcmi { @@ -50,6 +51,8 @@ namespace temp_readings static constexpr auto maxDataSets = 8; static constexpr auto maxInstances = 255; static constexpr auto maxTemp = 128; // degrees C + static constexpr auto configFile = + "/usr/share/ipmi-providers/dcmi_temp_readings.json"; /** @struct Response * @@ -70,6 +73,10 @@ namespace temp_readings using ResponseList = std::vector; using NumInstances = size_t; + using Value = uint8_t; + using Sign = bool; + using Temperature = std::tuple; + using Json = nlohmann::json; } static constexpr auto groupExtId = 0xDC; @@ -375,6 +382,24 @@ struct GetTempReadingsResponseHdr namespace temp_readings { + /** @brief Read temperature from a d-bus object, scale it as per dcmi + * get temperature reading requirements. + * + * @param[in] dbusService - the D-Bus service + * @param[in] dbusPath - the D-Bus path + * + * @return A temperature reading + */ + Temperature readTemp(const std::string& dbusService, + const std::string& dbusPath); + + /** @brief Parse out JSON config file containing information + * related to temperature readings. + * + * @return A json object + */ + Json parseConfig(); + /** @brief Read temperatures and fill up DCMI response for the Get * Temperature Readings command. This looks at a specific * instance. -- cgit v1.2.1