From 3dcf2fd837584b5e4481b5a9f23438d65a507502 Mon Sep 17 00:00:00 2001 From: Adnan Hodzic Date: Sun, 21 May 2023 14:03:29 +0200 Subject: [PATCH] Ensure all core indices are handled, RPI 4 support --- auto_cpufreq/core.py | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) diff --git a/auto_cpufreq/core.py b/auto_cpufreq/core.py index 9d1e33e..2dcdff1 100644 --- a/auto_cpufreq/core.py +++ b/auto_cpufreq/core.py @@ -1135,10 +1135,20 @@ def sysinfo(): cpu_core = dict() freq_per_cpu = [] for i in range(0, len(coreid_info), 3): - freq_per_cpu.append(float(coreid_info[i + 1].split(":")[-1])) + # ensure that indices are within the valid range, before accessing the corresponding elements + if i + 1 < len(coreid_info): + freq_per_cpu.append(float(coreid_info[i + 1].split(":")[-1])) + else: + # handle the case where the index is out of range + continue + # ensure that indices are within the valid range, before accessing the corresponding elements cpu = int(coreid_info[i].split(":")[-1]) - core = int(coreid_info[i + 2].split(":")[-1]) - cpu_core[cpu] = core + if i + 2 < len(coreid_info): + core = int(coreid_info[i + 2].split(":")[-1]) + cpu_core[cpu] = core + else: + # handle the case where the index is out of range + continue online_cpu_count = len(cpu_core) offline_cpus = [str(cpu) for cpu in range(total_cpu_count) if cpu not in cpu_core]