Click here to Skip to main content
11,930,231 members (42,997 online)
Click here to Skip to main content
Add your own
alternative version

Tagged as



Enhanced GPS sample update

, 14 Jun 2010 CPOL
Rate this:
Please Sign up or sign in to vote.
The modded MS GPS_Sample application with the addition to support streamed serial raw GPS data like that available on Intermec CN50

Sometime ago, I published my modded GPS_Sample code (see, which is based on a Microsoft GPSsample.

This time I added support for Int*rm*c CN50, which does NOT support reading raw GPS data using a serial connection. Instead the CN50 streams the data to the ‘communication’ port.

BTW: did you know how easy it is to create skins for use with MyMobiler?

The stream reader part is outsourced into a thread, which is based on my background thread class bgThread2 (see It was very easy to implement the stream reading within the thread, so the GUI is not blocked during read waits.

#region TheTHREAD
private void myThreadStart()
    System.Diagnostics.Debug.WriteLine("Entering thread proc");
    int _i=0;
            //The blocking function...
            char[] cSep = new char[] { '\r', '\n' };
            int iRes = 0;
                string sRes = "";
                iRes = GPS_Sample8.ReadFileClass.readFile(_sCOM, ref sRes);
                string[] sAll = sRes.Split(cSep);
                foreach (string s1 in sAll)
                    SendData(bgWnd.Hwnd, iRes, s1);
            } while (iRes == 0);
            System.Diagnostics.Debug.WriteLine("Thread sleeps...");
        } while (bRunThread);
    catch (ThreadAbortException)
        System.Diagnostics.Debug.WriteLine("Thread will abort");
        bRunThread = false;
    catch (Exception ex)
        System.Diagnostics.Debug.WriteLine("Exception in ThreadStart: " + ex.Message);
    System.Diagnostics.Debug.WriteLine("ThreadProc ended");

The main form code has some new functions to check for iCN50 and start/stop the stream reader background thread:

#region CN50raw
bgThread2 myStreamReaderThread;
private void OpenStream()
    //background thread already running?
    if (myStreamReaderThread == null)
        string szPort="";
        szPort = GetGPSPort();
        if (szPort != "")
            //start a new thread
            myStreamReaderThread = new bgThread2(szPort);
            myStreamReaderThread.bgThread2Event += 
	       new bgThread2.bgThread2EventHandler(myStreamReaderThread_bgThread2Event);
            AddRawText("No raw GPS port found");

void myStreamReaderThread_bgThread2Event(object sender, bgThread2.BgThreadEventArgs bte)
private void CloseStream()
    if (myStreamReaderThread != null)
        myStreamReaderThread = null;
    mnuRAWStart.Enabled = true;
    mnuRAWStop.Enabled = false;

Download (VS2008 solution targeting WM6 SDK)

<!-- Social Bookmarks BEGIN -->

<!-- Social Bookmarks END -->


This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)


About the Author

Germany Germany
No Biography provided

You may also be interested in...

Comments and Discussions

GeneralWhy some delay (not always) Pin
jozeunico27-Jul-12 9:46
memberjozeunico27-Jul-12 9:46 
GeneralRe: Why some delay (not always) Pin
hjgode27-Jul-12 20:04
memberhjgode27-Jul-12 20:04 
GeneralRe: Why some delay (not always) Pin
jozeunico30-Jul-12 6:52
memberjozeunico30-Jul-12 6:52 
GeneralRe: Why some delay (not always) Pin
hjgode30-Jul-12 7:52
memberhjgode30-Jul-12 7:52 
GeneralRe: Why some delay (not always) Pin
jozeunico30-Jul-12 9:14
memberjozeunico30-Jul-12 9:14 
GeneralRe: Why some delay (not always) Pin
hjgode30-Jul-12 18:55
memberhjgode30-Jul-12 18:55 
GeneralRe: Why some delay (not always) Pin
hjgode21-Nov-12 5:54
memberhjgode21-Nov-12 5:54 
GeneralRe: Why some delay (not always) Pin
jozeunico21-Nov-12 5:58
memberjozeunico21-Nov-12 5:58 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.

| Advertise | Privacy | Terms of Use | Mobile
Web02 | 2.8.151126.1 | Last Updated 14 Jun 2010
Article Copyright 2010 by hjgode
Everything else Copyright © CodeProject, 1999-2015
Layout: fixed | fluid