Wednesday, 17 April 2013

Disabling Visual Studio macro “tip” balloon

Thanks to Stack Overflow for showing how to get rid of the annoying tip balloon when running macros in Visual Studio.

http://stackoverflow.com/questions/48470/how-to-disable-visual-studio-macro-tip-balloon

The key is to create/set the "DontShowMacrosBalloon" value to dword:6 under [HKCU\Software\Microsoft\VisualStudio\9.0] etc.

Respect to these guys as this has been annoying me for ages...

MartinT

Thursday, 29 November 2012

Update to Removing Process & Thread IDs from WEC 7.0 Serial Debug Output

Following my earlier post I've found that setting

    g_pOemGlobal->pfnWriteDebugString = NULL;

has an unfortunate side-effect during suspend & resume in that any debug prints during OEMPowerOff will use the NULL function pointer and cause the system to crash.

The solution is to restore the kernel to use the default serial debug during OEMPowerOff()...

VOID BSPPowerOff()
{
    // If OEMInit() cleared g_pOemGlobal->pfnWriteDebugString to remove VID/PID
    // from debug output, g_pNKGlobal->pfnWriteDebugString will now be NULL (see
    // NKPowerOffSystem() in WINCE700\private\winceos\COREOS\nk\kernel\kwin32.c)
    if (NULL == g_pNKGlobal->pfnWriteDebugString)
    {
        // Set kernel pfnWriteDebugString so that debug prints in OEMPowerOff()
        // do not crash the system.
        // NKPowerOffSystem() will restore the orginal value following return
        // from OEMPowerOff()
        g_pNKGlobal->pfnWriteDebugString = (PFN_WriteDebugString)OEMWriteDebugString;
    }
}

Thursday, 14 June 2012

Choosing the right ARM based System on Module (SOM)

I am regularly in the situation where the choice of processor, module and thus vendor selection is still a customer question. This should not be a great surprise as there are so many variants for consideration. So I’ll try and help with my thought process and highlight the major considerations when making this selection. Read more... Let me know your thoughts

Friday, 20 April 2012

Removing Process & Thread IDs from WEC 7.0 Serial Debug Output

One nice feature in Windows Embedded Compact 7.0 is that, unlike earlier versions of Windows CE, the kernel prepends serial debug output with the process and thread identifiers:
PID:00400002 TID:00C4000A Device Power State = NdisDeviceStateD3.


In many cases this is useful and the output is now more like KITL debug output than before. 

With KITL debug output the Platform Builder Debug Message Options dialog gives you control of which information is prepended to the debug messages:


So, what happens if you want to remove the PID and TID from the serial debug trace to reduce the volume of information and/or increase speed?  There's no Platform Builder option to help.

The answer is to modify the OAL and set

g_pOemGlobal->pfnWriteDebugString = NULL;

Setting this pointer to NULL makes the kernel call g_pNKGlobal->pfnWriteDebugString directly instead of prepending the PID/TID information and calling OEMWriteDebugString().

You should be aware that this also bypasses thread synchronization but if you are happy to remove the PID/TID you are probably experienced enough to cope!

For more information refer to NKOutputDebugString and DoODS in WINCE700\PRIVATE\winceos\COREOS\nk\kernel\printf.c

Res2Res Errors During CE 6.0 Makeimg

Once again we are hitting problems during makeimg with

ERROR: Res2Res: WriteResFile: xxxxxxxxxxxxx

The problem can be “fixed” by either

1.       Disabling virus scanning of the temporary directory

2.       Emptying the temporary directory

My temp dir was full of rubbish so I used option 2.  The command line below is much quicker than using Explorer

del /q /f /s %temp%\*

This worked for me.  However, if the problem persists then try option 1.  It worked for a colleague.

Hope this helps!

Wednesday, 28 March 2012

Debugging CE7 apps using VS2005

If you want to build apps for a CE7 system using visual studio 2005 you can (normally you’d use 2008) if you have an SDK for the Windows Embedded Compact 7 (WinCE7) platform and you follow these steps!

I was getting the following error on linking:

corelibc.lib(armsecgs.obj) : fatal error LNK1103: debugging information corrupt; recompile module


To work around this:

- Install the hot fix for VS2005 from http://support.microsoft.com/kb/949009

- Fix any build issues in the project arising from defines not available in VS2005, i.e.:

From imm.h for instance:

DWORD WINAPI ImmGetGuideLineW(HIMC, DWORD dwIndex, _Out_bytecap_(dwBufLen) LPWSTR, DWORD dwBufLen);

To

DWORD WINAPI ImmGetGuideLineW(HIMC, DWORD dwIndex, LPWSTR, DWORD dwBufLen);

