Reading from COM port (Ipaq + GPS module)

  • Thread starter Thread starter Kris Luyten
  • Start date Start date
K

Kris Luyten

Hi,

I am trying to access the Haicom HI-303MMF GPS modul using C# (.Net
Compact Framework on Pocket PC). The NMEA data that it produces can be
read from the (virtual) COM6 port.

I try to open a connection with the COM6 port
using CreateFile like this:
======
[DllImport("coredll.dll",SetLastError=true)]
private static extern unsafe int CreateFile.....

....
m_ihandle = CreateFile("COM6",GENERIC_READ, 0, 0, OPEN_EXISTING,0, 0);
....
=====

This works when COM6 is replaced by COM1, but COM6 gives me the
error (obtained by the GetLastError function):
"2: The System Cannot find the file specified."
I also tried using "COM6:", "//./COM6", "//./COM6:" and "\\\\.\\COM6" as
identifier, but they also fail.


Is there something I should take into account because of the high number
of the COM port?


Thanks,
Kris
 
In Windows CE, it's *critical* that you name the devices you are trying to
open properly. You don't have a colon at the end of the device name,
"COM6:". It won't open COM6, but a file called "COM6", the way you've
written it (and only if the file of that name already exists).

It's also quite possible that there is no COM6 on your device and the
documentation is in error. To check that, use the Remote Registry Editor
from eVC to look for keys in the HKEY_LOCAL_MACHINE\Drivers\Active tree. If
there is a COM6, one of the entries under that tree should be COM6...

Paul T.
 
Back
Top