Monday 24 May 2010

Summer 2010 EmbeddedSPARK Competition

To all you embedded hobbyists. I Just want to highlight the latest Microsoft embeddedSPARK compitition on this summer. Given the latest release, this round of the competition is focused on Embedded Standard 7.

You can find all the information you need to enter at http://www.embeddedspark.com/

A video about this can also be seen at http://www.embeddedspark.com/public/videos/embeddedSPARKSUMMER_howto.wmv

FYI - Round 1 closes on June 8
Any questions or issues I can help with please let me know.

>> Nigel

Thursday 20 May 2010

Setting up COM buffers

I was pointed to this today to set the size of serial buffers on WinCE:
 BOOL SetupComm(     HANDLE hFile,   DWORD dwInQueue,     DWORD dwOutQueue   );
This should control the internal buffer sizes for the COM port... but the amusing comment in MSDN says:
 Always returns FALSE because the FIFO queue size cannot be changed
Err... so does this work!?

Wednesday 12 May 2010

Realtime CPU calculation for CE debugging

Quite often I've been in the situation where a process or thread has gone rogue and I've been trying to track down why the system has ground to a halt.

One of the things I find most helpful is the SnapShot tools, this allows you to take a snapshot of the system for its current running processes or threads, this can be useful in itself but using the GetThreadTimes API you can then print out any high CPU users, basically creating your own mini-task manager for Windows CE.

Firstly take a snapshot of the system:

HANDLE hSnapshot = CreateToolhelp32Snapshot (TH32CS_SNAPTHREAD, 0);

Secondly call Thread32First/Next on the snapshot to retrieve all the thread information:

THREADENTRY32 te[256]; // up to 256 threads
int used = 0;
te[used].dwSize = sizeof(THREADENTRY32);
if ( Thread32First(hSnapshot,&te[used]) )
{
do
{
..
..

used++;
te[used].dwSize = sizeof(THREADENTRY32);
}
while (Thread32Next(hSnapshot,&te[used]));
}

Finally iterate through the threads getting their thread times, creating times etc:


FILETIME creationTime,exitTime;
FILETIME ktTime[256];
FILETIME utTime[256];
GetThreadTimes ((HANDLE)te[used].th32ThreadID,
&creationTime,
&exitTime,
&ktTime[used],
&utTime[used]);

This can be done in the while loop above, you can also use the results from the snapshot over and over with a sleep(1000), compare the results and print out the top XX threads using CPU to give some realtime feedback on the system usage.

Commonly my applications and kernel development use this method to ensure that the system is using the expected CPU time when being developed.


Thursday 6 May 2010

2010 Embedded Market Study shows Microsoft embedded OS's are on the way up...

The 2010 Embedded Market Study from EE Times group is out now, they reviewed 1,574 surveys on embedded designs.

This year we should be expecting the Wind River (VxWorks) to take the top 17% of upcoming embedded designs, followed by 13% for Debian (Linux), then Windows CE closely following at 13% and then Windows (XP Embedded) at 12%.

Windows CE and Windows XP Embedded are up 1% on last years survey, and between them take a whopping 25% of new designs, great news!

Check out the Webinar on http://www.techonline.com/learning/livewebinar/224000228 for on-demand playback.


Snooze using SleepTilTick

A not so well known function, this little API allows a thread to relinquish its hold on the system until the next tick normally 1ms great for polling loops when used in conjunction with high priority threads...