Stop Prime95 if CoreTemps hit 95*C

Fixes issue #90
This commit is contained in:
2Shirt 2019-02-05 21:34:47 -07:00
commit 82377bc1ab
Signed by: 2Shirt
GPG key ID: 152FAC923B0E132C
3 changed files with 33 additions and 6 deletions

View file

@ -1262,6 +1262,7 @@ def run_mprime_test(state, test):
test.update_status()
update_progress_pane(state)
test.sensor_data = get_sensor_data()
test.thermal_abort = False
# Update tmux layout
tmux_update_pane(
@ -1303,6 +1304,7 @@ def run_mprime_test(state, test):
command=['hw-diags-prime95', global_vars['TmpDir']],
working_dir=global_vars['TmpDir'])
time_limit = int(MPRIME_LIMIT) * 60
thermal_limit = int(THERMAL_LIMIT)
try:
for i in range(time_limit):
clear_screen()
@ -1319,15 +1321,19 @@ def run_mprime_test(state, test):
# Not using print wrappers to avoid flooding the log
print(_status_str)
print('{YELLOW}{msg}{CLEAR}'.format(msg=test.abort_msg, **COLORS))
update_sensor_data(test.sensor_data)
update_sensor_data(test.sensor_data, thermal_limit)
# Wait
sleep(1)
except KeyboardInterrupt:
# Catch CTRL+C
except (KeyboardInterrupt, ThermalLimitReachedError) as err:
# CTRL+c pressed or thermal limit reached
test.aborted = True
test.update_status('Aborted')
print_warning('\nAborted.')
if isinstance(err, KeyboardInterrupt):
test.update_status('Aborted')
elif isinstance(err, ThermalLimitReachedError):
test.failed = True
test.thermal_abort = True
test.update_status('NS')
update_progress_pane(state)
# Restart live monitor
@ -1428,6 +1434,16 @@ def run_mprime_test(state, test):
test.sensor_data, 'Idle', 'Max', 'Cooldown', core_only=True):
test.report.append(' {}'.format(line))
# Add abort message(s)
if test.aborted:
test.report.append(
' {YELLOW}Aborted{CLEAR}'.format(**COLORS))
if test.thermal_abort:
test.report.append(
' {RED}CPU reached temperature limit of {temp}°C{CLEAR}'.format(
temp=THERMAL_LIMIT,
**COLORS))
# Done
update_progress_pane(state)

View file

@ -19,6 +19,11 @@ TEMP_LIMITS = {
REGEX_COLORS = re.compile(r'\033\[\d+;?1?m')
# Error Classes
class ThermalLimitReachedError(Exception):
pass
def clear_temps(sensor_data):
"""Clear saved temps but keep structure, returns dict."""
for _section, _adapters in sensor_data.items():
@ -214,7 +219,7 @@ def save_average_temp(sensor_data, temp_label, seconds=10):
_data[temp_label] = sum(_data['Temps']) / len(_data['Temps'])
def update_sensor_data(sensor_data):
def update_sensor_data(sensor_data, thermal_limit=None):
"""Read sensors and update existing sensor_data, returns dict."""
json_data = get_raw_sensor_data()
for _section, _adapters in sensor_data.items():
@ -230,6 +235,11 @@ def update_sensor_data(sensor_data):
# Dumb workound for Dell sensors with changing source names
pass
# Check if thermal limit reached
if thermal_limit and _section == 'CoreTemps':
if max(_data['Current'], _data['Max']) >= thermal_limit:
raise ThermalLimitReachedError('CoreTemps reached limit')
def join_columns(column1, column2, width=55):
return '{:<{}}{}'.format(

View file

@ -16,6 +16,7 @@ KIT_NAME_SHORT='WK'
SUPPORT_MESSAGE='Please let 2Shirt know by opening an issue on GitHub'
# Live Linux
MPRIME_LIMIT='7' # of minutes to run Prime95 during hw-diags
THERMAL_LIMIT='95' # Prime95 abort temperature in Celsius
ROOT_PASSWORD='Abracadabra'
TECH_PASSWORD='Abracadabra'
# Server IP addresses