Add ability to add 'energy' sensor Type 01 records
Allow the getSensorTypeFromPath to create Type 01 records for D-Bus
entries with 'energy' in their path name.
Energy sensors are 'Other Unit-based sensors' and are considered to be
'threshold' sensors. The unit of measure is 'joules'.
Tested:
Confirmed sensors with the 'energy' string preceding the sensor name
generated a Type 01 record with the Sensor Type == 0xb, and the Event
Reading type set to 0x01. The record also set the Sensor Units 2 entry
to 0x07 to indicate the unit of measure is in joules.
Change-Id: I6ca9027e1ff2a8ad58640f851a9bd9f102ba55e9
Signed-off-by: Johnathan Mantey <johnathanx.mantey@intel.com>
diff --git a/dbus-sdr/sensorcommands.cpp b/dbus-sdr/sensorcommands.cpp
index 72cf377..f3cd385 100644
--- a/dbus-sdr/sensorcommands.cpp
+++ b/dbus-sdr/sensorcommands.cpp
@@ -125,7 +125,8 @@
{"voltage", SensorUnits::volts},
{"current", SensorUnits::amps},
{"fan_tach", SensorUnits::rpm},
- {"power", SensorUnits::watts}}};
+ {"power", SensorUnits::watts},
+ {"energy", SensorUnits::joules}}};
void registerSensorFunctions() __attribute__((constructor));
diff --git a/include/dbus-sdr/sdrutils.hpp b/include/dbus-sdr/sdrutils.hpp
index b78e226..a38673e 100644
--- a/include/dbus-sdr/sdrutils.hpp
+++ b/include/dbus-sdr/sdrutils.hpp
@@ -354,7 +354,9 @@
{"watchdog", std::make_pair(SensorTypeCodes::watchdog2,
SensorEventTypeCodes::sensorSpecified)},
{"entity", std::make_pair(SensorTypeCodes::entity,
- SensorEventTypeCodes::sensorSpecified)}}};
+ SensorEventTypeCodes::sensorSpecified)},
+ {"energy", std::make_pair(SensorTypeCodes::other,
+ SensorEventTypeCodes::threshold)}}};
std::string getSensorTypeStringFromPath(const std::string& path);
uint8_t getSensorTypeFromPath(const std::string& path);
diff --git a/include/dbus-sdr/storagecommands.hpp b/include/dbus-sdr/storagecommands.hpp
index 7b3046c..2ae9291 100644
--- a/include/dbus-sdr/storagecommands.hpp
+++ b/include/dbus-sdr/storagecommands.hpp
@@ -60,6 +60,7 @@
volts = 0x4,
amps = 0x5,
watts = 0x6,
+ joules = 0x7,
rpm = 0x12,
};