GPS Connection and Position

2950
2
Jump to solution
11-22-2012 07:37 AM
JohnFannon
Occasional Contributor III
Hi All

I've got a requirement to connect to the GPS device and log the current position to a file on a mobile unit running windows - there's no requirement to show the position on a map. I've put together some ArcObjects (v10) code based on some of the samples that uses IRealTimeFeedManager, IGPSFeed and IGPSConnection, but am struggling to get it reporting the position.

The code is basically similar to the following:

IRealTimeFeedManager realTimeFeedMgr = new RealTimeFeedManagerClass(); IGpsFeed gpsFeed = realTimeFeedMgr.GpsFeed;  IGpsConnection gpsConnection = gpsFeed.Connection; gpsConnection.CommPort = 1; gpsConnection.BaudRate = (short)esriGpsBaudRate.esriGpsBaudRate9600; gpsConnection.DataBits = 8; gpsConnection.Parity = esriGpsParity.esriGpsParityNone; gpsConnection.StopBits = 1; gpsFeed.Connection = gpsConnection;  realTimeFeedMgr.RealTimeFeed = (IRealTimeFeed)gpsFeed; realTimeFeed.Start();  System.Diagnostics.Debug.WriteLine("Status: " + realTimeFeed.Status.ToString());  esriGpsConnectionError conError = realTimeFeed.ConnectionError; System.Diagnostics.Debug.WriteLine(conError.ToString());  esriGpsPositionInfo posInfo = realTimeFeed.CurrentPosition; System.Diagnostics.Debug.WriteLine("Position: " + posInfo.latitude.ToString() + "," + posInfo.longitude);  realTimeFeed.Stop();


When I debug the code, the output is always:

Status: esriGpsConnectionStatusOpen
esriGpsConnectionErrorNone
Position: 0,0


I've messed around a little with the baud settings etc, but can't get it to report the status as esriGpsConnectionStatusReceiving, which I guess is why it's returning the position as 0,0.

Has anyone got any pointers as to what I'm doing wrong or perhaps can you confirm that the above should work? There aren't too many samples that use IGPSFeed, they mainly use a simulated feed.

Anyway. I'd appreciate any thoughts on this. Otherwise I may have to take another, possibly non-Esri route.

Thanks

John
0 Kudos
1 Solution

Accepted Solutions
JohnFannon
Occasional Contributor III
This issue was related to a problem with the GPS card on the laptop involved.

View solution in original post

0 Kudos
2 Replies
DubravkoAntonic
New Contributor III
Use IGpsFeed.TestStatus to see what it returns.

Just one simple idea:
- do you have signal if you are using it in the office.
- maybe your GPS haven't fixed on satellite if it has a weak signal.

Test output of GPS with some SerialPort monitor or if you have NMEA parser, and find by hand tag that holds coordinates.

Be sure that you have valid baudrate before using it with AO, some OEM GSP modules are by default at 4800.

Regards
0 Kudos
JohnFannon
Occasional Contributor III
This issue was related to a problem with the GPS card on the laptop involved.
0 Kudos