Reload config when modified

This commit is contained in:
hbriese 2020-08-07 16:58:36 +10:00
parent 3650458474
commit dfdda3b1b7

View file

@ -541,6 +541,10 @@ def set_disable_bdprochot():
log('[D] BDPROCHOT - write "{:#02x}" - read "{:#02x}" - match {}'.format(0, read_value, match))
def get_config_write_time():
return os.stat(args.config).st_mtime
def power_thread(config, regs, exit_event):
try:
mchbar_mmio = MMIO(0xFED159A0, 8)
@ -550,6 +554,7 @@ def power_thread(config, regs, exit_event):
mchbar_mmio = None
next_hwp_write = 0
last_config_write_time = get_config_write_time()
while not exit_event.is_set():
# log thermal status
if args.debug:
@ -558,6 +563,13 @@ def power_thread(config, regs, exit_event):
for key, value in core_thermal_status.items():
log('[D] core {} thermal status: {} = {}'.format(index, key.replace("_", " "), value))
# Reload config when modified
config_write_time = get_config_write_time()
if last_config_write_time != config_write_time:
last_config_write_time = config_write_time
config = load_config()
log('[I] Reloading changes.')
# switch back to sysfs polling
if power['method'] == 'polling':
power['source'] = 'BATTERY' if is_on_battery(config) else 'AC'