FakeGPS and Editing NMEA .txt files


So I have been doing a lot of work with Virtual Earth and Windows Mobile, incorporating GPS as well.  FakeGPS is an excellent tool to help GPS development but with one challenge:  How do you change the reported locations?

The FakeGPS tool reads from text files located in the GPSFiles folder where FakeGPS is installed on the device.

image

The files are in NMEA file format, reporting locations in the Seattle area.  There are a bunch of links out there that talk about the file format but I found this page to be useful.

http://www.gpsinformation.org/dale/nmea.htm

It explains the format and provides some examples.  What I did is grabbed a few sample entries from the file to create this sample file. I primarily looked at the entry for GPRMC, GPGGA, and GPGGLL at the above link to change the date, time, and location values for the entry. 

$GPRMC,053729,A,3203.156,N,08104.482,W,000.0,360.0,131008,015.5,E*
$GPRMB,A,,,,,,,,,,,,V*
$GPGGA,053730,3203.356,N,08104.482,W,1,05,1.6,646.4,M,-24.1,M,,*
$GPGSA,A,3,02,,,07,,09,24,26,,,,,1.6,1.6,1.0*
$GPGSV,2,1,08,02,43,088,38,04,42,145,00,05,11,291,00,07,60,043,35*
$GPGSV,2,2,08,08,02,145,00,09,46,303,47,24,16,178,32,26,18,231,43*
$PGRME,22.0,M,52.9,M,51.0,M*
$GPGLL,3203.360,N,08104.481,W,053730,A*
$PGRMZ,2062,f,3*
$PGRMM,WGS 84*
$GPBOD,,T,,M,,*
$GPRTE,1,1,c,0*
$GPRMC,053731,A,3203.482,N,08104.436,W,000.0,360.0,131008,015.5,E*
$GPRMB,A,,,,,,,,,,,,V*

You can modify this to generate GPS data for your desired location.  the bold items are either a UTC time or a date.  To help you interpret the values, the value of 053729 is UTC time in HHMMSS format.  The value of 131008 is October 13th, 2008 in DDMMYY format. 

The latitude data is in red and the longitude data is in green in the above example.  As an example, 3203.156,N represents 32 degrees, 03.156 minutes N.  08104.482,W represents 081 degrees, 04.482 minutes West. 

You will normally see latitude and longitude represented as something like this 32.2432 N and 081.1234 W (west and south are negative values) so you will have to convert between the float value and the degrees / minutes value.

The last thing I wanted to mention is that there is normally a checksum on the lines that end in an asterisk (*) in the file above.  The checksum value represents all of the characters between the $ and * XOR'd.  I was lazy and tested the file by simply leaving the checksum value off and it worked fine with FakeGPS.  So if you have another file that you want to modify, be sure to delete the checksum value after the asterisk.

Comments (3)
  1. It’s no secret that I believe location based services via mobile devices will absolutely change

  2. Ripper says:

    I am using the FakeGPS utility on Device Emulator. I was able to install it successfully. I then wrote a small app to test FakeGPS but the code does not seem to be working i.e I dont get the information from the NMEA text files.. as I am supposed to.

    Here’s the code I am using: (App)

    /** START **/

    #define FLAG 1

    HRESULT hr = S_OK;

    GPS_DEVICE gpsDeviceState;

    GPS_POSITION gpsPosition;

    HANDLE h_GPS;

    memset(&gpsDeviceState, 0, sizeof(GPS_DEVICE));

    memset(&gpsPosition, 0, sizeof(GPS_POSITION));

    h_GPS = GPSOpenDevice(NULL, NULL, NULL, 0);

    if (!h_GPS)

    {

    RETAILMSG(FLAG, (TEXT("FakeGpsApp:GPSOpenDevice failed!n")));

    return E_FAIL;

    }

    RETAILMSG(FLAG, (TEXT("FakeGpsApp:GPSOpenDevice succeededn")));

    gpsDeviceState.dwVersion = GPS_VERSION_1;

    gpsDeviceState.dwSize = sizeof(GPS_DEVICE);

    if (ERROR_SUCCESS == GPSGetDeviceState(&gpsDeviceState))

    {

    RETAILMSG(FLAG, (TEXT("FakeGpsApp:GPSGetDeviceState succeededn")));

    RETAILMSG(FLAG, (TEXT("ServiceState:%d, DeviceState:%dn"), gpsDeviceState.dwServiceState, gpsDeviceState.dwDeviceState));

    RETAILMSG(FLAG, (TEXT("Prefix:%s, FriendlyName:%sn"), gpsDeviceState.szGPSDriverPrefix, gpsDeviceState.szGPSFriendlyName));

    }

    else

    {

    RETAILMSG(FLAG, (TEXT("FakeGpsApp:GPSGetDeviceState failed!n")));

    }

    gpsPosition.dwVersion = GPS_VERSION_1;

    gpsPosition.dwSize = sizeof(gpsPosition);

    if (ERROR_SUCCESS == GPSGetPosition(h_GPS, &gpsPosition, 10000, 0))

    {

    RETAILMSG(FLAG, (TEXT("FakeGpsApp:GPSGetPosition succeededn")));

    RETAILMSG(FLAG, (TEXT("ValidFields:%d, SatelliteCount:%dn"), gpsPosition.dwValidFields, gpsPosition.dwSatelliteCount));

    RETAILMSG(FLAG, (TEXT("Latitude:%d, Longitude:%dn"), gpsPosition.dblLatitude, gpsPosition.dblLongitude));

    }

    else

    {

    RETAILMSG(FLAG, (TEXT("FakeGpsApp:GPSGetPosition failed!n")));

    }

    GPSCloseDevice(h_GPS);

    return hr;

    /** END **/

    And the debug msgs that I am getting are:

    /** START **/

    Load module: FakeGPSApp.exe

    .

    .

    FakeGpsApp:GPSOpenDevice succeeded

    FakeGpsApp:GPSGetDeviceState succeeded

    ServiceState:1, DeviceState:1

    Prefix:File, FriendlyName:TestGPSFile

    FakeGpsApp:GPSGetPosition succeeded

    ValidFields:0, SatelliteCount:0

    Latitude:0, Longitude:0

    .

    .

    /** END **/

    Although GPSOpenDevice and GPSGetDeviceState are working fine, GPSGetPostion does not seem to be returning the right values. Am I doing something wrong? I am not sure if this is the right place to post this, any help is appreciated 🙂

    I am using VS2005 to build the app and running it on Windows Mobile 6 Pro emulator. And yes, after installation of FakeGPS, I did enable the FakeGPS app.

    Thanks,

    Ripper

Comments are closed.

Skip to main content