Basically removing all “_Out_bytecap_(dwBufLen)” from anything that doesn’t build…

- In the top of one of my files I needed to set

#define __INLINEISEQUALGUID__

As there seem to be two defines for the same named GUID equality function and it causes a link issue.

As the meerkat would say…Simples!

Tuesday, 10 May 2011

Windwos Embedded Compact 7

Direct Insight was recently involved in running a Windows Embedded Compact 7 event at the UK Microsoft Campus. From which an article has been written including information and quotes from me and colleagues.

You can find the article here at http://www.mtemag.com/ArticleItem.aspx?Cont_Title=Real-Time+Operating+Systems%3a+Take+seven

Please have a read and let me know what you think.

>> Nigel

Friday, 11 February 2011

Visual Studio 2005 deploy error after downloading a managed code application to a Windows CE6 R3 device

Thanks to William White for this:-

After deploying a managed code application to a windows CE6 R3 device you get a deployment error something like:

Deploying ‘C:\will\VBProjects\CEApp\bin\Debug\HelloWorld.exe’
Deploying ‘C:\Program Files\Microsoft Visual Studio 8\SmartDevices\SDK\CompactFramework\2.0\v2.0\windowsce\diagnostics\System_SR_enu.cab’
Post-deploy error 0×00000001 returned after calling ‘\Windows\wceload.exe /noui \Windows\System_SR_enu.cab’.
========== Build: 1

Visual Studio 2005 will attempt to download the .NET CF 2.0 cab file (System_SR_enu.cab) and automatically install if the device does not already contain the run time (however the OS dependencies for the .NET CF 2.0 must be included in the WinCE6 image). It appears that the version of .NET CF 2.0 included with Visual Studio 2005 SP1 is not compatible with the R3 release of Windows CE6. To fix the problem, shutdown all instances of Visual Studio 2005 and simply download and install .NET CF2.0 SP2:

http://www.microsoft.com/downloads/en/details.aspx?familyid=AEA55F2F-07B5-4A8C-8A44-B4E1B196D5C0&displaylang=en

Try again and everything should be fine.

A successful deployment should then look something like:

DeviceApplication1 -> C:\Documents and Settings\XPMUser\My Documents\Visual Studio 2005\Projects\DeviceApplication1\DeviceApplication1\bin\Debug\DeviceApplication1.exe
—— Deploy started: Project: DeviceApplication1, Configuration: Debug Any CPU ——
Deploying ‘C:\Program Files\Microsoft.NET\SDK\CompactFramework\v2.0\windowsce\wce500\armv4i\NETCFV2.wce5.armv4i.cab’
Deploying ‘C:\Documents and Settings\XPMUser\My Documents\Visual Studio 2005\Projects\DeviceApplication1\DeviceApplication1\bin\Debug\DeviceApplication1.exe’
Deploying ‘C:\Program Files\Microsoft.NET\SDK\CompactFramework\v2.0\windowsce\diagnostics\System_SR_enu.cab’
========== Build: 1 succeeded or up-to-date, 0 failed, 0 skipped ==========
========== Deploy: 1 succeeded, 0 failed, 0 skipped ==========

Monday, 10 January 2011

Keeping your Smartphone alive for background processing

Want to keep your windows mobile smart phone alive, even if the user is trying to force it off?

This can be achieved by using the unattended mode, the power manager on Windows Mobile has an unattended state that will effectively look like the phone is off but the CPU will be running in the background with the LCD off. This is used for playing music, downloading emails etc. To invoice this

PowerPolicyNotify(PPN_UNATTENDEDMODE, 1);

To release this do

PowerPolicyNotify(PPN_UNATTENDEDMODE, 0);

Whist in this state you may need to poke the device to stay on by calling the above function again. If you want to wake up the device then use another power API:

// Force backlight and power on
SetSystemPowerState(NULL, POWER_STATE_ON, POWER_FORCE);

This will force the system to wake up fully if you want to display information to the user after your background processing.

Wednesday, 1 December 2010

Why's my Alpha blend not working!!

That was what I was saying as I do an AlphaBlend() of a 32 bit bitmap nicely saved in Photoshop, the result was a bitmap with white as the 'background' instead of a nice transparent edge.

I've seen this before and moving between Desktop and WinCE I seem to have slightly different results with Alpha blending and image factory stuff. Anyhow I found a few people mentioning that you need to pre-multiply any alpha per pixel before using the Alpha blend (which has an alpha on the image as well). Sceptical but tried it and hey presto my bitmaps now render perfectly.

Here is what I do in Win32:

