Created
March 23, 2012 16:52
-
-
Save AeroNotix/2172714 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| from ctypes import (windll, Structure, byref, POINTER, | |
| c_char, c_ubyte, c_bool, c_uint, c_float) | |
| import time | |
| class CTSharedData(Structure): | |
| _fields_ = [ | |
| ("uiLoad", c_uint * 256), | |
| ("uiTjMax", c_uint * 128), | |
| ("uiCoreCnt", c_uint), | |
| ("uiCPUCnt", c_uint), | |
| ("fTemp", c_float * 256), | |
| ("fVID", c_float), | |
| ("fCPUSpeed", c_float), | |
| ("fFSBSpeed", c_float), | |
| ("fMultiplier", c_float), | |
| ("sCPUName", c_char * 100), | |
| ("ucFahrenheit", c_ubyte), | |
| ("ucDeltaToTjMax", c_ubyte)] | |
| dll_file = 'path/to/dll' | |
| ctlib = windll.LoadLibrary(dll_file) | |
| get_ctinfo = ctlib.fnGetCoreTempInfoAlt | |
| get_ctinfo.argtypes = [POINTER(CTSharedData)] | |
| get_ctinfo.restype = c_bool | |
| data = CTSharedData() | |
| while (1): | |
| if get_ctinfo(byref(data)): | |
| print("Core temperatures:") | |
| unit = 'F' if data.ucFahrenheit else 'C' | |
| core_temps = data.fTemp[:data.uiCoreCnt] | |
| for core, temp in enumerate(core_temps): | |
| print(" Core {0}: {1:.2f} {2}".format(core, temp, unit)) | |
| else: | |
| print('Error accessing Core Temp') |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment