DEVBUZZ Homepage How to make your application work together with other GPS software
 
Web www.devbuzz.com
  HOME PAGE
  All Articles
  Advertise
  Consulting

 Development
  Discuss - Forums
  Still in the box?
  .Compact Framework
  Code Snippets
  SQL Server CE
  Database
  MS Resources
 Stores
  Developer Controls
  Pocket PC Hardware
  Pocket PC Software
  Pocket PC Books
  .NET CF Books
  Book Reviews
  SPB SW Discounts
  RESCO SW Discounts
 DEVBUZZ Info
  About Us
  Help
  Join our email list
  Links & Ratings
  Press & Comments
  Pocket PC version
  Software Reviews
  Hardware Reviews
 Authors
  Authors
  Article Guide
  Competitions
 Resources
  Developers
  Register
  Login

  SPB Discounts!
 Columnists
  Rick Winscot
 Past Blast
  Personal Media Ctr
  Gizmobility
  eVB Legacy
  Old news
  Hosted Software
  Wireless
  Newsletters
  Carl Davis
  Upton Au

 Pocket PC Registry
  Join the registry
  View current list
 Current Poll
Are you converting to .NET Compact Framework?
Yes, it has changed my life!
No, I'm sticking with eVB
.NET CF what's that`?

Current results
3431 votes so far
 Recent Forum Threads [goto forums]

Get Computername
read... (67 hits)


Great aid to development productivity
read... (82 hits)


ThreadingTimer sample code
read... (143 hits)


Multithreading with .NET CF
read... (194 hits)


Moving from eMbedded Visual Basic to Visual Basic .NET
read... (166 hits)


.NET Compact Framework 2.0 Service Pack 2
read... (226 hits)


Transfer Data from SQL Server 2000 to SQL Server Compact Edition
read... (298 hits)


This protocol version is not supported
read... (236 hits)


Converting Lowercase to uppercase wont work
read... (203 hits)


Direct access to MS SQL Server 2000
read... (374 hits)


Creating SDF file in Desktop
read... (513 hits)


Winsock in CF.NET
read... (316 hits)


Using Pocket Outlook to submit HTML page form with MAILTO action
read... (420 hits)


Missing file "System.Data.PocketPC.asmmeta.dll"
read... (268 hits)


HP iPAQ hw6915 Serial Port Issue
read... (309 hits)


Info on the recent forum changes
read... (341 hits)


SqlServer tools from Redgate
read... (383 hits)


Arrow keys and Hardware navigation button
read... (393 hits)


O2 XDA lls pin sync cable to comport
read... (322 hits)


Creating dynamic folders on Pocket PC OS
read... (299 hits)

Custom Windows Mobile software development.
LBS Challenge 2007
LBS Challenge Eight previous NAVTEQ Global LBS ChallengeŽ participants have received venture capital funding and nine past LBS Challenge winners have launched commercial applications on major wireless carriers. Register your non-commercial LBS application in the 2007 NAVTEQ Global LBS Challenge in one of three regions: Americas, Europe-Middle East-Africa (EMEA) or Asia-Pacific(APAC). You could win a share of $2 million in prizes. This could be your year.
Dream. Develop. Win.

Development | .NET Compact Framework

How to make your application work together with other GPS software
Written by Jonas Kämpe  [author's bio]  [read 29544 times]
Edited by Derek

.NET Compact Framework   

Page 1  Page 2 

Dot Net programming example: Sharing a GPS by using GpsGate

This example shows briefly how to open access to the GPS via GpsGate in a Dot Net Form and read position data from the device, as well as using GpsGate to act as a data source to other applications. This code example is for Windows Mobile devices, but GpsGate works well on any PC running Windows.

The easiest way to start developing using the GpsGate API is to download the GpsGate SDK from Franson Technology (http://www.franson.biz/gpsgate/dev_guide.asp?platform=ppc). There you will find code examples for both Windows and Windows Mobile, in C# .Net, VB/eVB, and VC++/cVC++.

First, what you need to do in order to make the GpsGate API accessible to your .Net Compact Framework application is to reference the GateApiNET.dll found in the GpsGate SDK. All functions in the Dot Net GpsGate API are then available to programmers through an on object called Simple.

From within a form, all you have to do is to set up a variable for the GateApi object and create a new Simple object:

private GateApiNET.Simple m_simple = null;
m_simple = new GateApiNET.Simple();

Whenever GpsGate receives data from the GPS, it will generate an OnRead event, and we set our form to handle it:

m_simple.OnRead += new GateApiNET.OnRead(Form1_OnRead);

…and the button to open the GPS:

this.bOpen.Text = "Open the GPS";
this.bOpen.Click += new System.EventHandler(this.bOpen_Click);
this.Controls.Add(this.bOpen);

…and a label for displaying the read position data:

this.txtRead.Text = "";
this.Controls.Add(this.txtRead);

The event handler for the “open”-button uses StartGpsGate() to make sure GpsGate is up and running, and specifies that we want to read the output channel of GpsGate. There is no need to specify a particular COM port or to have any other knowledge of the GPS:

private void bOpen_Click(object sender, System.EventArgs e)
{
try
{
m_simple.StartGpsGate();
m_simple.Open("_output");
}
catch(Exception ex)
{
MessageBox.Show(ex.Message);
}
}

Finally, we add the event handler that will be called each time new data is available from the GPS:

private void Form1_OnRead(string Data)
{
if(Data == null)
{
// Connection is down. GpsGate was probably closed
MessageBox.Show("Connection down");
m_simple.Close();
}
else
{
txtRead.Text = Data;
}
}

Your device should by now be connected to the application, and NMEA strings will appear in the text box as soon as the GPS gets a fix.

Adding more functionality: acting as a position source

GpsGate also provides a feature to act as a source of GPS data to other applications – basically your application can simulate an GPS.

In that case we would change the channel above into “_input” and add an event for writing, to send back an NMEA sentence into GpsGate and to all listening applications:

private void bWrite_Click(object sender, System.EventArgs e)
{
try
{
m_simple.Write("$GPRMC,093339,A,5917.40531,N,01806.38798, E,10.0,147.2,040607,0.0,E*4A\r\n");
}
catch(Exception ex)
{
MessageBox.Show(ex.Message);
}
}

Higher-level GPS tools

In addition to offering a clean programmable application interface for accessing and sharing a GPS, users can benefit from the same features by setting up GpsGate manually. Something very handy during both debugging and demonstrations is the ability to log and retransmit NMEA sentences to other applications. You can also define a set of waypoints and let GpsGate simulate travel between those.

For readers that have not already developed a GPS application ready to be shared, Franson Technology also provides several other tools for rapid GPS application development. Most notably GpsTools is a program that includes support for reading GPS data, converting between different coordinate systems and plotting to raster maps. It also integrates directly with GpsGate, making it a low-threshold introduction to GPS programming, with plenty of easy-to-follow examples in VB, .Net and C++.

By using tools such as these, you should be up and running with your GPS application development within a couple of hours, while still allowing for your users to mix and match between their favourite GPS applications!

For further case studies see http://franson.biz/gpsgate/case.asp.

Previous Page 

Back to .NET Compact Framework | [Article Index]

 

Back to the top of the page.
Franson GPS tools for the Pocket PC Chris De Herrera's Windows CE Website Windows CE News & Information Source RESCO Software discounts
Copyright ©2000-2008 by DEVBUZZ.COM, Inc., TX. USA.