summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rwxr-xr-xscripts/sensor-example.yaml38
-rw-r--r--scripts/writesensor.mako.cpp76
-rw-r--r--sensordatahandler.cpp9
3 files changed, 86 insertions, 37 deletions
diff --git a/scripts/sensor-example.yaml b/scripts/sensor-example.yaml
index 4a1472d..c0fbe1e 100755
--- a/scripts/sensor-example.yaml
+++ b/scripts/sensor-example.yaml
@@ -154,3 +154,41 @@
#the update will be skipped.
skipOn: deassert
type: bool
+
+0xC5:
+ sensorType: 0x17
+ path: /system/chassis/motherboard/gv100card0
+ sensorReadingType: 1
+ serviceInterface: xyz.openbmc_project.Inventory.Manager
+ readingType: assertion
+ mutability: Mutability::Write|Mutability::Read
+ sensorNamePattern: nameLeaf
+ interfaces:
+ xyz.openbmc_project.Inventory.Decorator.Replaceable:
+ FieldReplaceable:
+ Offsets:
+ 7:
+ assert: true
+ deassert: true
+ type: bool
+ xyz.openbmc_project.Inventory.Item:
+ Present:
+ Offsets:
+ 7:
+ assert: true
+ deassert: false
+ type: bool
+ # Example of an interface with no attached properties
+ xyz.openbmc_project.Inventory.Item.Accelerator:
+ xyz.openbmc_project.State.Decorator.OperationalStatus:
+ Functional:
+ Offsets:
+ 8:
+ assert: false
+ deassert: true
+ type: bool
+ Prereqs:
+ 7:
+ assert: true
+ deassert: false
+ type: bool
diff --git a/scripts/writesensor.mako.cpp b/scripts/writesensor.mako.cpp
index 559f0f9..192b858 100644
--- a/scripts/writesensor.mako.cpp
+++ b/scripts/writesensor.mako.cpp
@@ -74,67 +74,69 @@ extern const IdInfoMap sensors = {
${updateFunc},${getFunc},Mutability(${mutability}),${sensorNameFunc},{
% for interface,properties in interfaces.items():
{"${interface}",{
- % for dbus_property,property_value in properties.items():
- {"${dbus_property}",{
+ % if properties:
+ % for dbus_property,property_value in properties.items():
+ {"${dbus_property}",{
<%
try:
preReq = property_value["Prereqs"]
except KeyError, e:
preReq = dict()
%>\
- {
- % for preOffset,preValues in preReq.items():
- { ${preOffset},{
- % for name,value in preValues.items():
- % if name == "type":
+ {
+ % for preOffset,preValues in preReq.items():
+ { ${preOffset},{
+ % for name,value in preValues.items():
+ % if name == "type":
<% continue %>\
- % endif
+ % endif
<% value = str(value).lower() %>\
- ${value},
+ ${value},
+ % endfor
+ }
+ },
% endfor
- }
},
- % endfor
- },
- {
- % for offset,values in property_value["Offsets"].items():
- { ${offset},{
- % if offset == 0xFF:
- }},
+ {
+ % for offset,values in property_value["Offsets"].items():
+ { ${offset},{
+ % if offset == 0xFF:
+ }},
<% continue %>\
- % endif
+ % endif
<% valueType = values["type"] %>\
<%
try:
skip = values["skipOn"]
if skip == "assert":
- skipVal = "SkipAssertion::ASSERT"
+ skipVal = "SkipAssertion::ASSERT"
elif skip == "deassert":
- skipVal = "SkipAssertion::DEASSERT"
+ skipVal = "SkipAssertion::DEASSERT"
else:
- assert "Unknown skip value " + str(skip)
+ assert "Unknown skip value " + str(skip)
except KeyError, e:
skipVal = "SkipAssertion::NONE"
%>\
- ${skipVal},
- % for name,value in values.items():
- % if name == "type" or name == "skipOn":
+ ${skipVal},
+ % for name,value in values.items():
+ % if name == "type" or name == "skipOn":
<% continue %>\
- % endif
- % if valueType == "string":
- std::string("${value}"),
- % elif valueType == "bool":
+ % endif
+ % if valueType == "string":
+ std::string("${value}"),
+ % elif valueType == "bool":
<% value = str(value).lower() %>\
- ${value},
- % else:
- ${value},
- % endif
- % endfor
- }
- },
+ ${value},
+ % else:
+ ${value},
+ % endif
+ % endfor
+ }
+ },
+ % endfor
+ }}},
% endfor
- }}},
- % endfor
+ % endif
}},
% endfor
},
diff --git a/sensordatahandler.cpp b/sensordatahandler.cpp
index 76dad69..923b96a 100644
--- a/sensordatahandler.cpp
+++ b/sensordatahandler.cpp
@@ -322,6 +322,15 @@ ipmi_ret_t assertion(const SetSensorReadingReq& cmdData, const Info& sensorInfo)
ipmi::sensor::InterfaceMap interfaces;
for (const auto& interface : sensorInfo.propertyInterfaces)
{
+ // An interface with no properties - It is possible that the sensor
+ // object on DBUS implements a DBUS interface with no properties.
+ // Make sure we add the interface to the list if interfaces on the
+ // object with an empty property map.
+ if (interface.second.empty())
+ {
+ interfaces.emplace(interface.first, ipmi::sensor::PropertyMap{});
+ continue;
+ }
// For a property like functional state the result will be
// calculated based on the true value of all conditions.
for (const auto& property : interface.second)
OpenPOWER on IntegriCloud