Skip to content
Open
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
21 changes: 7 additions & 14 deletions smc.c
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@

static io_connect_t conn;


UInt32 _strtoul(char* str, int size, int base)
{
UInt32 total = 0;
Expand Down Expand Up @@ -55,6 +56,10 @@ kern_return_t SMCOpen(void)
io_iterator_t iterator;
io_object_t device;

#ifndef kIOMainPortDefault
#define kIOMainPortDefault kIOMasterPortDefault
#endif

CFMutableDictionaryRef matchingDictionary = IOServiceMatching("AppleSMC");
result = IOServiceGetMatchingServices(kIOMainPortDefault, matchingDictionary, &iterator);
if (result != kIOReturnSuccess) {
Expand Down Expand Up @@ -268,26 +273,14 @@ void readAndPrintFanRPMs(void)
continue;
}

float rpm = actual_speed - minimum_speed;
float rpm = actual_speed;
if (rpm < 0.f) {
rpm = 0.f;
}
float pct = rpm / (maximum_speed - minimum_speed);
float pct = rpm / maximum_speed;

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

//sprintf(key, "F%dSf", i);
//SMCReadKey(key, &val);
//printf(" Safe speed : %.0f\n", strtof(val.bytes, val.dataSize, 2));
//sprintf(key, "F%dTg", i);
//SMCReadKey(key, &val);
//printf(" Target speed : %.0f\n", strtof(val.bytes, val.dataSize, 2));
//SMCReadKey("FS! ", &val);
//if ((_strtoul((char *)val.bytes, 2, 16) & (1 << i)) == 0)
// printf(" Mode : auto\n");
//else
// printf(" Mode : forced\n");
}
}
}
Expand Down