Hi,
I am developing a WinCE application for a PDA and i need to access its
USB port. I am trying to access a serial port, using the function
CreateFile, and when I execute the .exe in the PDA (it compiles and
links well on PC), it returns me a '120' Error (This function is not
valid on this platform.).
In the web requirements fot this function it says "OS Versions: Windows
CE 1.0 and later", and the PDA has 'Microsoft Pocket PC Version
4.20.0' installed, so the platform is compliant, isn't it
I am working with the eMbedded C++ 4.0, Pocket PC 2003 SDK and has installed evc4SP4
What can be the problem Here is the code:
-------------------------------------------------------
LPTSTR portName = TEXT("COM1:");
m_hUsbCom = CreateFile (
portName ,
// Pointer to
the name of the port
GENERIC_READ | GENERIC_WRITE,
// Access (read/write) mode
0,
// Share mode
NULL,
// Pointer to the security attribute
OPEN_EXISTING, // How to
open the serial port
0,
// Port attributes
NULL);
// Handle to port with attribute to copy
// if fail opening the port, return FALSE
if ( m_hUsbCom == INVALID_HANDLE_VALUE )
{
AfxMessageBox(L"Unable to open USB port",
MB_ICONSTOP);
DWORD error = GetLastError();
CString s;
s.Format(L"Error: %d", error);
AfxMessageBox(s);
ret = FALSE;
}
-------------------------------------------------------
Thanks in advance

Access to serial port in a WinCE device
TheSource
Read here:
http://forums.microsoft.com/MSDN/ShowPost.aspx PostID=300214&SiteID=1
CJ1983
Since John pointed, I have checked in the PDA registry and the USB port seems to be COM5: (iterating in HKLM\Drivers\Active, the \08 has the key: 'Drivers\BuiltIn\USBF_Serial').
But I still have the problem with my application: when I try to open the 'COM5:' USB port, it returns a '120' error. I have tried with OPEN_EXISTING, OPEN_ALWAYS, ... Is the CreateFile() function I use valid for my iPAQ I supposed it was, but with this error I am not sure yet...
I have a previous problem that may be related to the one before: when I plugged in the USB device, the iPAQ is supposed to pop up a dialog to ask me for a previous installed library (as the USB vendor says), but the iPAQ does not recognize the USB device (no pop up, nothing happens). May it be because the USB device need a power that the iPAQ does not supply I have tried other USB devices, such a memory stick, or an external hard drive, all of them with no external power supply, but nono of them was recognized by the iPAQ.
Should the iPAQ O.S. (WinCE Pocket PC) recognize a USB device automatically when it is plugged in, like it occurs in a PC O.S. (Windows) I supossed it is a problem of power supply, and in that case I have a problem...
BTW, is there any Device Manager application for WinCE (PocketPC) like MyPC in Windows, to control the iPAQ Hardware
Thanks a lot
some1sxi
Thanks a lot,
I have tried the Remote Process Viewer (RPV) and can see the DLLs used in the iPAQ. But when i have connected the iPAQ to the labtop which has the eVC (in order to use the RPV), the iPAQ obviously is not connected to the USB device that i need to access to, should I see the DLL of the USB device in the RPV anyway if it was properly installed in the iPAQ It does not appear...
Maybe it is the problem, a DLL of the USB device is copied to the iPAQ /Windows directory (as said the manufacturer, before plug in the device), but I am not sure if is the correct one, there is several drivers possibilities (ARM, MIPS, PPC, SHx, x86). I have chosen PPC (2 more options: ppc403, ppc821), and then chosen ppc403, but I am not sure if this is the correct one for my iPAQ Pochet PC...
JWhite
I also have some experience with this as I wrote a WinCE stream driver for a COM port.
You may want to watch out enumerating the active drivers list for the COM prefix. Those three letters are determined by the driver and so it may or may not be a COM port depending on the driver. A lot of drivers use the first three letters COM even though they may not support all th COM IOCTLs.
I was just trying to give you another set of options in the link above that seem to work for most people who try to open a COM port. The OPEN_EXISTING flag is not always appropriate. but like you said you have some experience with this...
jslabrie
zzip,
Most PPC devices are built with ARM. I always try ARM or ARM4 first when using libraries.
Mike C#
COM1: on a PDA will usually be an actual serial port. It's part of the connector that the cradle plugs in to and requires a special cable. You can either modify the cradle, or see if there is a "GPS cable" available for your model.
The way I look for serial ports on a Pocket PC is to iterate over each key in HKLM\Drivers\Active. If the value "Key" contains "serial" or the value "Name" contains "com", I call it a serial port, and use the "Name" value to open it. Use the remote registry viewer and examine this key, and you should be able to get some idea about which are valid ports.
BTW, it looks like the USB port is COM9: on this iPAQ 2415. (Key is "Drivers\BuiltIn\USB").
stevenng
zziipp,
Well as to "Device Manager" there is none that I know of. However you can use the Remote Process Viewer provided in eVC and look at the device.exe file. This will give you a good idea of what DLLs are being used.
As to USB devices and their drivers they are usually custom drivers. I think you will need support directly from the manufactuer.