HBITMAP hbmp = CreateDIBSection(hdcScreen, lpbi, DIB_RGB_COLORS, &pvImageBits, NULL, 0);

const UINT cbImage = cbStride * height;
if (FAILED(ipBitmap->CopyPixels(NULL, cbStride, cbImage, static_cast<BYTE *>(pvImageBits))))
{
// couldn't extract image; delete HBITMAP
DeleteObject(hbmp);
hbmp = NULL;
}

// Pre multiply RGB on alpha channels else alpha blit won't work!
//
if (lpbi->bmiHeader.biBitCount == 32)
{
BYTE* linePtr = (BYTE*)pvImageBits;
for(int y=0;y<height;y++)
{
BYTE* ptr = linePtr;

for(int x=0;x<width;x++)
{
BYTE alpha = *(ptr+3);
*(ptr+0)=(*(ptr+0) * alpha) / 255;
*(ptr+1)=(*(ptr+1) * alpha) / 255;
*(ptr+2)=(*(ptr+2) * alpha) / 255;
ptr+=4;
}

linePtr += cbStride;
}
}
Then just AlphaBlend on my bitmap...perfect, but why doesn't AlphaBlend handle the 32 bit bitmaps anyhow that's what I don't understand.... !

Monday, 15 November 2010

Adding custom notifications to the WM6.5 lock screen

If you are wondering how your application can add information on the new WM6.5 lock screen, this can be done easily by utilising a few registry entries! There are two OEM lockscreen entries reserved for OEM applications that will allow applications to register an icon to show on the lock screen with an optional number of unread or unhandled events, when the user slides this to the right or left the application is invoked to deal with the unread events.

The regsitry entry all of this appears under is:

HKLM\Software\\Microsoft\\Shell\\LockScreen\\Notifications\\Notif0
HKLM\Software\\Microsoft\\Shell\\LockScreen\\Notifications\\Notif1

Add the settings like this:

"Command Line"="\program files\myapp\myapp.exe"
"Image"="\icon_notclicked.png"
"FocusImage"="\icon_clicked.png"
"Notification Count"=dword:0

The command line should point to your application, this will be executed when the user slides your cusom slider to the right. The Image and Focus image are two icons which are shown on the lock screen with and without you pressing them. The notification count should be more than 0 to show your icon and 0 to hide your item. The number in the noticication count is displayed on the lock screen so this could be the number of unread messages or emails you've received, whatever you are counting in your application.

You should check that Notif0 and 1 aren't already used by another application and use the appropriate one.

Happy screen locking!

Wednesday, 27 October 2010

Accessing the phone vibrator

How can I access the vibrate function from my apps you may say...?

Well the vibrate function is part of the NLED (or notification LED) driver. You can use the NLED functions to pulse or turn on/off the motor in the same way as any LED. To find the vibrator search through the list of LEDs until you find one with a cycle time of -1, this indicates the vibrator.

The following code is complete example of searching through the available LEDs and turning on and off only the vibrate function. This should work on any Windows Mobile or Windows CE with a compatible NLED driver:


#include "nled.h"

enum Status
{
OFF = 0,
ON,
BLINK
};

int GetLedCount()
{
int count = 0;
NLED_COUNT_INFO nci;
if (NLedGetDeviceInfo(NLED_COUNT_INFO_ID, &nci))
{
count = nci.cLeds;
}
return count;
}

int ledCount = GetLedCount();

void SetLedStatus(Status status)
{
NLED_SETTINGS_INFO nsi;
NLED_SUPPORTS_INFO nInfo;
nsi.OffOnBlink = (uint)status;
for (int i = 0; i < ledCount; i++)
{
// request information from this led, we're looking for a
// cycleAdjust of -1 which indicates the vibrator
nInfo.LedNum = i;
NLedGetDeviceInfo(NLED_SUPPORTS_INFO_ID, &nInfo);
if (nInfo.lCycleAdjust == -1)
{
nsi.LedNum = (uint)i;
NLedSetDevice(NLED_SETTINGS_INFO_ID, &nsi);
}
}
}

void VibrateOn()
{
SetLedStatus(Status::ON);
}

void VibrateOff()
{
SetLedStatus(Status::OFF);
}


int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance,
LPTSTR lpCmdLine, int nCmdShow)
{
VibrateOn();
Sleep(500);
VibrateOff();
}

Tuesday, 12 October 2010

Missing Ordinals in Windows CE

If you get the message:

ERROR: function @ Ordinal 297 missing
Please Check your SYSGEN variable!!!


Then the problem is most likely to be a missing funciton in CoreDLL, to check which it is go to the private sources:

\WINCE600\PRIVATE\WINCEOS\COREOS\CORE\DLL>notepad core_common.def

