Recent

Author Topic: Question about RPI_HAL CPU info  (Read 822 times)

pascalbythree

  • Sr. Member
  • ****
  • Posts: 256
Question about RPI_HAL CPU info
« on: May 27, 2022, 04:01:15 pm »
Code: Pascal  [Select][+][-]
  1. procedure RPI_show_cpu_info;
  2. begin
  3.   writeln('rpi Snr  : ',RPI_snr);
  4.   writeln('rpi HW   : ',RPI_hw);
  5.   writeln('rpi proc : ',RPI_proc);
  6.   writeln('rpi rev  : ',RPI_rev);
  7.   writeln('rpi mips : ',RPI_mips);
  8.   writeln('rpi Freq : ',RPI_freq);
  9.   writeln('rpi Osci : ',(CLK_GetFreq(1)/1000000):7:2,' MHz');
  10.   writeln('rpi PLLC : ',(CLK_GetFreq(5)/1000000):7:2,' MHz (CoreFreq)');
  11.   writeln('rpi PLLD : ',(CLK_GetFreq(6)/1000000):7:2,' MHz');
  12.   writeln('rpi HDMI : ',(CLK_GetFreq(7)/1000000):7:2,' MHz');
  13.   writeln('CLK min  : ',(CLK_GetMinFreq/1000):   7:2,' kHz');
  14.   writeln('CLK max  : ',(CLK_GetMaxFreq/1000000):7:2,' MHz');
  15.   writeln('PWMHW min: ',(PWM_GetMinFreq(PWM_DIVImax)/1.0):7:2,' Hz');
  16.   writeln('PWMHW max: ',(PWM_GetMaxFreq(PWM_DIVImin)/1000):7:2,' kHz');
  17. 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
« Last Edit: May 27, 2022, 04:02:59 pm by pascalbythree »

Thaddy

  • Hero Member
  • *****
  • Posts: 14363
  • Sensorship about opinions does not belong here.
Re: Question about RPI_HAL CPU info
« Reply #1 on: May 28, 2022, 04:52:59 pm »
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  [Select][+][-]
  1. 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  [Select][+][-]
  1. program cpuload;
  2. uses cthreads, classes;
  3. var
  4.   s:Tstrings;
  5. begin
  6.   s:= TStringlist.Create;
  7.   s.loadfromfile('/proc/loadavg');
  8.   writeln(s.text);
  9.   // etc;
  10.   s.free;
  11. end.
Untested, but should be close.
« Last Edit: May 28, 2022, 09:24:42 pm by Thaddy »
Object Pascal programmers should get rid of their "component fetish" especially with the non-visuals.


 

TinyPortal © 2005-2018