Desktop-to-WinCE Communication using the ActiveSync USB Serial Driver
By using the ActiveSync USB Serial Driver, it is possible to communicate and send data over USB without writing USB Drivers for each side.
The following code and explanation is an example of a Desktop PC communicating with a WinCE Device.
- Desktop Preparation
- Install the latest version of the ActiveSync USB Serial Driver on to the Desktop PC that will be communicating with the WinCE device.
ADS ActiveSync USB Serial Drivers - If Microsoft ActiveSync is installed on the computer, prevent ActiveSync from opening up the USB Serial Driver when it detects a WinCE Device by opening ActiveSync, and under File->Connection Settings, uncheck Allow USB Connections and click OK.
- Desktop Communication
Desktop USB Test.exe (WIN 32 Application)
This application communicates with a WinCE Device over USB using the ActiveSync USB Serial Driver from the Desktop PC Side. It signals the attached WinCE Device to begin communication, sends 40 DWORD numbers, and then recieves 40 DWORD numbers.
It opens the first USB Serial Driver, given by the port name \\.\wceusbsh001
ActiveSync USB Serial Drivers are created in the order that the ActiveSync capable devices are connected to the Desktop PC. They can only be opened when a device is connected to the Desktop PC. The driver ports do not exist when no devices are connected.
Example: If two WinCE devices are connected to the Desktop PC, USB Serial Driver \\.\wceusbsh001 is created and assigned to the first device connected USB Serial Driver \\.\wceusbsh002 is created and assigned to the second device connected.
Make sure Desktop USB Test.exe is opening the correct driver for your device.
Source Download Rev 1 - (Sept 19, 2006) (9k zip)
|
Key APIs Used ClearCommError CreateFile EscapeCommFunction SetCommMask SetCommState WaitCommEvent |
- Device Preparation
DisableRepllog.exe (WinCE Application)
This application disables the running of repllog.exe upon detecting a RS232 Event Notficiation from the ActiveSync USB Serial Driver. It instead will start the .exe file specified in the programName string (by default, this is \FlashFX Disk\USB_Test.exe).
This program must be run before the Desktop Application can begin communication with the WinCE Device. Therefore, it is best to include this executeable in the \FlashFX Disk\Startup\ Folder so that it is executed upon start up. It is also possible to make this executable the ADSLoad.exe for the device.
Source Download Rev 1 - (Sept 19, 2006) (7k zip)
|
Key APIs Used CeRunAppAtEvent |
- Device Communication
Device USB Test (USB_Test.exe) (WinCE Application)
This application communicates with a Desktop PC over USB using the ActiveSync USB Serial Driver from the WinCE Device Side. It begins communicating once signaled by the Desktop PC, recieves 40 DWORD numbers, and then sends 40 DWORD Numbers.
It opens the USB Serial Driver, given by the port name COM4:
The ActiveSync USB Serial Driver poses as a COM Port on WinCE Devices.
In order to find out which COM port to use for your device:
- Make an ActiveSync conenction with the device (make sure USB Connections are enabled for this step, if you disabled them using the directions above)
- Run RegEdit.exe and expand the following Registry Key: [HKEY_LOCAL_MACHINE\Drivers\Active]
- The numbers listed represent the current active drivers in the system. Search through them, looking for the Registry Key named Key with a value of \Drivers\USB\FunctionDrivers\Serial_Class. The Name Key listed under this Active Driver is the Comm Port USB_Test.exe needs to open.
Make sure USB_Test.exe is opening the correct COM Port for your device.
Source Download Rev 1 - (Sept 19, 2006) (8k zip)
|
Key APIs Used ClearCommError CreateFile PurgeComm SetCommMask SetCommState WaitCommEvent |
- Helpful MSDN Links
Note:
All code projects in this example are VS 2005 C/C++ Projects.
Currently, communicating this way only works in WinCE 5.0.