forked from mirror/smcFanControl
added the two missing bits to the result when decoding FPE2 values
This commit is contained in:
@ -52,7 +52,7 @@ void _ultostr(char *str, UInt32 val)
|
|||||||
(unsigned int) val);
|
(unsigned int) val);
|
||||||
}
|
}
|
||||||
|
|
||||||
float _strtof(char *str, int size, int e)
|
float _strtof(unsigned char *str, int size, int e)
|
||||||
{
|
{
|
||||||
float total = 0;
|
float total = 0;
|
||||||
int i;
|
int i;
|
||||||
@ -65,6 +65,8 @@ float _strtof(char *str, int size, int e)
|
|||||||
total += str[i] << (size - 1 - i) * (8 - e);
|
total += str[i] << (size - 1 - i) * (8 - e);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
total += (str[size-1] & 0x03) * 0.25;
|
||||||
|
|
||||||
return total;
|
return total;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -77,9 +79,7 @@ void smc_close(){
|
|||||||
}
|
}
|
||||||
void printFPE2(SMCVal_t val)
|
void printFPE2(SMCVal_t val)
|
||||||
{
|
{
|
||||||
/* FIXME: This decode is incomplete, last 2 bits are dropped */
|
printf("%.02f ", _strtof(val.bytes, val.dataSize, 2));
|
||||||
|
|
||||||
printf("%.0f ", _strtof(val.bytes, val.dataSize, 2));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void printUInt(SMCVal_t val)
|
void printUInt(SMCVal_t val)
|
||||||
|
|||||||
@ -98,5 +98,4 @@ kern_return_t SMCClose(io_connect_t conn);
|
|||||||
void smc_init();
|
void smc_init();
|
||||||
void smc_close();
|
void smc_close();
|
||||||
|
|
||||||
float _strtof(char *str, int size, int e);
|
float _strtof(unsigned char *str, int size, int e);
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user