FakeSMCSensor *FakeSMCPlugin::addTachometer(UInt32 index, const char* name, SInt8 *fanIndex) { SInt8 vacantFanIndex = takeVacantFanIndex(); if (vacantFanIndex >= 0) { char key[5]; snprintf(key, 5, KEY_FORMAT_FAN_SPEED, vacantFanIndex); if (FakeSMCSensor *sensor = addSensor(key, TYPE_FPE2, 2, kFakeSMCTachometerSensor, index)) { if (name) { snprintf(key, 5, KEY_FORMAT_FAN_ID, vacantFanIndex); if (!setKeyValue(key, TYPE_CH8, strlen(name), name)) HWSensorsWarningLog("failed to add tachometer name for key %s", key); } if (fanIndex) *fanIndex = vacantFanIndex; return sensor; } else HWSensorsErrorLog("failed to add tachometer sensor for key %s", key); } else HWSensorsErrorLog("failed to take vacant Fan index"); return 0; }
FakeSMCSensor *FakeSMCPlugin::addTachometer(UInt32 index, const char *name, FanType type, UInt8 zone, FanLocationType location, SInt8 *fanIndex) { SYNCLOCK; SInt8 vacantFanIndex = takeVacantFanIndex(); if (vacantFanIndex >= 0) { char key[5]; snprintf(key, 5, KEY_FORMAT_FAN_SPEED, vacantFanIndex); if (FakeSMCSensor *sensor = addSensor(key, TYPE_FPE2, TYPE_FPXX_SIZE, kFakeSMCTachometerSensor, index)) { FanTypeDescStruct fds; bzero(&fds, sizeof(fds)); fds.type = type; fds.ui8Zone = zone; fds.location = location; if (name) strlcpy(fds.strFunction, name, DIAG_FUNCTION_STR_LEN); else snprintf(fds.strFunction, DIAG_FUNCTION_STR_LEN, "MB Fan %X", index); snprintf(key, 5, KEY_FORMAT_FAN_ID, vacantFanIndex); if (!setKeyValue(key, TYPE_FDS, sizeof(fds), &fds)) HWSensorsWarningLog("failed to add tachometer name for key %s", key); if (fanIndex) *fanIndex = vacantFanIndex; SYNCUNLOCK; return sensor; } else HWSensorsErrorLog("failed to add tachometer sensor for key %s", key); } else HWSensorsErrorLog("failed to take vacant Fan index"); SYNCUNLOCK; return 0; }