Package oshi.util.platform.mac
Class SmcUtil
java.lang.Object
oshi.util.platform.mac.SmcUtil
Provides access to SMC calls on macOS
-
Field Summary
FieldsModifier and TypeFieldDescriptionprivate static final byte[]
private static final byte[]
private static final byte[]
Byte array used for matching return typeprivate static final IOKit
static final int
private static Map
<Integer, IOKit.SMCKeyDataKeyInfo> Thread-safe map for caching info retrieved by a key necessary for subsequent calls.private static final org.slf4j.Logger
static final byte
static final byte
static final String
static final String
static final String
static final String
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic int
smcCall
(com.sun.jna.platform.mac.IOKit.IOConnect conn, int index, IOKit.SMCKeyData inputStructure, IOKit.SMCKeyData outputStructure) Call SMCstatic int
smcClose
(com.sun.jna.platform.mac.IOKit.IOConnect conn) Close connection to SMC.static double
smcGetFloat
(com.sun.jna.platform.mac.IOKit.IOConnect conn, String key) Get a value from SMC which is in a floating point datatype (SP78, FPE2, FLT)static int
smcGetKeyInfo
(com.sun.jna.platform.mac.IOKit.IOConnect conn, IOKit.SMCKeyData inputStructure, IOKit.SMCKeyData outputStructure) Get cached keyInfo if it exists, or generate new keyInfostatic long
smcGetLong
(com.sun.jna.platform.mac.IOKit.IOConnect conn, String key) Get a 64-bit integer value from SMCstatic com.sun.jna.platform.mac.IOKit.IOConnect
smcOpen()
Open a connection to SMC.static int
smcReadKey
(com.sun.jna.platform.mac.IOKit.IOConnect conn, String key, IOKit.SMCVal val) Read a key from SMC
-
Field Details
-
LOG
private static final org.slf4j.Logger LOG -
IO
-
keyInfoCache
Thread-safe map for caching info retrieved by a key necessary for subsequent calls. -
DATATYPE_SP78
private static final byte[] DATATYPE_SP78Byte array used for matching return type -
DATATYPE_FPE2
private static final byte[] DATATYPE_FPE2 -
DATATYPE_FLT
private static final byte[] DATATYPE_FLT -
SMC_KEY_FAN_NUM
- See Also:
-
SMC_KEY_FAN_SPEED
- See Also:
-
SMC_KEY_CPU_TEMP
- See Also:
-
SMC_KEY_CPU_VOLTAGE
- See Also:
-
SMC_CMD_READ_BYTES
public static final byte SMC_CMD_READ_BYTES- See Also:
-
SMC_CMD_READ_KEYINFO
public static final byte SMC_CMD_READ_KEYINFO- See Also:
-
KERNEL_INDEX_SMC
public static final int KERNEL_INDEX_SMC- See Also:
-
-
Constructor Details
-
SmcUtil
private SmcUtil()
-
-
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
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
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, IOKit.SMCKeyData inputStructure, IOKit.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, String key, IOKit.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, IOKit.SMCKeyData inputStructure, IOKit.SMCKeyData outputStructure) Call SMC- Parameters:
conn
- The connectionindex
- Kernel indexinputStructure
- Key data inputoutputStructure
- Key data output- Returns:
- 0 if successful, nonzero if failure
-