diff --git a/smc-command/smc.c b/smc-command/smc.c index 9a17e4a..693d8c1 100644 --- a/smc-command/smc.c +++ b/smc-command/smc.c @@ -52,7 +52,7 @@ void _ultostr(char *str, UInt32 val) (unsigned int) val); } -float _strtof(char *str, int size, int e) +float _strtof(unsigned char *str, int size, int e) { float total = 0; int i; @@ -65,6 +65,8 @@ float _strtof(char *str, int size, int e) total += str[i] << (size - 1 - i) * (8 - e); } + total += (str[size-1] & 0x03) * 0.25; + return total; } @@ -77,9 +79,7 @@ void smc_close(){ } void printFPE2(SMCVal_t val) { - /* FIXME: This decode is incomplete, last 2 bits are dropped */ - - printf("%.0f ", _strtof(val.bytes, val.dataSize, 2)); + printf("%.02f ", _strtof(val.bytes, val.dataSize, 2)); } void printUInt(SMCVal_t val) diff --git a/smc-command/smc.h b/smc-command/smc.h index b6f57ac..3a31b8f 100644 --- a/smc-command/smc.h +++ b/smc-command/smc.h @@ -98,5 +98,4 @@ kern_return_t SMCClose(io_connect_t conn); void smc_init(); void smc_close(); -float _strtof(char *str, int size, int e); - +float _strtof(unsigned char *str, int size, int e);