Skip to content

Commit

Permalink
added Catalina fan fix from alkurbatov lavoiesl#30
Browse files Browse the repository at this point in the history
  • Loading branch information
BourgonLaurent committed Jul 26, 2020
1 parent 1ed274f commit a6b714b
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 3 deletions.
8 changes: 5 additions & 3 deletions smc.c
Original file line number Diff line number Diff line change
Expand Up @@ -222,6 +222,10 @@ float SMCGetFanRPM(char* key)
if (result == kIOReturnSuccess) {
// read succeeded - check returned value
if (val.dataSize > 0) {
if (strcmp(val.dataType, DATATYPE_FLT) == 0) {
return *((float*)val.bytes);
}

if (strcmp(val.dataType, DATATYPE_FPE2) == 0) {
// convert fpe2 value to RPM
return ntohs(*(UInt16*)val.bytes) / 4.0;
Expand Down Expand Up @@ -276,10 +280,8 @@ void readAndPrintFanRPMs(void)
if (rpm < 0.f) {
rpm = 0.f;
}
float pct = rpm / (maximum_speed - minimum_speed);

pct *= 100.f;
printf("Fan %d - %s at %.0f RPM (%.0f%%)\n", i, name, rpm, pct);
printf("Fan %d - %s at %.0f RPM (%.0f%%)\n", i, name, actual_speed, 100 * actual_speed / maximum_speed);

//sprintf(key, "F%dSf", i);
//SMCReadKey(key, &val);
Expand Down
1 change: 1 addition & 0 deletions smc.h
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@
#define SMC_CMD_READ_PLIMIT 11
#define SMC_CMD_READ_VERS 12

#define DATATYPE_FLT "flt "
#define DATATYPE_FPE2 "fpe2"
#define DATATYPE_UINT8 "ui8 "
#define DATATYPE_UINT16 "ui16"
Expand Down

0 comments on commit a6b714b

Please sign in to comment.