다음을 통해 공유


GPSID source code: the ultimate answer

Recently I've been asked some questions about how GPSID handles certain weird scenarios that fall outside the scope of the docs.  I'm happy to answer these of course - it is my job after all :).  The really hard questions have come from GPS device driver writers, but this post may help app developers also.  Another and often faster you can get the answers about GPSID is to look at the GPSID source code.  It's shared in the public tree so Platform Builder customers or OEMs with the src access in WM can look and modify, if needed. 

The root directory is \public\COMMON\oak\drivers\GPSID.  Under here is the .\client directory, which is the link-time library for gpsapi.dll.  This isn't very interesting (it's just IPC magic between the app calling GPSID and GPSID.dll, either in device.exe or servicesd.exe depending on OS version).  You shouldn't ever mess with this code.

The more interesting piece is in the .\server directory, which compiles gpsid.dll itself.  This is the DLL that runs in device.exe/servicesd.exe and does the interaction with the GPS device as well as taking IPC calls from apps.  It's only about 6000 lines of code and (I flatter myself :)) it's written well enough that no one has ever had problems following it that I know of.

For the record, here's a brief overview of the files in this directory and what they do:

GPSAPI.cpp -> "Receives" the IPC calls to GPSOpenDevice, checks params, and calls into rest of GPSID.

GPSCore.cpp -> This is the "main" set of routines for GPSID.  Most interesting fcn is GPSWorkerThread(), which is spun up to interact with the GPS device.

GPSDriver.cpp -> Provides abstraction between rest of GPSID and the underlying GPS driver, be it a standard NMEA device, the Poll Driver (CE6.0 and above), or the simple text file reader.

GPSHandle.cpp -> Manages handles from API/caller process layer

GPSIntrf.cpp -> xxx_Init/xxx_IOControl etc interface for tying GPSID into device.exe/servicesd.exe

GPSMultiplexer.cpp -> Implements the logic for the virtual COM port/multiplexer in GPSID.

GPSParse.cpp -> Parse out the NMEA string and (CE6.0 and above) when using the poll driver, potentially generate a NMEA string.

GPSString.cpp -> Helper utilities that parse out individual fields in a NMEA string

It's interesting that the way the alphabetical list ended up working out, you don't actually get to the string parsing until the very bottom of the list.  Ah, abstraction!

The best way to follow the code is to look at what the API's do (GPSOpenDeviceIntrnl & GPSGetLocationIntrnl especially) and to trace through GPSWorkerThread.

[Author: John Spaith]

Comments

  • Anonymous
    August 31, 2007
    Would you be kind enough to explain what NMEA-0183 messages are used in both WM5 and WM6 (if they are different)?  I'm guessing $GPRMC, $GPGGA, and $GPGSV (for satellites).  Unfortunately, I don't have Platform Builder... I am a mere application developer trying to get a better handle on some of the guts (for reasons I have explained in other posts).
  • Anonymous
    September 20, 2007
    First apologies on slowness of this response.  Ugh, I'm slacking.We do GPGGA, GPRMC, GPGLL, GPGSA, and GPGSV.