|
Download the Eye4Software GPS Toolkit fully functional 30 day trial version for free |
|
Browse through the Eye4Software GPS Toolkit manual |
The Eye4Software GPS toolkit allows software developers to add GPS functionality to their own programs without the need to have any knowledge on serial communications and GPS protocols like RS-232 and NMEA0183.
The product can be used in many programming environments, such as Visual Basic, Visual C++, Visual Studio.Net, Borland C++ Builder, Borland Delphi and VBA, but also web oriented applications such as ASP, ASP.NET and PHP, and all other programming environments that support ActiveX.
First you must have a VB Script editor and the Eye4Software GPS Component installed on your computer. If you do not have a dedicated VBScript editor, notepad will do. You can download the Eye4Software GPS Component here.
To create your VB Script, you can just use notepad or any other text editor. Create a file with a ".vbs" extension.
On top of your script, please add the following code to declare the objects:
Dim objGps Dim objGpsConstants
And the following code to create an instance of the object:
Set objGps = CreateObject("Eye4Software.Gps")
Set objGpsConstants = CreateObject("Eye4Software.GpsConstants")
Below you can find the sourcecode from the VBScript demo as shipped with the project. This script opens the serial port the GPS is connected to, and reads a single GPS position from the device.
Option Explicit
' Declare variables
Dim objGps, objGpsConstants, objSatelliteInfo, i
' Create objects
Set objGps = CreateObject ( "Eye4Software.Gps" )
Set objGpsConstants = CreateObject ( "Eye4Software.GpsConstants" )
' Serial port settings
objGps.DeviceSerialPort = 1
objGps.DeviceBaudrate = 4800
' Optional: Only decode specific NMEA data
'objGps.Filter = objGpsConstants.GPS_NMEA_FILTER_VTG Or objGpsConstants.GPS_NMEA_FILTER_GGA
' Optional: Units
objGps.UnitsAltitude = objGpsConstants.GPS_ALTITUDE_FEET
objGps.UnitsSpeed = objGpsConstants.GPS_SPEED_KNOTS
' Optional: Latitude and Longitude strings formatting
objGps.LatLonStringFormat = objGpsConstants.GPS_LATLONFORMAT_DM
' Open serial port and start reading NMEA data
objGps.Open ()
If ( objGps.LastError <> 0 ) Then
WScript.Echo "Error opening device, error #" & objGps.LastError & " (" & objGps.LastErrorDescription & ")"
WScript.Quit (0)
End If
WScript.Echo "Waiting for GPS data..."
WScript.Sleep ( 5000 )
' Display GPS fix parameters
WScript.Echo ( "Time = " & objGps.gpsTime )
WScript.Echo ( "Latitude = " & objGps.gpsLatitudeString )
WScript.Echo ( "Longitude = " & objGps.gpsLongitudeString )
WScript.Echo ( "Altitude = " & objGps.gpsAltitude )
WScript.Echo ( "Sats = " & objGps.gpsSatellites )
WScript.Echo ( "Quality = " & objGps.gpsQuality )
WScript.Echo ( "BeaconID = " & objGps.gpsDifferentialID )
WScript.Echo ( "Diff Age = " & objGps.gpsDifferentialAge )
WScript.Echo ( "VDOP = " & objGps.gpsVDOP )
WScript.Echo ( "HDOP = " & objGps.gpsHDOP )
WScript.Echo ( "PDOP = " & objGps.gpsPDOP )
WScript.Echo ( "Speed = " & objGps.gpsSpeed )
WScript.Echo ( "Heading = " & objGps.gpsHeading )
WScript.Echo
WScript.Echo ( "Satellites in view" )
WScript.Echo
' Display all satellites in view
On Error Resume Next
Set objSatelliteInfo = objGps.GetFirstSatellite ()
On Error Goto 0
While ( objGps.LastError = 0 )
If ( objSatelliteInfo.ID <> 0 ) Then
WScript.Echo
WScript.Echo "Satellite Number " & objSatelliteInfo.ID
WScript.Echo " Used for fix : " & objSatelliteInfo.UsedForFix
WScript.Echo " Elevation : " & objSatelliteInfo.Elevation
WScript.Echo " Azimuth : " & objSatelliteInfo.Azimuth
WScript.Echo " Signal (dB) : " & objSatelliteInfo.SignalNoiseRatio
End If
On Error Resume Next
Set objSatelliteInfo = objGps.GetNextSatellite ()
On Error Goto 0
Wend
WScript.Sleep ( 3000 )
WScript.Echo "Ready."
objGps.Close ()