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]