GPSCom2
v1.17 / IConnectionPointImplMT v1.12
Welcome to GPSCom2, a simple freeware COM based library which
can be used to add GPS support to your Windows applications. GPSCom2 is a standard
COM EXE developed in ATL in VC 2017. It is based on the design of the existing shareware
GPSCom component of the author
which has now been obsoleted by GPSCom2. GPSCom2 internally uses an advanced ATL
class called IConnectionPointImplMT to support firing COM events from worker threads
different that the threads on which the COM object was originally created. The GPSCom2
code internally used asynchronous IO when reading from the serial port to provide
the best performance and avoids the need for polling. Included in the download is
prebuilt GPSCom2 binaries for x86 and x64. The GPSCom2 component delivers a simple
string value of a sentence back to client applications using the standard COM Connection
Point notification mechanism. A set of C++ client classes further abstracts this
to provide a simple C++ class with virtual functions for each type of NMEA sentence.
These set of classes are provided in the GPSCom2Client\GPSCom2Client.h header file
which you can simple include in your existing C++ applications. These classes provide
comprehensive support for the following NMEA sentences: $GPRMC, $GPGGA, $GPGSV,
$GPGLL, $GPVTG, $GPGSA, $GPGRS & $GPGST. All the parsing of these sentences
is handled for you and standard virtual function and parsed structures are available
for client applications to code against.
Features
- Provides a very simple C++ client API to the out of process COM object hiding
all the COM plumbing required to achieve this.
- Allows connections to GPS devices to be shared between multiple clients
i.e. multiple client processes can share the one connection to the receivers
serial port !!. This is achieved by the IGPSConnection::CreateConnection method
which hands back existing connections if the port number requested matches an
already open port.
- Standard COM Connection points are provided in the library to allow client
apps to be notified in real time of incoming GPS NMEA sentences, but this plumbing
is all hidden by the C++ client classes.
- Provides a concrete example on how COM collection classes should be implemented.
- Comprehensive support for the following NMEA sentences: $G*RMC, $G*GGA,
$G*GSV, $G*GLL, $G*VTG, $G*GSA, $G*GRS, $G*GST, $G*GNS & $G*ZDA. This is a pretty comprehensive
set of NMEA sentences available from most GPS devices.
- Client apps can also poll the connection for the NMEA information if they
so desire or hook into the virtual functions which get called when a specific
sentence is received.
- Supports any standard GPS device which supports the NMEA 0183 standard and
which presents its data on a Windows Serial Port (Physical or Virtual/Emulated).
- The GPSCom2 binary does not have any dependencies on ATL or MFC DLLs. It
is a purely ATL based implementation unlike GPSCom and only takes dependencies
on standard Windows DLLs.
- Supports per user registration as well as the standard per machine registration.
This is achieved by the use of the "RegServerPerUser" and "UnregServerPerUser"
command line options to GPSCom2.
History
v1.17 GPSCom2 / v1.12 IConnectionPointImplMP (17 June 2023)
- Updated copyright details.
- Made a local variable in GPSCom2::CSentence::IsChecksumValid const
- Removed unnecessary constructors from sentence classes.
v1.16 GPSCom2 / v1.11 IConnectionPointImplMP (1 May 2022)
- Updated copyright details.
- Updated the code to use C++ uniform initialization for all variable
declarations.
v1.15 GPSCom2 (10 May 2020)
- Fixed a number of additional compiler warnings when the code is compiled with VS
2019 Preview
v1.14 GPSCom2 / v1.10 IConnectionPointImplMP (4 April 2020)
- Updated copyright details.
- Fixed more Clang-Tidy static code analysis warnings in the code.
v1.13 GPSCom2 (22 December 2019)
- Fixed various Clang-Tidy static code analysis warnings in the code.
v1.12 GPSCom2 (4 November 2019)
- Updated initialization of various structs to use C++ 11 list
initialization
v1.11 GPSCom2 (9 September 2019)
- Fixed a number of compiler warnings when the code is compiled with VS
2019 Preview
v1.10 GPSCom2 (30 June 2019)
- Improved the robustness of the NMEA parser in the reading thread to lop
off anything before the start of a NMEA sentence. This will handle the case
of any devices which mix NMEA sentences with other data. e.g. u-Blox
devices.
- The reading thread in GPSCom2 will now only fire COM notifications for
data which now begin with "$G"
- Added support for GNSS, GLONASS, Galileo and BeiDou variants of NMEA
sentences in addition to the standard GPS versions.
- Added support for G*GNS & G*ZDA NMEA sentences.
v1.09 GPSCom2 (23 June 2019)
- Reworked CGPSConnection::MonitorThread code to avoid high CPU
utilization.
- Fixed compile warnings in GPSCom2Client.h when importing GPSCom2 type
library.
- Replaced enum with enum class throughout the codebase.
v1.08 GPSCom2 / v1.09 IConnectionPointImplMP (18 May 2019)
- Updated copyright details.
- Updated the code to clean compile on VC 2019
- Reworked the IConnectionPointImplMT::m_Clients array to store the store
the cookie instead of the GIT pointers since you can always get the GIT
pointers from them. This also allowed easier lookups so a simpler
implementation of Unadvise can be made. Thanks to Michael Ford for this nice
addition.
v1.07 GPSCom2 / v1.08 IConnectionPointImplMP (13 October 2018)
- Updated copyright details.
- Fixed a number of C++ core guidelines compiler warnings. These changes
mean that the code will now only compile on VC 2017 or later.
- Replaced BOOL with bool throughout the codebase.
- Removed code which supported CGPSCOM2CLIENT_MFC_EXTENSIONS code path.
v1.06 GPSCom2 (7 November 2017)
- Replaced CString::operator LPC*STR() calls with CString::GetString calls.
- Added missing targetver.h file to the zip download file.
- Included information in GPSCom2Client.h about registering GPSCom2.
- Reworked CGPSConnection::HandleRead code to avoid an off by one
termination issue. Thanks to Frits van Veen for reporting this bug.
- Fixed a compile issue in GPSCom2Client.h when
_ATL_NO_AUTOMATIC_NAMESPACE is defined.
- Refactored the CGPSConnection::MonitorThread code to use a new
CGPSConnection::ReadData method.
- Fixed a high CPU utilization bug in GPSCom2 due to code in
CGPSConnection::MonitorThread. Thanks to Frits van Veen for reporting this
bug.
- Fixed an issue in the new CGPSConnection::HandleRead method where the
code will incorrectly send an empty sentence to GPSCom2 clients.
- Added validation code to each of the CSentence::Parse methods to verify
the size of the "sFields" array. Thanks to Frits van Veen for reporting this
bug.
v1.05 GPSCom2 / v1.07 IConnectionPointImplMP (18 May 2017)
- Updated the code to compile cleanly using /permissive-.
v1.04 GPSCom2 / v1.06 IConnectionPointImplMP (7 March 2017)
- Updated copyright details.
- Updated code to clean compile in VC 2017
- Updated comment on the #import "libid:.." line to tell the user
how to resolve the issue.
v1.03 GPSCom2 / v1.05 IConnectionPointImplMP (19 November 2016)
- Updated copyright details.
- Replaced NULL throughout the codebase with nullptr
- The binaries and project include in the download are now compiled using
VC 2015 and include x64 binaries as well as x86 binaries.
- Provided a CreateConnection2 method which allows you to open the GPS port
without the need to specify DataBits, BaudRate, StopBits and Parity parameters.
This new method will simply open the specified port and send the init string
if any.
- Added support for IGPSPort:CreateConnection2 to the GPSCom2Client classes.
- Added SAL annotations to the GPSCom2Client classes.
- General clean-up and review of the code in GPSCom2 and GPSCom2Client.
- Fixed issue in the message when the code detects you do not have
atlcom.h included in the GPSCom2Client classes. Thanks to Frits van Veen for
reporting this issue.
v1.02 GPSCom2 / v1.04 IConnectionPointImplMP (17 December 2015)
- Updated copyright details.
- Updated sample client app to clean compile in VC 2010 - 2015.
- Update GPSCom2 to clean compile on VC 2013 - 2015.
- Reworked the GPSCom2Client classes to optionally compile without MFC. By
default the class now use STL classes and idioms but if you define CGPSCOM2CLIENT_MFC_EXTENSIONS
the class will revert back to the MFC behaviour.
- Reworked the IConnectionPointImplMT::GetInterfaceAt method to have the following
signature: HRESULT GetInterfaceAt(int nConnectionIndex, CComPtr<TSinkInterface>&
pTSinkInterface) This change from returning a CComPtr<IDispatch>&
means that the code can handle client situations where an IDispatch interface
is not available. This can occur where the event interface is implemented as
a marshalled C# class. Thanks to David Korn for reporting this issue.
v1.01 GPSCom2 (1 May 2010)
- Updated the CSentence::Time method to correctly handle centiseconds values
- Updated the CSentence::Angle method to correctly handle empty fields
- Fixed logic errors in CVTGSentence::Parse
- CSentence::Tokenize now removes all fields from the array before it starts
parsing
- All places which parse a floating point number now handle empty fields
v1.0 GPSCom2 / v1.03 IConnectionPointImplMP (1 May 2010)
- Initial public release of GPSCom2.
- IConnectionPointImplMP has been updated to work when "using namespace
ATL" is now explicitly set in client code.
- IConnectionPointImplMP::GetInterfaceAt method has been reworked to surface
a HRESULT as a return value. In addition the IDispatch pointer is now returned
already wrapped in a CComPtr<IDispatch> smart pointer reference parameter.
The instructions of how you recode the Fire_* methods have also been reworked.
Installation & Redistribution
The GPSCom2 exe is a standard self-registering COM exe so registration / un-registration
is handled using the "/RegServer" or "/UnRegServer" command
line parameters. If you are using a MSI based installer, then the recommended way
to register the component is to avoid self registration and instead extract the
registration details into the MSI tables. GPSCom2 also supports per user registration
by the use of the "RegServerPerUser" and "UnregServerPerUser"
command line options to GPSCom2. The zip file comes with ready to ship x86 and x64
Unicode release builds of GPSCom2 in the "Release" and "Release64"
directories. To compile the included TestClient application you will need to
have GPSCom2 already registered.
Usage
To start developing client applications using GPSCom2, all you need to do is
#include "GPSCom2Client.h" in your C++ applications. A sample console
based VC++ 2017 project is included in the download in the "GPSCom2Client"
directory along with the client header file itself to get you started.
To create a connection to a GPS device you can create an instance of the GPSCom2::CClient
class and call its Open method to connect to the device. This method exposes standard
serial port type parameters to configure the port settings. Then either periodically
poll the various NMEA sentence member variables of this class for the GPS values
you are interested in. Each member variable's name corresponds to the sentence name.
E.g. if you want to obtain your current longitude you would dot into m_RMC.m_Longitude.dValue.
Alternatively you can derive a class from CClient and override any virtual functions
you need, each of which correspond to the arrival of a specific NMEA sentence. For
further information about the various NMEA sentences please consult the NMEA specifications
available from http://www.nmea.org/ or public
sources such as http://aprs.gids.nl/nmea/.
Contacting the Author
PJ Naughter
Email: pjna@naughter.com
Web: http://www.naughter.com
17 June
2023