[phosphor-virtual-sensor] Exception "The name is not activatable" when get the source sensor value.

Thu Nguyen OS thu at os.amperecomputing.com
Wed Mar 31 04:06:45 AEDT 2021


Dear All,

In MtJade platform, we are using phosphor-virtual-sensor to create the host virtual sensors.
The source sensors of the virtual sensors are created by phosphor-hwmon.
The phosphor-hwmon get the sensor value from sysfs which created by SMPro-hwmon driver.
As linux kernel requirement, SMPro-hwmon driver will not be binded until the device is accessible.
In our case, it is when the host is off. So the source sensors of the host virtual sensors are not available when the host is off.
When the SMPro-hwmon driver start binding the source sensors, the serviceName of the sensor is available.
But the its’ value interface can be unavailable in the short time.


Below is my observation:
+ Turn on the host.
+ The SMPro-hwmon driver starts binding the source sensors.
+ The phosphor-hwmon starts creating dbus sensor for the source sensors getService() return the corrected service name.
But in the sort time, the value interface “xyz.openbmc_project.Sensor.Value” is not available. Calling getDbusProperty() exit with the exception
“sd_bus_call: org.freedesktop.DBus.Error.ServiceUnknown: The name is not activatable”


As my opinion, we should add try catch when get the sensor value. And return std::numeric_limits<double>::quiet_NaN() when the exception appears.
I’m changing the code of GetSensorValue() as below to fix the exception.
/** @brief Get sensor value property from D-bus interface */
    double getSensorValue()
    {
        double ret = -1;

        if (servName.empty())
        {
            servName = getService(bus, path, sensorIntf);
            if (servName.empty())
            {
                return std::numeric_limits<double>::quiet_NaN();
            }
        }
        /*
         * When the sensor driver is binding, getting its' value can be
         * cause exception:
         * "sd_bus_call: org.freedesktop.DBus.Error.ServiceUnknown: \
         * The name is not activatable"
         * Add try catch to cover this exception case.
         */
        try
        {
            ret = getDbusProperty<double>(bus, servName, path, sensorIntf,
                                    "Value");
        }
        catch(const std::exception& e)
        {
            ret = std::numeric_limits<double>::quiet_NaN();
        }

        return ret;
    }

Is the patch file?

Thanks.
Thu Nguyen.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.ozlabs.org/pipermail/openbmc/attachments/20210330/4d6b14d4/attachment-0001.htm>


More information about the openbmc mailing list