Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: Display of the CPU fan speed on Catalina, #28 #30

Closed
wants to merge 3 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 5 additions & 1 deletion 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 @@ -279,7 +283,7 @@ void readAndPrintFanRPMs(void)
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
5 changes: 3 additions & 2 deletions smc.h
Original file line number Diff line number Diff line change
Expand Up @@ -32,15 +32,16 @@
#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"
#define DATATYPE_UINT32 "ui32"
#define DATATYPE_SP78 "sp78"

// key values
#define SMC_KEY_CPU_TEMP "TC0P"
#define SMC_KEY_GPU_TEMP "TG0P"
#define SMC_KEY_CPU_TEMP "TCXC"
#define SMC_KEY_GPU_TEMP "TCGC"
#define SMC_KEY_FAN0_RPM_CUR "F0Ac"

typedef struct {
Expand Down