<html xmlns:v="urn:schemas-microsoft-com:vml" xmlns:o="urn:schemas-microsoft-com:office:office" xmlns:w="urn:schemas-microsoft-com:office:word" xmlns:x="urn:schemas-microsoft-com:office:excel" xmlns:m="http://schemas.microsoft.com/office/2004/12/omml" xmlns="http://www.w3.org/TR/REC-html40">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<meta name="Generator" content="Microsoft Word 15 (filtered medium)">
<style><!--
/* Font Definitions */
@font-face
        {font-family:"Cambria Math";
        panose-1:2 4 5 3 5 4 6 3 2 4;}
@font-face
        {font-family:Calibri;
        panose-1:2 15 5 2 2 2 4 3 2 4;}
@font-face
        {font-family:Menlo;
        panose-1:2 11 6 9 3 8 4 2 2 4;}
@font-face
        {font-family:"Helvetica Neue";
        panose-1:2 0 5 3 0 0 0 2 0 4;}
/* Style Definitions */
p.MsoNormal, li.MsoNormal, div.MsoNormal
        {margin:0cm;
        font-size:11.0pt;
        font-family:"Calibri",sans-serif;}
span.EmailStyle17
        {mso-style-type:personal-compose;
        font-family:"Calibri",sans-serif;
        color:windowtext;}
p.p1, li.p1, div.p1
        {mso-style-name:p1;
        margin:0cm;
        font-size:10.0pt;
        font-family:"Helvetica Neue";}
.MsoChpDefault
        {mso-style-type:export-only;}
@page WordSection1
        {size:612.0pt 792.0pt;
        margin:72.0pt 72.0pt 72.0pt 72.0pt;}
div.WordSection1
        {page:WordSection1;}
