Forum > Linux

Question about RPI_HAL CPU info

(1/1)

pascalbythree:

--- Code: Pascal  [+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i < x.length; i++) { x[i].style.maxHeight='none'; x[i].style.height = Math.min(x[i].clientHeight+15,306)+'px'; x[i].style.resize = "vertical";}};} ---procedure RPI_show_cpu_info;begin  writeln('rpi Snr  : ',RPI_snr);  writeln('rpi HW   : ',RPI_hw);  writeln('rpi proc : ',RPI_proc);  writeln('rpi rev  : ',RPI_rev);  writeln('rpi mips : ',RPI_mips);  writeln('rpi Freq : ',RPI_freq);  writeln('rpi Osci : ',(CLK_GetFreq(1)/1000000):7:2,' MHz');  writeln('rpi PLLC : ',(CLK_GetFreq(5)/1000000):7:2,' MHz (CoreFreq)');  writeln('rpi PLLD : ',(CLK_GetFreq(6)/1000000):7:2,' MHz');  writeln('rpi HDMI : ',(CLK_GetFreq(7)/1000000):7:2,' MHz');   writeln('CLK min  : ',(CLK_GetMinFreq/1000):   7:2,' kHz');  writeln('CLK max  : ',(CLK_GetMaxFreq/1000000):7:2,' MHz');  writeln('PWMHW min: ',(PWM_GetMinFreq(PWM_DIVImax)/1.0):7:2,' Hz');  writeln('PWMHW max: ',(PWM_GetMaxFreq(PWM_DIVImin)/1000):7:2,' kHz'); end;
Can anybody help reading the raspberry CPU usage in freepascal with for example RPI_HAL ?
Can anybody read if the above procedure is to read CPU usage ? Witch variable ? or bad luck?

Greetz, Wouter van Wegen, PascalByThree

It has to read out quick, to fill the graph form below. Cross compiled to my RPI

Thaddy:
well, the usual way to do that is reading loadavg with a timer.
Total CPU load is the first value and should be multiplied by 100 to get the percentage.

--- Code: Bash  [+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i < x.length; i++) { x[i].style.maxHeight='none'; x[i].style.height = Math.min(x[i].clientHeight+15,306)+'px'; x[i].style.resize = "vertical";}};} ---cat /proc/loadavg But you can also read that into a memo, label, whatever, in code.
Note that "everything in Unix is a file" applies here: It is a real time value. You can connect it to a timer.
E.g. the TOP command/program also utilizes loadavg.

--- Code: Pascal  [+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i < x.length; i++) { x[i].style.maxHeight='none'; x[i].style.height = Math.min(x[i].clientHeight+15,306)+'px'; x[i].style.resize = "vertical";}};} ---program cpuload;uses cthreads, classes;var  s:Tstrings;begin  s:= TStringlist.Create;  s.loadfromfile('/proc/loadavg');  writeln(s.text);  // etc;  s.free;end. Untested, but should be close.

Thausand:
https://forum.lazarus.freepascal.org/index.php/topic,59344.msg442437.html#msg442437

Navigation

[0] Message Index

Go to full version