The information contained here are property of DIGITAX Automotive Electronics Italy, and extremely confidential. Any disclosure, copying, distribution to third
party is strictly prohibited.
48
GPS
This application shows how to use the GPS library to interact with the GPS receiver. You can get the
position and satellites data. There is also the possibility to ask for the receiver version and the
antenna connection status.
Sample code:
using
System;
using
System.Collections.Generic;
using
System.ComponentModel;
using
System.Data;
using
System.Drawing;
using
System.Text;
using
System.Windows.Forms;
namespace
Digitax.Sample.GPSTest
{
//simple application that shows how to get data from the GPS receiver
public
partial
class
GPSTestForm
:
Form
{
//gps wrapper and data instances
GPS.Wrapper41.
GPSWrapper
_gps =
new
GPS.Wrapper41.
GPSWrapper
();
GPS.Wrapper41.
GSADATA
_gsaData =
new
GPS.Wrapper41.
GSADATA
();
GPS.Wrapper41.
RMCDATA
_rmcData =
new
GPS.Wrapper41.
RMCDATA
();
GPS.Wrapper41.
SatelliteData
[] _satellites;
string
_swVersion =
""
;
string
_HwVersion =
""
;
ushort
_agc = 0;
byte
_antennaStatus = 0;
bool
_satsUpd =
false
;
bool
_rmcUpd =
false
;
bool
_versUpd =
false
;
bool
_hwMonUpd =
false
;
public
GPSTestForm()
{
InitializeComponent();
this
.C=
new
CancelEventHandler
(GPSTestForm_Closing);
//init reciver on MDT/MCU reciver is on COM1: - ForceOne COM2:
_gps.GPSInitData(
"COM1:"
, 9600);
//init events and callbacks
_gps.EvGPSGSVSatellitesCa=
new
GPS.Wrapper41.
GPSWrapper
.
delGPSGSVSatellitesCallback
(_gps_EvGPSGSVSatellitesCallback);
_gps.EvGPSPositionCa=
new
GPS.Wrapper41.
GPSWrapper
.
delGPSSetPositionCallback
(_gps_EvGPSPositionCallback);
_gps.EvGPSUbxCallbacksAntarisHwM=
new
GPS.Wrapper41.
GPSWrapper
.
delGPSSetUbxCallbacksAntarisHwMonitor
(_gps_EvGPSUbxCallbacksAntarisHwMonitor);
_gps.EvGPSUbxCallbacksAntarisV=
new
GPS.Wrapper41.
GPSWrapper
.
delGPSSetUbxCallbacksAntarisVersion
(_gps_EvGPSUbxCallbacksAntarisVersion);
_gps.GPSInitPositionCallback();
_gps.GPSInitGSVSatellitesCallback();
_gps.GPSInitUbxCallbacks();
}
void
_gps_EvGPSUbxCallbacksAntarisVersion(
string
wzSwVersion,
string
wzHwVersion,
uint
lpParam)
{
//version recived
_swVersion = wzSwVersion;
_HwVersion = wzHwVersion;
_versUpd =
true
;
UpdForm();
}
void
_gps_EvGPSUbxCallbacksAntarisHwMonitor(
ushort
wAgcPermille,
byte
bAntennaStatus,
byte
bAntennaPower,
uint
lpParam)
{
//hw monitor data recived
_agc = wAgcPermille;
_antennaStatus = bAntennaStatus;
_hwMonUpd =
true
;
UpdForm();
}
void
_gps_EvGPSPositionCallback(GPS.Wrapper41.
RMCDATA
pRMCData, GPS.Wrapper41.
GSADATA
pGSAData,
uint
lpParam)
{
//rmc and gsa data racived
_rmcData = pRMCData;
_gsaData = pGSAData;
_rmcUpd =
true
;
UpdForm();
}
void
_gps_EvGPSGSVSatellitesCallback(GPS.Wrapper41.
SatelliteData
[] satsData,
uint
lpParam)
{
//satellites data recived
_satellites = satsData;
_satsUpd =
true
;
UpdForm();
}
private
delegate
void
delUpdForm
();
private
void
UpdForm()
{