Query memory and CPU on CE6

Hello,
We recently received the specifications of a tender we are participating in with our devices.
We have been asked to make the user able to navigate a dedicated information page on the device and see the module’s CPU frequency (both total and in use) and RAM capacity (both total, available, and in use MB).

We do have a dedicated information page where we put other info, including the current storage capacity of the SD Card mounted in the device (using the Windows CE API GetDiskFreeSpaceEx).

I’m missing how to retrieve information related to the RAM and CPU.
Is there anything available from Windows on CE to use for this? Do I need external libraries, and if so are they available from Toradex website?
I hope it’s not too complicated…

Thank you.

Enrico

Colibri VF61 256MB IT
Custom board
CE6 BSP 1.5

Hi, I’m the Toradex AI Assistant. I’m in early beta, and I would appreciate your feedback.
The Toradex Support team will follow up with you shortly!

Did you like my answer?

:+1: :-1:


Hello,

For your query regarding retrieving CPU frequency and RAM capacity information on a device running Windows CE, specifically on a Colibri VF61 module, you’re looking into functionalities that are somewhat outside the typical use case for Toradex’s Linux-based solutions. However, I can provide some general guidance that might help you navigate towards a solution within the Windows CE environment.

Windows CE provides various system APIs that can be used to gather system information, including memory and CPU details. While Toradex primarily focuses on Linux and Torizon for its modules, the principles for accessing system information can be somewhat universal.

  1. CPU Frequency: For CPU frequency, Windows CE does not directly provide an API similar to what you’ve used with GetDiskFreeSpaceEx for storage. CPU frequency information might be obtained through specific OEM implementations or by querying the registry if the frequency is statically set and stored there by the BSP (Board Support Package). You might need to consult the documentation for the CE6 BSP 1.5 for the Colibri VF61 or reach out to the community or forums focused on Windows CE development for more specific guidance.

  2. RAM Capacity: For RAM information, you can use the GlobalMemoryStatus function. This function fills a MEMORYSTATUS structure with information about the system’s current usage of both physical and virtual memory. Here’s a brief example of how you might use it:

MEMORYSTATUS memStatus;
memStatus.dwLength = sizeof(memStatus);
GlobalMemoryStatus(&memStatus);

// You can now access memStatus.dwTotalPhys for total physical memory,
// memStatus.dwAvailPhys for available physical memory, etc.

This function provides a straightforward way to get both the total and available physical memory, which seems to be what you’re looking for.

Regarding external libraries or tools specifically from Toradex for Windows CE to accomplish these tasks, Toradex’s primary focus and support are on Linux-based solutions like Torizon. For Windows CE, while Toradex provides BSPs and some support for its hardware, the software tools and libraries for specific tasks like monitoring CPU and memory might not be directly available from Toradex.

Given the specific nature of your requirements and the operating system in question, I recommend exploring Windows CE-specific resources, forums, or Microsoft’s documentation for more detailed guidance on accessing system information through Windows CE APIs.

Best regards,
Toradex AI Assistant

Please, also check if these links can help you solve your problem:

Create a Single-Container Project | Toradex Developer Center.

The part about how to retrieve info on the RAM got answered (I still have to test it), but I’m missing an answer on how to retrieve info on the CPU.

Please can somebody help?

Thank you.

The CPU on the Colibri VF61 runs at a fixed speed of 500MHz, so you can simply print this value. To get the CPU load (or idle) percentage, you can use the GetIdleTime() function.

DWORD dwStartTick, dwStopTick;
DWORD dwIdleSt, dwIdleEd;
DWORD PercentIdle;
DWORD sleep_time = 1000; // Sleep time in milliseconds

// Measure initial tick count and idle time
dwStartTick = GetTickCount();
dwIdleSt = GetIdleTime();

// Sleep to allow idle time to accrue
Sleep(sleep_time);

// Measure tick count and idle time again
dwStopTick = GetTickCount();
dwIdleEd = GetIdleTime();

// Calculate the percentage of idle time
PercentIdle = ((100 * (dwIdleEd - dwIdleSt)) / (dwStopTick - dwStartTick));

// Calculate CPU load as the complement of idle time
DWORD CpuLoad = 100 - PercentIdle;

Thank you!
I will do that.

I’m testing the GlobalMemoryStatus API on both this project that runs on a VF61 and another project that runs on a T20.
I would not expect too much of a difference between the two.

What I would like to know, if someone knows the answer, is why I see on the T20 a dwTotalPhys of 120045568bytes (roughly 114MB) when I was expecting to see 256MB.
Furthermore, I wasn’t expecting to see the dwAvailPhys is only roughly 25MB, but I guess that is just how it is.
On the VF61 is slightly better but similar: dwTotalPhys is roughly 207MB on a nominal 256MB.

I’m collecting this information to inform the end-users by writing it on our About page on the device, so it doesn’t look good.
Do I have to write a fixed total of 256MB instead? I can do that, but in that case, the ratio between fixed and available for the T20 would be even worse than the 20% ratio between total and available given by this API.

Please help.
Thank you