summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--env.cpp3
-rw-r--r--env.hpp4
-rw-r--r--mainloop.cpp15
3 files changed, 16 insertions, 6 deletions
diff --git a/env.cpp b/env.cpp
index 6841987..677f6fb 100644
--- a/env.cpp
+++ b/env.cpp
@@ -52,6 +52,7 @@ std::string getEnv(
std::string getIndirectID(
std::string path,
+ const std::string& fileSuffix,
const SensorSet::key_type& sensor)
{
std::string content;
@@ -59,7 +60,7 @@ std::string getIndirectID(
path.append(sensor.first);
path.append(sensor.second);
path.append(1, '_');
- path.append(hwmon::entry::label);
+ path.append(fileSuffix);
std::ifstream handle(path.c_str());
if (!handle.fail())
diff --git a/env.hpp b/env.hpp
index fa23888..56dd2aa 100644
--- a/env.hpp
+++ b/env.hpp
@@ -43,14 +43,16 @@ std::string getEnv(
/** @brief Gets the ID for the sensor with a level of indirection
*
- * Read the sensor number/ID from the <path>/<item><X>_label file.
+ * Read the ID from the <path>/<item><X>_<suffix> file.
* <item> & <X> are populated from the sensor key.
*
* @param[in] path - Directory path of the label file
+ * @param[in] fileSuffix - The file suffix
* @param[in] sensor - Sensor details
*/
std::string getIndirectID(
std::string path,
+ const std::string& fileSuffix,
const SensorSet::key_type& sensor);
} // namespace env
diff --git a/mainloop.cpp b/mainloop.cpp
index 221c8c9..5243f3c 100644
--- a/mainloop.cpp
+++ b/mainloop.cpp
@@ -216,17 +216,24 @@ std::string MainLoop::getID(SensorSet::container_t::const_reference sensor)
/*
* Check if the value of the MODE_<item><X> env variable for the sensor
- * is "label", then read the sensor number from the <item><X>_label
+ * is set. If it is, then read the from the <item><X>_<mode>
* file. The name of the DBUS object would be the value of the env
- * variable LABEL_<item><sensorNum>. If the MODE_<item><X> env variable
+ * variable LABEL_<item><mode value>. If the MODE_<item><X> env variable
* doesn't exist, then the name of DBUS object is the value of the env
* variable LABEL_<item><X>.
+ *
+ * For example, if MODE_temp1 = "label", then code reads the temp1_label
+ * file. If it has a 5 in it, then it will use the following entry to
+ * name the object: LABEL_temp5 = "My DBus object name".
+ *
*/
auto mode = env::getEnv("MODE", sensor.first);
- if (!mode.compare(hwmon::entry::label))
+ if (!mode.empty())
{
id = env::getIndirectID(
- _hwmonRoot + '/' + _instance + '/', sensor.first);
+ _hwmonRoot + '/' + _instance + '/',
+ mode,
+ sensor.first);
if (id.empty())
{
OpenPOWER on IntegriCloud