sensor-cache: Implement readingAssertion()
Implement readingAssertion() for cache's sensor.
Tested: Verify the sensors using `readingAssertion` have valid values in
QEMU, e.g.
CPU0_Status | 0x0 | discrete | 0x0000| na | na | na | na | na | na
Signed-off-by: Lei YU <yulei.sh@bytedance.com>
Change-Id: I3a370a48c46da244de53a3e90fbbc373cd682480
diff --git a/sensordatahandler.hpp b/sensordatahandler.hpp
index 7ecfee8..9084b7a 100644
--- a/sensordatahandler.hpp
+++ b/sensordatahandler.hpp
@@ -386,8 +386,42 @@
readingAssertion(uint8_t id, const Info& sensorInfo,
sdbusplus::message::message& msg)
{
- // TODO
- return {};
+ auto type = msg.get_type();
+ if (type == msgTypeSignal)
+ {
+ // This is signal callback
+ std::string interfaceName;
+ msg.read(interfaceName);
+ if (interfaceName != sensorInfo.sensorInterface)
+ {
+ // Not the interface we need
+ return {};
+ }
+ }
+ // Now the message only contains the properties.
+ GetSensorResponse response{};
+ std::map<std::string, ipmi::Value> properties;
+
+ enableScanning(&response);
+
+ msg.read(properties);
+
+ auto iter = properties.find(
+ sensorInfo.propertyInterfaces.begin()->second.begin()->first);
+ if (iter == properties.end())
+ {
+ return {};
+ }
+
+ setAssertionBytes(static_cast<uint16_t>(std::get<T>(iter->second)),
+ &response);
+
+ if (!sensorCacheMap[id].has_value())
+ {
+ sensorCacheMap[id] = SensorData{};
+ }
+ sensorCacheMap[id]->response = response;
+ return response;
}
/** @brief Get sensor reading from the dbus message from match