WinCE Serial Over USB
It is possible to establish a serial connection between a host (e.g. a PC) and a Toardex module (Colibri or Apalis) over the USB.
Here are the steps:
- Disable the ActiveSync on the module.
- Make sure ActiveSync/Mobile Device Center is not occupying the virtual serial port. Stop the ActiveSync/Mobile Device Center service (wcescomm.exe) if necessary.
Client side (Toradex Module)
On the Windows CE Image, the com port can be accessed on the virtual port \$device\COM0.
hPort= CreateFile( TEXT("\\$device\\com0"), GENERIC_READ | GENERIC_WRITE, 0, NULL, OPEN_EXISTING, 0, NULL );
if (hPort == INVALID_HANDLE_VALUE)
printf("Can not open port!\r\n");
Host Side (PC)
If your device can not be setup when you attach it, you can create your own installer to match your idVendor and idProduct as described on MSDN. There is also a small third party tool called Zadig, which let you create and install a customized WinUSB driver.
To have a quick start we provide you a basic sample project to communicate with your client. Please also make sure, you have disabled wcescomm.exe service as described above.
This project is based on a sample from Microsoft. The project also contains libs and headers from the Windows Driver Kit Version 7.1.0. The sample was tested on Windows 7 and built with VS2008 and Windows 10 with VS2015.
Note: This probably will not work on Windows Vista and later. We recommend to use WinUSB on the host side.
The drivers used on the PC is the same drivers which is used by ActiveSync/Mobile Device Center. This means you have to install ActiveSync on the PC that wants to connect to the module. Although ActiveSync isn't used directly.
On the PC side, the virtual serial port on the module can be accessed using regular COM port APIs (CreateFile()...). The port is called \\.\wceusbsh001 .
unsigned char buf = "TestMsg";
unsigned int written;
h = CreateFile("\\\\.\\wceusbsh001", FILE_ALL_ACCESS, 0, NULL, OPEN_ALWAYS, FILE_ATTRIBUTE_NORMAL, NULL);
// do some error handling here....
WriteFile(h, buf, 5, &written, NULL);