`
guowee
  • 浏览: 176730 次
  • 性别: Icon_minigender_1
  • 来自: 南京
社区版块
存档分类
最新评论

GPS Antenna on Windows Mobile: Internal or Externa

阅读更多

http://blogs.msdn.com/raffael/archive/2008/05/28/gps-antenna-on-windows-mobile-internal-or-external.aspx

 

- Do we really care?

- GPS Hardware Port settings

- Avoid end-user actions

- A possible programmatic solution

 

For whatever reason you may want to know if the GPS Antenna your Windows Mobile device is connected to is internal or external... but... are we sure we should care? If you’re using GPSID APIs, then you shouldn’t care if the GPS Antenna is external or internal: in both cases it must be set in the OS’ GPS control panel applet by the user (this is not the only option, see below). Programmatically speaking, once you’ll call GpsOpenDevice to create a connection to the GPSID, then it’s up to the Intermediate Driver to internally take care if the antenna is internal or external.

In contrast, if you’re NOT using GPSID APIs (as I did in my previous test application I talked about in my blog), then probably your only option is as many 3rd party software do, i.e. scanning all the COM ports. In any case, also by using this approach you won’t be able to discriminate if the COM port you’re opening is related to an internal or external GPS antenna (for example if it’s a COM Port associated to the “Serial Port” service exposed by a Bluetooth GPS Antenna).

So the question may become: why do you need to care if the antenna is internal or external? Well... for example you may think that if external then the user is required to explicitly set the "GPS Hardware Port " within the GPS control panel applet (Start\Settings-System\GPS), contrarily to the case where the antenna is internal, because the manufacturer very likely configured its properties when building the platform... I'm talking about the following:

 

GPS Settings: Specify the hardware port to which your GPS device is connected. For more information, see the GPS device manufacturer's documentation.

And since, as I've already written, every developer must know the motto "KNOW THY USER, FOR HE IS NOT THEE " [cit. from David S. Platt, President of Rolling Thunder Computing ] Smile , you may want to provide users with as few as possible steps.

Ok, consider that at the moment there's no Configuration Service Provider for GPSID, however all the properties are retrieved through the Registry! So, for example, the Hardware Port is set under the keys documented at GPS Intermediate Driver GPS Hardware Registry Settings . So, if you know how the user will set the "Serial Port Service" of the external GPS Antenna (Bluetooth, SD or any other hardware), then it's a matter of using the Registry functions , or Microsoft.Win32.Registry NETCF class or even the Registry Configuration Service Provider for example. If you can't know a priori how the user will set his external device, then even knowing if it's indeed an external device doesn't help...  probably the only option is at this point to instruct the user on how to set the external antenna's COM service and the associated Hardware Port within the GPSID control panel applet... This is basically what I saw in the manual of another great piece of software: Run.GPS ! (thanks Giorgio for this hint! ) -- see chapter 3 "GPS Support". I looked at SportsDo 's user guide as well, and didn't find such info, probably purely because its GPS Data Interpreter engine is not based on Windows Mobile's GPSID (manual here ).

 

In any case, to verify if the target device has an integrated GPS Antenna or not , accordingly to the documentation above you can check the GPS Intermediate Driver GPS Hardware Registry Settings , and analyze the keys under [HKEY_LOCAL_MACHINE\System\CurrentControlSet\GPS Intermediate Driver\Drivers] : I've found something interesting in this case...

  • example of some devices WITH integrated antenna (note key "CurrentDriver"):
    [HKEY_LOCAL_MACHINE\System\CurrentControlSet\GPS Intermediate Driver\Drivers]
    "SleepOnNoData"=dword:000003e8
    "RetryWaitOnError"=dword:00000003
    "OutputBufferSize"=dword:00001000
    "InputBufferSize"=dword:00001000
    "CurrentDriver"="GPSOneDevice"
    
    
    
    [HKEY_LOCAL_MACHINE\System\CurrentControlSet\GPS Intermediate Driver\Drivers\GPSOneDevice]
    "Version"=dword:00000001
    "PollInterval"=dword:000001f4
    "DriverName"="TAI"
    "FriendlyName"="QualComm GpsOne Card, version 0.0"
    "InterfaceType"="POLL"
    
    [HKEY_LOCAL_MACHINE\System\CurrentControlSet\GPS Intermediate Driver\Drivers\GPSOneEmulate]
    "Filex"="\\windows\\GPSOneFileSimulation.txt"
    "FriendlyName"="QualComm GpsOne File, version 0.0"
    "InterfaceType"="File"
    
    [HKEY_LOCAL_MACHINE\System\CurrentControlSet\GPS Intermediate Driver\Drivers\GPSOnePort]
    "CommPort"="COM1:"
    "FriendlyName"="QualComm GpsOne Card, version 0.0"
    "InterfaceType"="COMM"
  • other example of devices WITH integrated antenna (note key "CurrentDriver"):
[HKEY_LOCAL_MACHINE\System\CurrentControlSet\GPS Intermediate Driver\Drivers]
"CurrentDriver"="Samsung GPS Hardware"



[HKEY_LOCAL_MACHINE\System\CurrentControlSet\GPS Intermediate Driver\Drivers\Samsung GPS Hardware]
"CommPort"="COM9:"
"FriendlyName"="Samsung GPS Card, version 1.0"
"InputBufferSize"=dword:00001000
"InterfaceType"="COMM"
"OutputBufferSize"=dword:00001000
"RetryWaitOnError"=dword:00002710
"SleepOnNoData"=dword:00000064
  • devices WITHOUT integrated antenna:
[HKEY_LOCAL_MACHINE\System\CurrentControlSet\GPS Intermediate Driver\Drivers] 
"CurrentDriver"="Control Panel Configured Device"



[HKEY_LOCAL_MACHINE\System\CurrentControlSet\GPS Intermediate Driver\Drivers\Control Panel Configured Device] 
"Baud"=dword:0000e100 
"CommPort"="COM7:" 
"InterfaceType"="COMM" 

I've tried with a few devices (thanks Nicola, Carlo , Fernando and JP!! Tongue out ) and in all of them the result is the same, i.e. when OEMs place a integrated antenna then they also "configure" its specific hardware through the [HKEY_LOCAL_MACHINE\System\CurrentControlSet\GPS Intermediate Driver\Drivers] key.

I noted a different set of keys on one device only, on which by the way the integrate GPS Antenna was working as expected... the CurrentDriver was NOT there ! (see below) Looking at WM6 documentation, if it's not set the GPS Intermediate Driver uses plug and play GPS hardware. So? Does "plug&play GPS Hardware" have sense on a device with integrated GPS Antenna?? Thinking   Without the CurrentDriver registry entry, multiple registry entries would have to change to switch between different GPS devices... without that set, does the device.exe load the first "driver" listed under [HKEY_LOCAL_MACHINE\System\CurrentControlSet\GPS Intermediate Driver\Drivers] ? Very likely yes (I should confirm looking at source-code).

[HKEY_LOCAL_MACHINE\System\CurrentControlSet\GPS Intermediate Driver\Drivers] 

[HKEY_LOCAL_MACHINE\System\CurrentControlSet\GPS Intermediate Driver\Drivers\GPSOneDevice] 
"Version"=dword:00000001 
"PollInterval"=dword:000001f4 
"DriverName"="TAI" 
"FriendlyName"="QualComm GpsOne Card, version 0.0" 
"InterfaceType"="POLL" 

[HKEY_LOCAL_MACHINE\System\CurrentControlSet\GPS Intermediate Driver\Drivers\GPSOneEmulate] 
"Filex"="\\windows\\GPSOneFileSimulation.txt" 
"FriendlyName"="QualComm GpsOne File, version 0.0" 
"InterfaceType"="File" 

[HKEY_LOCAL_MACHINE\System\CurrentControlSet\GPS Intermediate Driver\Drivers\GPSOnePort] 
"CommPort"="COM1:" 
"FriendlyName"="QualComm GpsOne Card, version 0.0" 
"InterfaceType"="COMM"

 

Even if we had such a confirmation, at this point the only thing that may discriminate if the GPS Antenna is internal or external SEEMS TO BE (I sure haven't tried on enough devices, so feel free to let me know!) *IF* [HKEY_LOCAL_MACHINE\System\CurrentControlSet\GPS Intermediate Driver\Drivers\Control Panel Configured Device] key *exists* .  I was initially thinking at checking the value of [HKEY_LOCAL_MACHINE\System\CurrentControlSet\GPS Intermediate Driver\Drivers]CurrentDriver , however as you noticed I found at least one device without it and yet with integrated antenna... To wrap up the discussion, a possible programmatic approach may be:

- MANAGED:

static
 void
 Main(string
[] args)
{
    RegistryKey rk = Registry.LocalMachine.OpenSubKey(
        @"System\CurrentControlSet\GPS Intermediate Driver\Drivers\Control Panel Configured Device"
);
    bool
 HasIntegratedGpsAntenna = (rk == null
);
    if
 (rk != null
)
        rk.Close();

    if
 (HasIntegratedGpsAntenna)
        MessageBox.Show("Integrated"
, "GPS Antenna"
);
    else

        MessageBox.Show("External"
, "GPS Antenna"
);
}

 

- NATIVE:

int
 _tmain(int
 argc, _TCHAR* argv[])
{
    HKEY hKey = NULL;
    LONG rc = NULL;
    BOOL HasIntegratedGpsAntenna = FALSE;

    rc = RegOpenKeyEx(HKEY_LOCAL_MACHINE, 
        L"System\\CurrentControlSet\\GPS Intermediate Driver\\Drivers\\Control Panel Configured Device"
, 
        0, 0, &hKey);
    
    HasIntegratedGpsAntenna = (rc != ERROR_SUCCESS); 

    //or probably better, including other error-check:

    //HasIntegratedGpsAntenna = (rc == ERROR_FILE_NOT_FOUND); 


    if
 (hKey != NULL)
        rc = RegCloseKey(hKey);

    if
 (HasIntegratedGpsAntenna)
        MessageBox(NULL, L"Integrated"
, L"GPS Antenna"
, MB_OK);
    else

        MessageBox(NULL, L"External"
, L"GPS Antenna"
, MB_OK);

    return
 0;
}

 

Cheers,

~raffaele

Filed under: GPS

Comments

# re: GPS Antenna on Windows Mobile: Internal or External?

Hi,

One must know that the solution will work only after 1st use/configuration of the external GPS to function via the intermediate driver.

Otherwise, this key will not appear.

I guess there isn't a straightforward technology (yet?) :-)

Thanks.

# re: GPS Antenna on Windows Mobile: Internal or External?

Thanks Mrgoos for your comment! Yes, the "solution" assumes that the user already configured the external antenna a first time... however, (I didn't test this rough idea) a condition for "external antenna" might also be "no keys under System\CurrentControlSet\GPS Intermediate Driver\Drivers\Control Panel Configured Device", because if it was "internal antenna" then also just after a hard-reset the OEM keys would be there. If you'll try this, please post your comment -- thanks!

 

分享到:
评论

相关推荐

Global site tag (gtag.js) - Google Analytics