Editor's Note
Tales of a GPS Demo

Code download available at: Ednote0309.exe (1,016KB)

One of the most annoying things about the Internet is that no matter how hard you try to make something permanent, it can be gone tomorrow with no forwarding address. We found this out the hard way earlier this year, and we're hoping to remedy the situation with this Editor's Note. Let us explain.

Back in 2001, we presented an article called "Migrating a GPS App from the Desktop to eMbedded Visual Basic 3.0," which set the standard for articles about migrating GPS apps to the Pocket PC. A year and a half later, the .NET Compact Framework was introduced in beta, and we decided to update the GPS app to fix a few bugs, modularize it, and bring the power of the .NET Framework to it. We planned to present it at the ASP.NET Connections conference in October 2002.

There were several interesting challenges in porting a program like this. The first big obstacle was accessing the COM port, since a GPS device communicates with the host machine through an RS-232 serial port. If you'll take a quick look at the .NET Framework, you'll find no classes to do native serial comm! There were two choices here. The first was to use the MSComm ActiveX control on a form—but the .NET Compact Framework doesn't support embedded ActiveX components. So we could either spend valuable minutes of our life wrapping MSComm and hoping for the best with a direct port or we could create a wrapper class.

About the time we were working on this project, we published an article called "Use P/Invoke to Develop a .NET Base Class Library for Serial Device Communications" by John Hind. The ideas in this piece were all we needed to create a .NET Compact Framework version of a serial comm library (it's not exactly the same as the desktop version since it uses different DLL exports). Putting this serial comm class together with a bit of simple threading, we created a more robust serial engine for the program.


There were a number of other challenges we faced in creating the session, which we documented for the anticipated assembled throng at the conference. Everything was going great. We had a stable beta of Visual Studio .NET 2003 running on the demo machine, but about a month before the conference, terror hit. The trusty laptop decided it no longer recognized a key peripheral—the power cord. Within days the only solution was to use the machine with its docking station attached at all times. Then the keys started popping off. We put in an emergency order for a new laptop, which arrived just in the nick of time.

Everything was reinstalled and working just fine as we got to Orlando. We got the project up and running with sample data, so there was only one step left—the live test. We went to plug in the trusty GPS unit and...and...where's the nine-pin adapter? When did they start making laptops without a nine-pin serial port, and why did we order the first one ever produced? What a mess. Fortunately, we had a backup PC Card GPS receiver.

The talk itself went pretty well (it was erroneously listed as GPRS, instead of GPS, so we only managed to get a dozen or so people in attendance, but they were all treated to a memorable mid-morning event). Now here's the problem. After the conference, we put the code up on the free Web space given to us by an ISP and told everyone to download the code from there. A few months later, the nice folks at this satellite company got out of the DSL business. We switched over to another national ISP, but can't figure out how to use the shell account. With nearly a dozen people clamoring for this .NET Compact Framework project, and another quarter-handful looking for it on various newsgroups, we thought we'd give it a more permanent home. The PowerPoint presentation and associated sample code are available as the download for this Editor's Note (see the link at the top of this article). We think that's a pretty permanent location.

Now for this year's ASP.NET Connections conference, we're working on another program that will draw maps directly from data provided by the U.S. Census Bureau. This is going to be even cooler than last year's demo, and we hope to see at least two dozen of you there this October.

—J.T.

BizTalk, JScript, Microsoft, MSDN, Outlook, Visual Basic, Visual C++, Visual SourceSafe, Visual Studio, Windows, Windows NT, and Win32 are registered trademarks of Microsoft Corporation. Other trademarks or tradenames mentioned herein are the property of their respective owners.

MSDN Magazine does not make any representation or warranty, express or implied with respect to any code or other information herein. MSDN Magazine disclaims any liability whatsoever for any use of such code or other information.

© 2007 Microsoft Corporation and CMP Media, LLC. All rights reserved; reproduction in part or in whole without permission is prohibited.