<div dir="ltr"><div>Hi James,</div><div><br></div><div>Thank you for the reference implementation.</div><div>I see that you are using the GetAttributes function in sensorutils.cpp, that accepts the Min and Max value and outputs mValue, bValue, rExp and bExp. This is exactly what I was looking for. </div><div><br></div><div>I still had some concerns, can you please help with the following,</div><div><br></div><div>1. When I plug in values from Tom's example (in this thread), I don't seem to get the expected values for B. When min and max are (-127 , 128), I am getting M=1 and B=-1 (including bSigned) where according to Tom's calculation, it is M=1 and B=-127. Am I interpreting the output of B correctly? </div><div><br></div><div>2. Any reference document/spec for this algorithm, if available, would be really helpful. </div><div><br></div><div>Thanks,</div><div>Guhan</div></div><div class="gmail_extra"><br><div class="gmail_quote">On Fri, Apr 13, 2018 at 8:41 AM, James Feist <span dir="ltr"><<a href="mailto:james.feist@linux.intel.com" target="_blank">james.feist@linux.intel.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">There is an RFC I posted that calculates the M, B, and exponents from<br>
the D-Bus sensor endpoints: <a href="https://gerrit.openbmc-project.xyz/#/c/8521/" rel="noreferrer" target="_blank">https://gerrit.openbmc-project<wbr>.xyz/#/c/8521/</a><br>
<br>
We were hoping to roll this into host-ipmi sometime in future.<br>
<br>
Thanks,<br>
<br>
James Feist<span class=""><br>
<br>
On 04/12/2018 07:41 PM, guhan balasubramanian wrote:<br>
</span><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><span class="">
Hi Tom,<br>
<br>
Thanks for the explanation. But I still see some concerns in this conversion logic.<br>
<br>
For input, we have 4 given parameters as<br>
     1. Min and Max values of the sensor (y)<br>
     2. the Min and Max values of the byte value (x - assuming this is always 0 to 255).<br>
<br>
For output, we have 4 paramters to calculate<br>
     1. multiplierM (M)<br>
     2. offsetB (B)<br>
     3. bExp (k1)<br>
     4. rExp (k2)<br>
<br>
We have two equations to compute 4 variables in this logic.<br>
<br>
<br></span><div><div class="h5">
On Sat, Mar 10, 2018 at 9:45 AM, Tom Joseph <<a href="mailto:tomjose@linux.vnet.ibm.com" target="_blank">tomjose@linux.vnet.ibm.com</a> <mailto:<a href="mailto:tomjose@linux.vnet.ibm.com" target="_blank">tomjose@linux.vnet.ibm<wbr>.com</a>>> wrote:<br>
<br>
    Hello Guhan,<br>
<br>
    The updated sensor-example.yaml has the Rexp field as well. These<br>
    values are  calculated based on the minimum and maximum value of the<br>
    sensor.<br>
<br>
    If a temperature sensor has a range of -127 - +128, means y is -127<br>
    to +128 and the range of x is 0-255.<br>
    By substituting x = 0 and y = -127 (k2 is the decimal precision and<br>
    assume in this case as whole nos) implies Bexp = -127.<br>
    Similarly substitute x = 255 and y = 128 and M is evaluated as 1.<br>
<br>
<br>
In the above example, with 2 values [(0, -127) and (255, 128)] for (x,y) we were able to calculate M and B. We are assuming k2 as 0 since we are taking only whole numbers for our ranges (y values). But we are still assuming the values for k1 as 0.<br>
<br>
<br>
    Regards,<br>
    Tom<br>
<br>
<br>
    On Saturday 10 March 2018 08:01 AM, guhan balasubramanian wrote:<br>
</div></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div><div class="h5">
    Hi,<br>
<br>
    According to the IPMI spec, we represent all sensor readings<br>
    (Volt, Temp, Amp, etc.) as 1-byte.<br>
<br>
    Since we represent them as 1-byte, we use a linearization formula<br>
    to convert to actual value as follows:<br>
<br>
    y = (M*x + B*10^(k1))*10^(k2)<br>
<br>
    where x is the 1-byte value that is filled in the get sensor<br>
    reading command.<br>
<br>
    We see in the ipmitool example on how an example of 3.36 V is<br>
    represented as 1-byte.<br>
    <a href="https://computercheese.blogspot.com/2013/10/ipmi-sensor-reading-conversion-formula.html?q=sensor" rel="noreferrer" target="_blank">https://computercheese.blogspo<wbr>t.com/2013/10/ipmi-sensor-<wbr>reading-conversion-formula.<wbr>html?q=sensor</a><br>
    <<a href="https://computercheese.blogspot.com/2013/10/ipmi-sensor-reading-conversion-formula.html?q=sensor" rel="noreferrer" target="_blank">https://computercheese.blogsp<wbr>ot.com/2013/10/ipmi-sensor-<wbr>reading-conversion-formula.<wbr>html?q=sensor</a>><br>
<br>
    Can any one please help on how the values for M, B, k1 and k2 are<br>
    populated for each sensor?<br>
<br>
    In the openbmc repo, I believe these values are present in the<br>
    config.yaml of phosphor-ipmi-sensor-inventory (based on the<br>
    following sample).<br>
<br>
    0xF1:<br>
      sensorType: 0x01<br>
      path: /xyz/openbmc_project/sensors/t<wbr>emperature/temp1<br>
      sensorReadingType: 0x01<br></div></div>
    *multiplierM*: 511<br>
    *offsetB*: 0<br>
    *bExp*: 0<span class=""><br>
      mutability: Mutability::Write|Mutability::<wbr>Read<br>
      serviceInterface: org.freedesktop.DBus.Propertie<wbr>s<br>
      readingType: readingData<br>
      interfaces:<br>
        xyz.openbmc_project.Sensor.Val<wbr>ue:<br>
          Value:<br>
            Offsets:<br>
              0x0:<br>
                type: int64_t<br>
<br>
<br>
    Thanks,<br>
    Guhan<br>
<br>
</span></blockquote><span class="">
With the given information, do you think there is a generic way (algorithm) where we can compute all the 4 variables M, B, k1 and k2?<br>
<br>
Thanks,<br>
Guhan<br>
<br>
</span></blockquote>
</blockquote></div><br></div>