Хочу использовать функции из фреймворка MacOS (IntelPowerGadget).
На данный момент я написал следующее
Код: Выделить всё
if sys.platform == 'darwin':
bundle = objc.loadBundle(
"IntelPowerGadget",
bundle_path="/Library/Frameworks/IntelPowerGadget.framework",
module_globals=globals(),
)
functions = [('PG_Initialize', objc._C_VOID),]
#('PG_ReadSample',...),
#('PGSample_GetPackageTemperature',...)]
objc.loadBundleFunctions(bundle, globals(), functions)
PG_Initialize()
Я тоже не могу найти достаточно документации (буду признателен за ссылки - если Я не там ищу).
upd с ответом @ali-saberi:
Код: Выделить всё
import objc
import ctypes
import sys
if sys.platform == 'darwin':
# Load the Intel Power Gadget framework
bundle = objc.loadBundle(
"IntelPowerGadget",
bundle_path="/Library/Frameworks/IntelPowerGadget.framework",
module_globals=globals(),
)
# Define PGSampleID as ctypes type (assuming it's an integer or a pointer type)
PGSampleID = ctypes.c_void_p # Assuming PGSampleID is a pointer. Adjust if it's another type.
# Define the functions
functions = [
('PG_Initialize', objc._C_BOOL),
('PG_ReadSample', objc._C_BOOL + objc._C_INT + objc._C_PTR + objc._C_ULNG_LNG),
('PGSample_GetPackageTemperature', objc._C_BOOL + objc._C_ULNG_LNG + objc._C_PTR + objc._C_DBL),
]
# Load the functions
objc.loadBundleFunctions(bundle, globals(), functions)
# Initialize the library
if not PG_Initialize():
print("Failed to initialize Intel Power Gadget")
sys.exit(1)
# Use PG_ReadSample
sample_id = PGSampleID() # Placeholder for PGSampleID pointer
iPackage = 0 # Assume we're reading from package 0
if PG_ReadSample(iPackage, ctypes.byref(sample_id)):
print("Sample read successfully")
# Use PGSample_GetPackageTemperature
temperature = ctypes.c_double()
if PGSample_GetPackageTemperature(sample_id, ctypes.byref(temperature)):
print(f"Package Temperature: {temperature.value}°C")
else:
print("Failed to get package temperature")
else:
print("Failed to read sample")
»ValueError: депитонификация «указателя», получен «CArgObject» '"
Подробнее здесь: https://stackoverflow.com/questions/793 ... owergadget
Мобильная версия