From fc9261834b700eb0e9d80ba23bc678f069aae601 Mon Sep 17 00:00:00 2001 From: Sondre Date: Mon, 15 Apr 2024 00:14:36 +0200 Subject: [PATCH 1/2] add grep filter --- uc_tronics_display/lcd_display/rpiInfo.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/uc_tronics_display/lcd_display/rpiInfo.c b/uc_tronics_display/lcd_display/rpiInfo.c index c1cd831..bfbaaf8 100644 --- a/uc_tronics_display/lcd_display/rpiInfo.c +++ b/uc_tronics_display/lcd_display/rpiInfo.c @@ -174,11 +174,11 @@ uint8_t get_cpu_message(void) int usCpu = 0; int syCpu = 0; - fp=popen("top -bn1 | grep %Cpu | awk '{printf \"%.2f\", $(2)}'","r"); //Gets the load on the CPU + fp=popen("top -bn1 | grep -m 1 -e CPU | awk '{printf \"%.2f\", $(2)}'","r"); //Gets the load on the CPU fgets(usCpuBuff, sizeof(usCpuBuff),fp); //Read the user CPU load pclose(fp); - fp=popen("top -bn1 | grep %Cpu | awk '{printf \"%.2f\", $(4)}'","r"); //Gets the load on the CPU + fp=popen("top -bn1 | grep -m 1 -e CPU | awk '{printf \"%.2f\", $(4)}'","r"); //Gets the load on the CPU fgets(syCpubuff, sizeof(syCpubuff),fp); //Read the system CPU load pclose(fp); usCpu = atoi(usCpuBuff); From f322469f8ba5ef3d8abb88fd4299627a71617570 Mon Sep 17 00:00:00 2001 From: Sondre Date: Mon, 15 Apr 2024 00:29:39 +0200 Subject: [PATCH 2/2] removed float conversion --- uc_tronics_display/lcd_display/rpiInfo.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/uc_tronics_display/lcd_display/rpiInfo.c b/uc_tronics_display/lcd_display/rpiInfo.c index bfbaaf8..e4ae0cd 100644 --- a/uc_tronics_display/lcd_display/rpiInfo.c +++ b/uc_tronics_display/lcd_display/rpiInfo.c @@ -174,11 +174,11 @@ uint8_t get_cpu_message(void) int usCpu = 0; int syCpu = 0; - fp=popen("top -bn1 | grep -m 1 -e CPU | awk '{printf \"%.2f\", $(2)}'","r"); //Gets the load on the CPU + fp=popen("top -bn1 | grep -m 1 -e CPU | awk '{printf \"%d\", $(2)}'","r"); //Gets the load on the CPU fgets(usCpuBuff, sizeof(usCpuBuff),fp); //Read the user CPU load pclose(fp); - fp=popen("top -bn1 | grep -m 1 -e CPU | awk '{printf \"%.2f\", $(4)}'","r"); //Gets the load on the CPU + fp=popen("top -bn1 | grep -m 1 -e CPU | awk '{printf \"%d\", $(4)}'","r"); //Gets the load on the CPU fgets(syCpubuff, sizeof(syCpubuff),fp); //Read the system CPU load pclose(fp); usCpu = atoi(usCpuBuff);