Package oshi.util.platform.mac
Class SmcUtil
java.lang.Object
oshi.util.platform.mac.SmcUtil
@ThreadSafe public final class SmcUtil extends java.lang.Object
Provides access to SMC calls on macOS
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static classSmcUtil.SMCKeyDataHolds the return value of SMC query.static classSmcUtil.SMCKeyDataKeyInfoHolds the return value of SMC KeyInfo query.static classSmcUtil.SMCKeyDataPLimitDataHolds the return value of SMC pLimit query.static classSmcUtil.SMCKeyDataVersHolds the return value of SMC version query.static classSmcUtil.SMCValHolds an SMC value -
Field Summary
Fields Modifier and Type Field Description static intKERNEL_INDEX_SMCstatic byteSMC_CMD_READ_BYTESstatic byteSMC_CMD_READ_KEYINFOstatic java.lang.StringSMC_KEY_CPU_TEMPstatic java.lang.StringSMC_KEY_CPU_VOLTAGEstatic java.lang.StringSMC_KEY_FAN_NUMstatic java.lang.StringSMC_KEY_FAN_SPEED -
Method Summary
Modifier and Type Method Description static intsmcCall(com.sun.jna.platform.mac.IOKit.IOConnect conn, int index, SmcUtil.SMCKeyData inputStructure, SmcUtil.SMCKeyData outputStructure)Call SMCstatic intsmcClose(com.sun.jna.platform.mac.IOKit.IOConnect conn)Close connection to SMC.static doublesmcGetFloat(com.sun.jna.platform.mac.IOKit.IOConnect conn, java.lang.String key)Get a value from SMC which is in a floating point datatype (SP78, FPE2, FLT)static intsmcGetKeyInfo(com.sun.jna.platform.mac.IOKit.IOConnect conn, SmcUtil.SMCKeyData inputStructure, SmcUtil.SMCKeyData outputStructure)Get cached keyInfo if it exists, or generate new keyInfostatic longsmcGetLong(com.sun.jna.platform.mac.IOKit.IOConnect conn, java.lang.String key)Get a 64-bit integer value from SMCstatic com.sun.jna.platform.mac.IOKit.IOConnectsmcOpen()Open a connection to SMC.static intsmcReadKey(com.sun.jna.platform.mac.IOKit.IOConnect conn, java.lang.String key, SmcUtil.SMCVal val)Read a key from SMC
-
Field Details
-
SMC_KEY_FAN_NUM
public static final java.lang.String SMC_KEY_FAN_NUM- See Also:
- Constant Field Values
-
SMC_KEY_FAN_SPEED
public static final java.lang.String SMC_KEY_FAN_SPEED- See Also:
- Constant Field Values
-
SMC_KEY_CPU_TEMP
public static final java.lang.String SMC_KEY_CPU_TEMP- See Also:
- Constant Field Values
-
SMC_KEY_CPU_VOLTAGE
public static final java.lang.String SMC_KEY_CPU_VOLTAGE- See Also:
- Constant Field Values
-
SMC_CMD_READ_BYTES
public static final byte SMC_CMD_READ_BYTES- See Also:
- Constant Field Values
-
SMC_CMD_READ_KEYINFO
public static final byte SMC_CMD_READ_KEYINFO- See Also:
- Constant Field Values
-
KERNEL_INDEX_SMC
public static final int KERNEL_INDEX_SMC- See Also:
- Constant Field Values
-
-
Method Details
-
smcOpen
public static com.sun.jna.platform.mac.IOKit.IOConnect smcOpen()Open a connection to SMC.- Returns:
- The connection if successful, null if failure
-
smcClose
public static int smcClose(com.sun.jna.platform.mac.IOKit.IOConnect conn)Close connection to SMC.- Parameters:
conn- The connection- Returns:
- 0 if successful, nonzero if failure
-
smcGetFloat
public static double smcGetFloat(com.sun.jna.platform.mac.IOKit.IOConnect conn, java.lang.String key)Get a value from SMC which is in a floating point datatype (SP78, FPE2, FLT)- Parameters:
conn- The connectionkey- The key to retrieve- Returns:
- Double representing the value
-
smcGetLong
public static long smcGetLong(com.sun.jna.platform.mac.IOKit.IOConnect conn, java.lang.String key)Get a 64-bit integer value from SMC- Parameters:
conn- The connectionkey- The key to retrieve- Returns:
- Long representing the value
-
smcGetKeyInfo
public static int smcGetKeyInfo(com.sun.jna.platform.mac.IOKit.IOConnect conn, SmcUtil.SMCKeyData inputStructure, SmcUtil.SMCKeyData outputStructure)Get cached keyInfo if it exists, or generate new keyInfo- Parameters:
conn- The connectioninputStructure- Key data inputoutputStructure- Key data output- Returns:
- 0 if successful, nonzero if failure
-
smcReadKey
public static int smcReadKey(com.sun.jna.platform.mac.IOKit.IOConnect conn, java.lang.String key, SmcUtil.SMCVal val)Read a key from SMC- Parameters:
conn- The connectionkey- Key to readval- Structure to receive the result- Returns:
- 0 if successful, nonzero if failure
-
smcCall
public static int smcCall(com.sun.jna.platform.mac.IOKit.IOConnect conn, int index, SmcUtil.SMCKeyData inputStructure, SmcUtil.SMCKeyData outputStructure)Call SMC- Parameters:
conn- The connectionindex- Kernel indexinputStructure- Key data inputoutputStructure- Key data output- Returns:
- 0 if successful, nonzero if failure
-