About GPS ToolKit.NET Mobile
Introduction
Purchasing GPS ToolKit.NET
Redistributing GPS ToolKit.NET
License Agreement
Support
Getting Started
Getting Started
Setting up the GPS
Basic Concepts
GPS ToolKit Sample Projects
About GPS ToolKit Errors
Reference
GPSToolKit Class
Properties
BaudRate
ExtendedFixData
IsGPSConnected
IsPortOpen
LastPositionUpdateTime
NavigationData
PortName
Protocol
Position
Satellites
Speed
TrueCourse
Methods
AddRoute
AddTrack
AddWaypoint
AutoDetectGPS
Close
GetAvailableSystemPorts
GetGPSInfo
GetRoutes
GetSystemPorts
GetTracks
GetWaypoints
Open
ShutOffGPS
WriteRawBinaryToGPS
WriteRawToGPS
Events
GPSConnected
GPSDisconnected
NavigationUpdate
PositionUpdate
RawDataReceived
SatelliteUpdate
Supporting Classes
Altitude
Angle
Distance
ExtendedFixData
Properties
DGPSRefStationID
EstimatedHorizontalError
EstimatedPositionError
EstimatedVerticalError
FixMode
GeoidHeightAboveWGS84
HDOP
MagneticVariation
NumSatellitesInView
PDOP
TimeSinceLastDGPSUpdate
VDOP
GPSInfo
Latitude
Methods
ToDecimalDegreesString
ToDegreesMinutesString
ToDegreesMinutesSecondsString
Longitude
Methods
ToDecimalDegreesString
ToDegreesMinutesString
ToDegreesMinutesSecondsString
NavData
Properties
ActiveRoute
ArrivedAtDest
CrossTrackError
DestWptName
DestWptPosition
IsValid
MagBearingFromOriginToDest
OriginWptName
TrueBearingFromOriginToDest
TrueBearingToDestWpt
VelocityTowardDestWpt
Position
Methods
BearingFrom
BearingTo
DistanceTo
Route
Properties
Name
Waypoints
Satellite
Speed
Track
Properties
Color
DisplayTrack
Name
TrackPoints
TrackPoint
Waypoint
Collections
RouteCollection
SatelliteCollection
TrackCollection
TrackPointCollection
WaypointCollection

About GPS ToolKit.NET Exceptions

GPS ToolKit.NET notifies your application of any errors it encounters by throwing one of the following exceptions:

  • PortClosedException: GPS port is closed
  • PortAlreadyOpenException: Port is already open
  • PortOpenException: Could not open port. This may be because the port does not exist or is already in use.
  • WriteErrorException: An error occurred while trying to write data to the GPS
  • ArgumentException: An invalid argument was supplied
  • GPSAutoDetectException: Unable to automatically detect GPS. You may still be able to open a port directly using the Open() method
  • NoGPSDetectedException: Unable to detect GPS on the specified port with the baudrate/protocol combination specified (if any). You may be able to detect the GPS using AutoDetectGPS.
  • NotSupportedException: This functionality is not supported by this GPS device or by the communications protocol currently in use.
  • ProtocolNotSupportedException: GPS ToolKit does not currently support this protocol/data type.
  • SystemPortsException: Unable to automatically detect system ports. You may still be able to open a port directly using the Open() method.
  • TransferTimeoutException: Transfer timed out.
  • DeviceInfoNotAvailableException: Device info is not available from the GPS

The following examples show how to handle these exceptions in your code.

Note that, for simplicity, the examples in the reference section do not include error handling constructs. You may examine the GPS ToolKit Test Panel sample project for examples of error handling in Visual Basic, C#, and C++.

Visual Basic.NET

GPS ToolKit.NET errors are handled in Visual Basic.NET using either structured exception handling similar to C# and C++, or by using the familiar unstructured On Error Goto construct. When using structured handling, you must specifically reference the Exception variable as type System.Exception. This is because GPS ToolKit.NET includes "Windows.h", which globally defines its own exception type, and Visual Basic's indifference to case will cause it to default to the exception type. The following example traps an error and displays the error message using structured exception handling:

Try
    myGPSToolKit.Open("COM1")
Catch ex As System.Exception
    MsgBox(ex.Message)
End Try
When using unstructured (VB6 style) exception handling, detailed error information can be found in the application's global Err object. For example, the following code traps an error and displays a description in a message box:

Private Sub MySub()
    On Error GoTo MyErrorHandler
    myGPSToolKit.Open "COM1"
    Exit Sub

MyErrorHandler:
    MsgBox(Err.Description)
End Sub

C#

GPS ToolKit.NET errors are handled in C# using standard try/catch blocks. The following code traps an error and displays a description in a message box:

try
{
    myGPSToolKit.Open("COM1");
}
catch(Exception Ex)
{
    MessageBox.Show(Ex.Message);
}

C++

GPS ToolKit.NET errors are handled in C++ using standard try/catch blocks. The following code traps an error and displays a description in a message box:

try
{
    myGPSToolKit->Open("COM1");
}
catch(Exception *Ex)
{
    MessageBox::Show(Ex->Message);
}