platform-mc: Use a default terminus name if empty
Current flow for terminus name determination is: ( Defined here: [1] )
1. If neither EM nor PDRs provide a terminus name, it will be empty.
2. If only the EM provides a terminus name, the EM-defined name is used.
3. If both EM and PDRs provide a terminus name, the PDRs-defined name
will override the EM-defined name.
If the terminus name is empty the numeric sensor creation is skipped.
This patch ensures that there's a fallback terminus name (in the format
`Terminus_{TID}` for case 1, when both EM and PDRs don't provide the
sensor name and numeric sensor creation isn't skipped.
Tested.
```
-- Terminus on dbus
~ busctl tree xyz.openbmc_project.PLDM
....
| `- /xyz/openbmc_project/inventory/system
| `- /xyz/openbmc_project/inventory/system/board
| |- /xyz/openbmc_project/inventory/system/board/Terminus_101
....
-- Sensors on dbus
~ busctl tree xyz.openbmc_project.PLDM
....
|- /xyz/openbmc_project/sensors
| `- /xyz/openbmc_project/sensors/temperature
| |- /xyz/openbmc_project/sensors/temperature/Terminus_101_Sensor_1
| |- /xyz/openbmc_project/sensors/temperature/Terminus_101_Sensor_8
....
```
[1]: https://gerrit.openbmc.org/c/openbmc/pldm/+/82469
Change-Id: I9c1d05b25371d5549593e24364adf060dd37e056
Signed-off-by: Aditya Kurdunkar <akurdunkar@nvidia.com>
diff --git a/platform-mc/terminus.cpp b/platform-mc/terminus.cpp
index eb87d3b..97b0c36 100644
--- a/platform-mc/terminus.cpp
+++ b/platform-mc/terminus.cpp
@@ -208,6 +208,10 @@
"NAME", tName.value());
terminusName = static_cast<std::string>(tName.value());
}
+ else
+ {
+ terminusName = std::format("Terminus_{}", tid);
+ }
if (terminusName.empty() &&
(numericSensorPdrs.size() || compactNumericSensorPdrs.size()))