PrabuKumar's WinCE Blog

October 25, 2008

Connecting to WinCE 6.0 ARM Emulator using Active Sync

 

If you are working on the WinCE 6.0 ARM Emulator then this post will be useful.Mostly Emulator will be used for testing some application.In order to transfer application to the Emulator you may need either KITL transport or Active Sync support.

If you want to work without KITL and but with Active sync support on Wince 6.0 ARM emulator,do the following things

1. Add the necessary SYSGEN(SYSGEN_AS_BASE,SYSGEN_AS_FILE) variables from the OS catalog items.

2. Add the following line in the WINCE600\PLATFORM\DEVICEEMULATOR\FILES\platform.dat file

Directory(LOC_DIRWINDOWSSTARTUP):-File(“DMAcnect.lnk”,”\Windows\DMAcnect.lnk”)

This line is already present in the platform.dat file but inside IMGTPC environment variable.You can remove this if condition also.

But defining this environment variable in the OSbinary will make your Wince GUI look some what different(Because IMGTPC is for Tablet PC).So better remove this IF IMGTPC condition.

3. After building,downloading and launching the Emulator,Configure your PC Active Sync application by selecting File–> Connection Settings–>Select “Allow Connections to one of the Following:” check box–>Select DMA From the Dropdown box.

ActiveSync

4. In VS2005 Select Tools–>Device Emulator Manager.In Device Emulator Manager dialog box it will list WinCE Emulator,if it is not displaying as below press on the refresh button.Right click on WinCE emulator will show the Popup menu as shown in the Picture.Clicking on the Cradle option will connect the PC to the Emulator via Active sync.

image

 

Now it is possible to transfer files,running remote tools and debugging application from VS2005 on your WinCE 6.0 Emulator using Active Sync transport.

October 8, 2008

Windows Embedded CE 6.0 Fundamentals free e-book from Microsoft

If you want to learn about the fundamentals and how to start developing with Windows Embedded CE 6.0,then here is the free e-book from Microsoft.

Windows® Embedded CE 6.0 Fundamentals

Already in May 2008 Microsoft had released free Windows Embedded CE 6.0 material for MCTS exam.Windows Embedded CE 6.0 material for MCTS is also a good one to start with.And this is second from Microsoft.I think in near future you can expect more from Microsoft.

So Windows CE 6.0 developers enjoy reading these good books.

October 7, 2008

USB Function driver dynamic Switching in WINCE

We have three USB function class drivers in WinCE.

1. Serial

2. Mass Storage

3. RNDIS

Usually only one driver will load by default.Now the question is

“Is it possible to switch the USB Function driver dynamically during WinCE runtime?”

Yes it is possible.We have one IOCTL(IOCTL_UFN_CHANGE_CURRENT_CLIENT) for changing the current USB function driver.I found this solution in wince newsgroups only.Just to share the code I have written this blog.

You can test this by doing the following things:

But before doing these steps,first confirm the working of individual functions(Serial,Mass Storage,RNDIS) on your platform.Then go for this option.

1. Add all the three components in the catalog items.”Device Driver–>USB Function Driver–>Serial

                                                                                                                –>Mass Storage

                                                                                                                –>RNDIS”

2. Compile and generate the OS binary.

3. Write simple application to add the following functions.

HANDLE GetUfnController()
{
    HANDLE hUfn = NULL;
    BYTE rgbGuidBuffer[sizeof(GUID) + 4]; // +4 because scanf writes longs
    LPGUID pguidBus = (LPGUID) rgbGuidBuffer;
    LPCTSTR pszBusGuid = _T(“E2BDC372-598F-4619-BC50-54B3F7848D35”);
    // Parse the GUID
    int iErr = _stscanf(pszBusGuid, SVSUTIL_GUID_FORMAT,SVSUTIL_PGUID_ELEMENTS(&pguidBus));
    if (iErr == 0 || iErr == EOF)
        return INVALID_HANDLE_VALUE;
    // Get a handle to the bus driver
    DEVMGR_DEVICE_INFORMATION di;
    memset(&di, 0, sizeof(di));
    di.dwSize = sizeof(di);
    HANDLE hf = FindFirstDevice(DeviceSearchByGuid, pguidBus, &di);
    if (hf != INVALID_HANDLE_VALUE) {
        RETAILMSG(1,(TEXT(“FindDevice = %s\r\n”),di.szBusName));
        hUfn = CreateFile(di.szBusName, GENERIC_READ, FILE_SHARE_READ,
NULL, OPEN_EXISTING, 0, NULL);
        CloseHandle(hf);
    }
    else {
        hUfn = INVALID_HANDLE_VALUE;
    }
    return hUfn;

}

BOOL ChangeClient(HANDLE hUfn, LPCTSTR pszNewClient)
{
    if(hUfn == INVALID_HANDLE_VALUE || pszNewClient == NULL)
        return ERROR_INVALID_PARAMETER;
    DWORD dwRet = ERROR_SUCCESS;
    UFN_CLIENT_NAME ucn;
    _tcscpy(ucn.szName, pszNewClient);
    RETAILMSG(1,(TEXT(“NewClient Name: %s\r\n”),pszNewClient));
    BOOL fSuccess = DeviceIoControl(hUfn,IOCTL_UFN_CHANGE_CURRENT_CLIENT, &ucn, sizeof(ucn), NULL, 0, NULL,
NULL);

    CloseHandle(hUfn);
    RETAILMSG(1,(TEXT(“DeviceIOcontrol Returned value=0x%x\r\n”),fSuccess));
   return fSuccess;

}

4. I have written small menu based application with three menus for selecting the current client driver to load.Here is the code which I handled in the menus.By selecting the corresponding menu will change the corresponding function driver to load.

case ID_USBFN_SERIAL:
    wsprintf(tempBuf,_T(“serial_class”));
    ChangeClient(GetUfnController(),tempBuf);
    break;

case ID_USBFN_MASS:
    wsprintf(tempBuf,_T(“mass_storage_class”));
    ChangeClient(GetUfnController(),tempBuf);
    break;

case ID_USBFN_RNDIS:
    wsprintf(tempBuf,_T(“RNDIS”));
    ChangeClient(GetUfnController(),tempBuf);
    break;

With this solution now you have all the three functions in single NK.bin but still you can use only one function(i.e.either serial or mass storage or RNDIS)at a time.If you want to use two functions(ex:Serial and Mass storage) simultaneously then you need to go for new feature USB Function Composite device driver which is supported in Wince 6.0.

Create a free website or blog at WordPress.com.