From 31ff6e6f4a8f7bac3214e48974a2b0d38b5e0bbb Mon Sep 17 00:00:00 2001 From: Tom Joseph Date: Wed, 24 Jan 2018 16:10:09 +0530 Subject: sensor: Populate entity id, instance and sensor name callback Change-Id: Ie7bf403ae15d9b1a70216aab0c57362c3d4240e7 Signed-off-by: Tom Joseph --- scripts/sensor-example.yaml | 9 +++++++++ scripts/writesensor.mako.cpp | 12 ++++++++---- 2 files changed, 17 insertions(+), 4 deletions(-) (limited to 'scripts') diff --git a/scripts/sensor-example.yaml b/scripts/sensor-example.yaml index c4ff4d5..db0e694 100755 --- a/scripts/sensor-example.yaml +++ b/scripts/sensor-example.yaml @@ -11,6 +11,8 @@ serviceInterface: org.freedesktop.DBus.Properties # Where the sensor value is represented - assertion bits/reading/event data readingType: assertion + # Sensor name would be occ0 + sensorNamePattern: nameLeaf eventType: 0x6F # All the d-bus interfaces : properties that must be updated for this path interfaces: @@ -35,6 +37,7 @@ path: /system/chassis/motherboard/dimm1 serviceInterface: xyz.openbmc_project.Inventory.Manager readingType: assertion + sensorNamePattern: nameLeaf interfaces: xyz.openbmc_project.State.Decorator.OperationalStatus: Functional: @@ -70,6 +73,8 @@ # serves as the value, or reading. Hence, the offset above is intentionally # 0xFF, to indicate not to check any specific bits in the assertion. readingType: readingAssertion + # Sensor name would be AttemptsLeft + sensorNamePattern: nameProperty sensorReadingType: 0x6F sensorType: 0xC3 serviceInterface: org.freedesktop.DBus.Properties @@ -83,6 +88,7 @@ type: uint32_t path: /xyz/openbmc_project/state/host1 readingType: readingAssertion + sensorNamePattern: nameProperty sensorReadingType: 0x6F sensorType: 0xC3 serviceInterface: org.freedesktop.DBus.Properties @@ -97,6 +103,7 @@ mutability: Mutability::Write|Mutability::Read serviceInterface: org.freedesktop.DBus.Properties readingType: readingData + sensorNamePattern: nameLeaf interfaces: xyz.openbmc_project.Sensor.Value: Value: @@ -110,6 +117,8 @@ sensorReadingType: 0x6F serviceInterface: xyz.openbmc_project.Inventory.Manager readingType: assertion + # Sensor name would be cpu0_core22 + sensorNamePattern: nameParentLeaf interfaces: xyz.openbmc_project.State.Decorator.OperationalStatus: Functional: diff --git a/scripts/writesensor.mako.cpp b/scripts/writesensor.mako.cpp index e081474..4644ff7 100644 --- a/scripts/writesensor.mako.cpp +++ b/scripts/writesensor.mako.cpp @@ -39,6 +39,8 @@ extern const IdInfoMap sensors = { path = sensor["path"] serviceInterface = sensor["serviceInterface"] sensorType = sensor["sensorType"] + entityID = sensor.get("entityID", 0) + instance = sensor.get("entityInstance", 0) readingType = sensor["sensorReadingType"] multiplier = sensor.get("multiplierM", 1) offsetB = sensor.get("offsetB", 0) @@ -47,6 +49,8 @@ extern const IdInfoMap sensors = { scale = sensor.get("scale", 0) hasScale = "true" if "scale" in sensor.keys() else "false" valueReadingType = sensor["readingType"] + sensorNamePattern = sensor.get("sensorNamePattern", "nameLeaf") + sensorNameFunc = "get::" + sensorNamePattern updateFunc = interfaceDict[serviceInterface]["updateFunc"] updateFunc += sensor["readingType"] getFunc = interfaceDict[serviceInterface]["getFunc"] @@ -63,10 +67,10 @@ extern const IdInfoMap sensors = { sensorInterface = next(iter(interfaces)) mutability = sensor.get("mutability", "Mutability::Read") %> - ${sensorType},"${path}","${sensorInterface}",${readingType},${multiplier}, - ${offsetB},${exp},${offsetB * pow(10,exp)}, - ${hasScale},${scale},"${unit}", - ${updateFunc},${getFunc},Mutability(${mutability}),{ + ${entityID},${instance},${sensorType},"${path}","${sensorInterface}", + ${readingType},${multiplier}, ${offsetB},${exp}, + ${offsetB * pow(10,exp)}, ${hasScale},${scale},"${unit}", + ${updateFunc},${getFunc},Mutability(${mutability}),${sensorNameFunc},{ % for interface,properties in interfaces.items(): {"${interface}",{ % for dbus_property,property_value in properties.items(): -- cgit v1.2.1