Пример #1
0
kern_return_t SMCWriteKey(io_connect_t conn, const SMCVal_t *val)
{    
    SMCVal_t      readVal;
    
    IOReturn result = SMCReadKey(conn, val->key, &readVal);
    if (result != kIOReturnSuccess) 
        return result;
    
    if (readVal.dataSize != val->dataSize)
        return kIOReturnError;
    
    return SMCWriteKeyUnsafe(conn, val);
}
Пример #2
0
double SMCGetTemperature(char *key)
{
    SMCVal_t val;
    kern_return_t result;

    result = SMCReadKey(key, &val);
    if (result == kIOReturnSuccess) {
        // read succeeded - check returned value
        if (val.dataSize > 0) {
            if (strcmp(val.dataType, DATATYPE_SP78) == 0) {
                // convert fp78 value to temperature
                int intValue = (val.bytes[0] * 256 + val.bytes[1]) >> 2;
                return intValue / 64.0;
            }
        }
    }
Пример #3
0
IoObject *IoAppleSensors_getRAMTemperature(IoAppleSensors *self, IoObject *locals, IoMessage *m)
{
	/*doc AppleSensors getRAMTemperature
		Returns a number for the RAM temperature sensor.
	 */
	SMCVal_t val = createEmptyValue();
	char cStr[16];
	kern_return_t result = SMCReadKey("TM0P", &val);
	if (result == kIOReturnSuccess) {
		result = representValue(val, &cStr[0]);
		if (result == TRUE) {
			float ftemp = atof(&cStr[0]);
			return IONUMBER(ftemp);
		}
	}
	return IONUMBER(-127);
}