--></style>
</head>
<body lang="en-VN" link="#0563C1" vlink="#954F72" style="word-wrap:break-word">
<div class="WordSection1">
<p class="MsoNormal"><span lang="EN-US">Dear All,<o:p></o:p></span></p>
<p class="MsoNormal"><span lang="EN-US"><o:p> </o:p></span></p>
<p class="MsoNormal"><span lang="EN-US">In MtJade platform, we are using phosphor-virtual-sensor to create the host virtual sensors.<o:p></o:p></span></p>
<p class="MsoNormal"><span lang="EN-US">The source sensors of the virtual sensors are created by phosphor-hwmon.<o:p></o:p></span></p>
<p class="MsoNormal"><span lang="EN-US">The phosphor-hwmon get the sensor value from sysfs which created by SMPro-hwmon driver.<o:p></o:p></span></p>
<p class="MsoNormal"><span lang="EN-US">As linux kernel requirement, SMPro-hwmon driver will not be binded until the device is accessible.<o:p></o:p></span></p>
<p class="MsoNormal"><span lang="EN-US">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.<o:p></o:p></span></p>
<p class="MsoNormal"><span lang="EN-US">When the SMPro-hwmon driver start binding the source sensors, the serviceName of the sensor is available.<o:p></o:p></span></p>
<p class="MsoNormal"><span lang="EN-US">But the its’ value interface can be unavailable in the short time.
<o:p></o:p></span></p>
<p class="MsoNormal"><span lang="EN-US"><o:p> </o:p></span></p>
<p class="MsoNormal"><span lang="EN-US"><o:p> </o:p></span></p>
<p class="MsoNormal"><span lang="EN-US">Below is my observation:<o:p></o:p></span></p>
<p class="MsoNormal"><span lang="EN-US">+ Turn on the host.<o:p></o:p></span></p>
<p class="MsoNormal"><span lang="EN-US">+ The SMPro-hwmon driver starts binding the source sensors.<o:p></o:p></span></p>
<p class="MsoNormal"><span lang="EN-US">+ The phosphor-hwmon starts creating dbus sensor for the source sensors getService() return the corrected service name.<o:p></o:p></span></p>
<p class="MsoNormal"><span lang="EN-US">But in the sort time, the value interface “</span>xyz.openbmc_project.Sensor.Value<span lang="EN-US">” is not available. Calling getDbusProperty() exit with the exception<o:p></o:p></span></p>
<p class="MsoNormal" style="line-height:18.0pt;background:#1E1E1E"><span lang="EN-US" style="color:white">“</span><span style="font-size:12.0pt;font-family:Menlo;color:#6A9955">sd_bus_call: org.freedesktop.DBus.Error.ServiceUnknown: The name is not activatable</span><span lang="EN-US" style="color:white">”
</span><span lang="EN-US"><o:p></o:p></span></p>
<p class="MsoNormal"><span lang="EN-US"><o:p> </o:p></span></p>
<p class="p1"><span lang="EN-US">As my opinion, we should add try catch when get the sensor value. And return
</span>std::numeric_limits<double>::quiet_NaN()<span lang="EN-US"> when the exception appears.<o:p></o:p></span></p>
<p class="MsoNormal"><span lang="EN-US">I’m changing the code of GetSensorValue() as below to fix the exception.<o:p></o:p></span></p>
<p class="MsoNormal" style="line-height:18.0pt;background:#1E1E1E"><span style="font-size:12.0pt;font-family:Menlo;color:#6A9955">/**
</span><span style="font-size:12.0pt;font-family:Menlo;color:#569CD6">@brief</span><span style="font-size:12.0pt;font-family:Menlo;color:#6A9955"> Get sensor value property from D-bus interface */</span><span style="font-size:12.0pt;font-family:Menlo;color:#D4D4D4"><o:p></o:p></span></p>
<p class="MsoNormal" style="line-height:18.0pt;background:#1E1E1E"><span style="font-size:12.0pt;font-family:Menlo;color:#D4D4D4">   
</span><span style="font-size:12.0pt;font-family:Menlo;color:#569CD6">double</span><span style="font-size:12.0pt;font-family:Menlo;color:#D4D4D4">
</span><span style="font-size:12.0pt;font-family:Menlo;color:#DCDCAA">getSensorValue</span><span style="font-size:12.0pt;font-family:Menlo;color:#D4D4D4">()<o:p></o:p></span></p>
<p class="MsoNormal" style="line-height:18.0pt;background:#1E1E1E"><span style="font-size:12.0pt;font-family:Menlo;color:#D4D4D4">    {<o:p></o:p></span></p>
<p class="MsoNormal" style="line-height:18.0pt;background:#1E1E1E"><span style="font-size:12.0pt;font-family:Menlo;color:#D4D4D4">       
</span><span style="font-size:12.0pt;font-family:Menlo;color:#569CD6">double</span><span style="font-size:12.0pt;font-family:Menlo;color:#D4D4D4">
</span><span style="font-size:12.0pt;font-family:Menlo;color:#9CDCFE">ret</span><span style="font-size:12.0pt;font-family:Menlo;color:#D4D4D4"> = -</span><span style="font-size:12.0pt;font-family:Menlo;color:#B5CEA8">1</span><span style="font-size:12.0pt;font-family:Menlo;color:#D4D4D4">;<o:p></o:p></span></p>
<p class="MsoNormal" style="line-height:18.0pt;background:#1E1E1E"><span style="font-size:12.0pt;font-family:Menlo;color:#D4D4D4"><o:p> </o:p></span></p>
<p class="MsoNormal" style="line-height:18.0pt;background:#1E1E1E"><span style="font-size:12.0pt;font-family:Menlo;color:#D4D4D4">       
</span><span style="font-size:12.0pt;font-family:Menlo;color:#C586C0">if</span><span style="font-size:12.0pt;font-family:Menlo;color:#D4D4D4"> (</span><span style="font-size:12.0pt;font-family:Menlo;color:#9CDCFE">servName</span><span style="font-size:12.0pt;font-family:Menlo;color:#D4D4D4">.</span><span style="font-size:12.0pt;font-family:Menlo;color:#DCDCAA">empty</span><span style="font-size:12.0pt;font-family:Menlo;color:#D4D4D4">())<o:p></o:p></span></p>
<p class="MsoNormal" style="line-height:18.0pt;background:#1E1E1E"><span style="font-size:12.0pt;font-family:Menlo;color:#D4D4D4">        {<o:p></o:p></span></p>
<p class="MsoNormal" style="line-height:18.0pt;background:#1E1E1E"><span style="font-size:12.0pt;font-family:Menlo;color:#D4D4D4">           
</span><span style="font-size:12.0pt;font-family:Menlo;color:#9CDCFE">servName</span><span style="font-size:12.0pt;font-family:Menlo;color:#D4D4D4"> =
</span><span style="font-size:12.0pt;font-family:Menlo;color:#9CDCFE">getService</span><span style="font-size:12.0pt;font-family:Menlo;color:#D4D4D4">(bus,
</span><span style="font-size:12.0pt;font-family:Menlo;color:#DCDCAA">path</span><span style="font-size:12.0pt;font-family:Menlo;color:#D4D4D4">,
</span><span style="font-size:12.0pt;font-family:Menlo;color:#9CDCFE">sensorIntf</span><span style="font-size:12.0pt;font-family:Menlo;color:#D4D4D4">);<o:p></o:p></span></p>
<p class="MsoNormal" style="line-height:18.0pt;background:#1E1E1E"><span style="font-size:12.0pt;font-family:Menlo;color:#D4D4D4">           
</span><span style="font-size:12.0pt;font-family:Menlo;color:#C586C0">if</span><span style="font-size:12.0pt;font-family:Menlo;color:#D4D4D4"> (</span><span style="font-size:12.0pt;font-family:Menlo;color:#9CDCFE">servName</span><span style="font-size:12.0pt;font-family:Menlo;color:#D4D4D4">.</span><span style="font-size:12.0pt;font-family:Menlo;color:#DCDCAA">empty</span><span style="font-size:12.0pt;font-family:Menlo;color:#D4D4D4">())<o:p></o:p></span></p>
<p class="MsoNormal" style="line-height:18.0pt;background:#1E1E1E"><span style="font-size:12.0pt;font-family:Menlo;color:#D4D4D4">            {<o:p></o:p></span></p>
<p class="MsoNormal" style="line-height:18.0pt;background:#1E1E1E"><span style="font-size:12.0pt;font-family:Menlo;color:#D4D4D4">               
</span><span style="font-size:12.0pt;font-family:Menlo;color:#C586C0">return</span><span style="font-size:12.0pt;font-family:Menlo;color:#D4D4D4">
</span><span style="font-size:12.0pt;font-family:Menlo;color:#4EC9B0">std</span><span style="font-size:12.0pt;font-family:Menlo;color:#D4D4D4">::</span><span style="font-size:12.0pt;font-family:Menlo;color:#4EC9B0">numeric_limits</span><span style="font-size:12.0pt;font-family:Menlo;color:#D4D4D4"><</span><span style="font-size:12.0pt;font-family:Menlo;color:#569CD6">double</span><span style="font-size:12.0pt;font-family:Menlo;color:#D4D4D4">>::</span><span style="font-size:12.0pt;font-family:Menlo;color:#DCDCAA">quiet_NaN</span><span style="font-size:12.0pt;font-family:Menlo;color:#D4D4D4">();<o:p></o:p></span></p>
<p class="MsoNormal" style="line-height:18.0pt;background:#1E1E1E"><span style="font-size:12.0pt;font-family:Menlo;color:#D4D4D4">            }<o:p></o:p></span></p>
<p class="MsoNormal" style="line-height:18.0pt;background:#1E1E1E"><span style="font-size:12.0pt;font-family:Menlo;color:#D4D4D4">        }<o:p></o:p></span></p>
<p class="MsoNormal" style="line-height:18.0pt;background:#1E1E1E"><span style="font-size:12.0pt;font-family:Menlo;color:#6A9955">        /*</span><span style="font-size:12.0pt;font-family:Menlo;color:#D4D4D4"><o:p></o:p></span></p>
<p class="MsoNormal" style="line-height:18.0pt;background:#1E1E1E"><span style="font-size:12.0pt;font-family:Menlo;color:#6A9955">         * When the sensor driver is binding, getting its' value can be</span><span style="font-size:12.0pt;font-family:Menlo;color:#D4D4D4"><o:p></o:p></span></p>
<p class="MsoNormal" style="line-height:18.0pt;background:#1E1E1E"><span style="font-size:12.0pt;font-family:Menlo;color:#6A9955">         * cause exception:</span><span style="font-size:12.0pt;font-family:Menlo;color:#D4D4D4"><o:p></o:p></span></p>
<p class="MsoNormal" style="line-height:18.0pt;background:#1E1E1E"><span style="font-size:12.0pt;font-family:Menlo;color:#6A9955">         * "sd_bus_call: org.freedesktop.DBus.Error.ServiceUnknown: \</span><span style="font-size:12.0pt;font-family:Menlo;color:#D4D4D4"><o:p></o:p></span></p>
<p class="MsoNormal" style="line-height:18.0pt;background:#1E1E1E"><span style="font-size:12.0pt;font-family:Menlo;color:#6A9955">         * The name is not activatable"</span><span style="font-size:12.0pt;font-family:Menlo;color:#D4D4D4"><o:p></o:p></span></p>
<p class="MsoNormal" style="line-height:18.0pt;background:#1E1E1E"><span style="font-size:12.0pt;font-family:Menlo;color:#6A9955">         * Add try catch to cover this exception case.</span><span style="font-size:12.0pt;font-family:Menlo;color:#D4D4D4"><o:p></o:p></span></p>
<p class="MsoNormal" style="line-height:18.0pt;background:#1E1E1E"><span style="font-size:12.0pt;font-family:Menlo;color:#6A9955">         */</span><span style="font-size:12.0pt;font-family:Menlo;color:#D4D4D4"><o:p></o:p></span></p>
<p class="MsoNormal" style="line-height:18.0pt;background:#1E1E1E"><span style="font-size:12.0pt;font-family:Menlo;color:#D4D4D4">       
</span><span style="font-size:12.0pt;font-family:Menlo;color:#C586C0">try</span><span style="font-size:12.0pt;font-family:Menlo;color:#D4D4D4"><o:p></o:p></span></p>
<p class="MsoNormal" style="line-height:18.0pt;background:#1E1E1E"><span style="font-size:12.0pt;font-family:Menlo;color:#D4D4D4">        {<o:p></o:p></span></p>
<p class="MsoNormal" style="line-height:18.0pt;background:#1E1E1E"><span style="font-size:12.0pt;font-family:Menlo;color:#D4D4D4">           
</span><span style="font-size:12.0pt;font-family:Menlo;color:#9CDCFE">ret</span><span style="font-size:12.0pt;font-family:Menlo;color:#D4D4D4"> =
</span><span style="font-size:12.0pt;font-family:Menlo;color:#DCDCAA">getDbusProperty</span><span style="font-size:12.0pt;font-family:Menlo;color:#D4D4D4"><</span><span style="font-size:12.0pt;font-family:Menlo;color:#569CD6">double</span><span style="font-size:12.0pt;font-family:Menlo;color:#D4D4D4">>(bus,
</span><span style="font-size:12.0pt;font-family:Menlo;color:#9CDCFE">servName</span><span style="font-size:12.0pt;font-family:Menlo;color:#D4D4D4">,
</span><span style="font-size:12.0pt;font-family:Menlo;color:#DCDCAA">path</span><span style="font-size:12.0pt;font-family:Menlo;color:#D4D4D4">,
</span><span style="font-size:12.0pt;font-family:Menlo;color:#9CDCFE">sensorIntf</span><span style="font-size:12.0pt;font-family:Menlo;color:#D4D4D4">,<o:p></o:p></span></p>
<p class="MsoNormal" style="line-height:18.0pt;background:#1E1E1E"><span style="font-size:12.0pt;font-family:Menlo;color:#D4D4D4">                                   
</span><span style="font-size:12.0pt;font-family:Menlo;color:#CE9178">"Value"</span><span style="font-size:12.0pt;font-family:Menlo;color:#D4D4D4">);<o:p></o:p></span></p>
<p class="MsoNormal" style="line-height:18.0pt;background:#1E1E1E"><span style="font-size:12.0pt;font-family:Menlo;color:#D4D4D4">        }<o:p></o:p></span></p>
<p class="MsoNormal" style="line-height:18.0pt;background:#1E1E1E"><span style="font-size:12.0pt;font-family:Menlo;color:#D4D4D4">       
</span><span style="font-size:12.0pt;font-family:Menlo;color:#C586C0">catch</span><span style="font-size:12.0pt;font-family:Menlo;color:#D4D4D4">(</span><span style="font-size:12.0pt;font-family:Menlo;color:#569CD6">const</span><span style="font-size:12.0pt;font-family:Menlo;color:#D4D4D4">
</span><span style="font-size:12.0pt;font-family:Menlo;color:#4EC9B0">std</span><span style="font-size:12.0pt;font-family:Menlo;color:#D4D4D4">::</span><span style="font-size:12.0pt;font-family:Menlo;color:#4EC9B0">exception</span><span style="font-size:12.0pt;font-family:Menlo;color:#D4D4D4">&
</span><span style="font-size:12.0pt;font-family:Menlo;color:#9CDCFE">e</span><span style="font-size:12.0pt;font-family:Menlo;color:#D4D4D4">)<o:p></o:p></span></p>
<p class="MsoNormal" style="line-height:18.0pt;background:#1E1E1E"><span style="font-size:12.0pt;font-family:Menlo;color:#D4D4D4">        {<o:p></o:p></span></p>
<p class="MsoNormal" style="line-height:18.0pt;background:#1E1E1E"><span style="font-size:12.0pt;font-family:Menlo;color:#D4D4D4">           
</span><span style="font-size:12.0pt;font-family:Menlo;color:#9CDCFE">ret</span><span style="font-size:12.0pt;font-family:Menlo;color:#D4D4D4"> =
</span><span style="font-size:12.0pt;font-family:Menlo;color:#4EC9B0">std</span><span style="font-size:12.0pt;font-family:Menlo;color:#D4D4D4">::</span><span style="font-size:12.0pt;font-family:Menlo;color:#4EC9B0">numeric_limits</span><span style="font-size:12.0pt;font-family:Menlo;color:#D4D4D4"><</span><span style="font-size:12.0pt;font-family:Menlo;color:#569CD6">double</span><span style="font-size:12.0pt;font-family:Menlo;color:#D4D4D4">>::</span><span style="font-size:12.0pt;font-family:Menlo;color:#DCDCAA">quiet_NaN</span><span style="font-size:12.0pt;font-family:Menlo;color:#D4D4D4">();<o:p></o:p></span></p>
<p class="MsoNormal" style="line-height:18.0pt;background:#1E1E1E"><span style="font-size:12.0pt;font-family:Menlo;color:#D4D4D4">        }<o:p></o:p></span></p>
<p class="MsoNormal" style="line-height:18.0pt;background:#1E1E1E"><span style="font-size:12.0pt;font-family:Menlo;color:#D4D4D4"><o:p> </o:p></span></p>
<p class="MsoNormal" style="line-height:18.0pt;background:#1E1E1E"><span style="font-size:12.0pt;font-family:Menlo;color:#D4D4D4">       
</span><span style="font-size:12.0pt;font-family:Menlo;color:#C586C0">return</span><span style="font-size:12.0pt;font-family:Menlo;color:#D4D4D4">
</span><span style="font-size:12.0pt;font-family:Menlo;color:#9CDCFE">ret</span><span style="font-size:12.0pt;font-family:Menlo;color:#D4D4D4">;<o:p></o:p></span></p>
<p class="MsoNormal" style="line-height:18.0pt;background:#1E1E1E"><span style="font-size:12.0pt;font-family:Menlo;color:#D4D4D4">    }<o:p></o:p></span></p>
<p class="MsoNormal"><span lang="EN-US"><o:p> </o:p></span></p>
<p class="MsoNormal"><span lang="EN-US">Is the patch file?<o:p></o:p></span></p>
<p class="MsoNormal"><span lang="EN-US"><o:p> </o:p></span></p>
<p class="MsoNormal"><span lang="EN-US">Thanks.<o:p></o:p></span></p>
<p class="MsoNormal"><span lang="EN-US">Thu Nguyen.<o:p></o:p></span></p>
</div>
</body>
</html>