In this you should be able to search for the ordinal number

; @CESYSGEN IF COREDLL_BATTERY
BatteryDrvrGetLevels=BatteryDrvrGetLevels @297
BatteryDrvrSupportsChangeNotification=BatteryDrvrSupportsChangeNotification @298
BatteryGetLifeTimeInfo=BatteryGetLifeTimeInfo @713
BatteryNotifyOfTimeChange=BatteryNotifyOfTimeChange @714
GetSystemPowerStatusEx=GetSystemPowerStatusEx @715
GetSystemPowerStatusEx2=GetSystemPowerStatusEx2 @1358
; @CESYSGEN ENDIF

Wednesday, 29 September 2010

Using events and waking devices using CeRunAppAtTime

Want to wake up a CE device at a future time (even if it is suspend), then use the CeRunAppAtTime but instead of running an app use a named event, this allows an application to wake up the device at a set time and also trap the wake event without spawning another process:

SYSTEMTIME time;
CTime nextWakeUpTime;

// get local system time and convert time to CTime for now
GetLocalTime(&time);
CTime now(time);

// 30 minutes in the future
nextWakeUpTime=now;
nextWakeUpTime+=CTimeSpan(0,0,30,0);

// convert to systemtime
nextWakeUpTime.GetAsSystemTime(time);

// set for wake up !
CeRunAppAtTime(TEXT("\\\\.\\Notifications\\NamedEvents\\SCHEDULE_WAKEEVENT_EVENT"), &time);

HANDLE wakeEvent = CreateEvent(NULL, FALSE, FALSE, SCHEDULE_WAKEEVENT_EVENT);

// wait for wake up!
if (WaitForSingleObject(wakeEvent, FALSE, INFINITE) == WAIT_OBJECT_0)
{
// sheduled wake up
}

Friday, 10 September 2010

KITL Messages Don't Support Wide Strings

I've just tracked down a minor irritation with KITL_RETAILMSG and KITL_DEBUGMSG under CE 6.0 R3 - they can't print UNICODE or wide strings.

On several platforms I've seen the KITL device name is not printed correctly. The device name is the name member of the OAL_KITL_DEVICE structure and is defined as a LPCWSTR.

Typically OALKitlInit uses KITL_RETAILMSG to report the device name but the name is never displayed correctly. The string is formatted as "%s" but only the first letter is shown - this implies that the wide string is being formatted as a character string. Trying %hs or %S to override the default does not help.

Reviewing the private sources confirms the problem. Only the %s format is supported and this is for character strings only.

Also be aware that formatting such as %08x is not supported either, but %X is fine!

Monday, 6 September 2010

Using #include from BIB files



Did you know that inside of Windows CE build system that bib files can #include other bib files. This technique is used on many BSP's to implement individual driver registry entries from the driver directory

platform.reg
#include "$(_TARGETPLATROOT)\SRC\DRIVERS\display\display.reg"

The same can be done for the bib file, I didn't release this before, but its there to use if you want to in CE6.0 for sure!

platform.bib
#include "$(_TARGETPLATROOT)\SRC\DRIVERS\display\display.bib"

Wednesday, 18 August 2010

Page faults on resume from suspend with COMPRESSION=on

A short while ago we had a problem on a platform resuming from suspend, a page fault calling a standard function. The function in question was a Registry query function. The fault was tracked down to that fact that when the config.bib specifies compression like:
COMPRESSION=ON
This means that all files are put into the nk.bin image back to back without any space between them, even running the image from RAM most of these files cannot be executed in place as the file aren't aligned on a page boundary, these files need to be copied into ram on a boundary and executed.
In the project above we needed to use the API so a solution was to turn off the COMPRESSION, this increases the NK.BIN size but helps in lower RAM usage and faster response times due to no duplication of files into executable positions. 

Thursday, 8 July 2010

Transformations in WindowsCE using SetMapMode

Unfortunately Windows CE doesn't support transformation of the coordinate system using SetMapMode, SetViewPortExt and SetWindowExt even in Windows CE 7.0 which is rather unfortunate as we had an application just this week that would have benefited from this. The application I'm referring to would have been cross compiled for Win32 and CE so basically I had to support scaling for the PC end as well, no point in having two different systems when the app should be seemless across both platforms, maybe in CE8.0 eh?

Wednesday, 9 June 2010

Windows CE 7.0 Preview

Microsoft have unveiled a technology preview of Windows Embedded Compact Edition (windows CE) version 7.0, the preview can be downloaded from http://www.microsoft.com/windowsembedded/en-us/products/windowsce/compact7.mspx go check it out now!

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