views:

307

answers:

3

Hi All,

I have a GPS device connected to my system which is having Windows Vista,

I wanted to read the NMEA sentences from GPS device and print on screen.

How I will come to know, on which port the GPS device has been connected, as there can be other devices also connected on various com ports.

I am developing the application in c++,

does micro soft gives any api's for this

with regards

Vinayaka Karjigi

A: 

What kind of port is it? If it is a serial port, try connecting to all serial ports, one at a time, and then just listen for a NMEA string. If one is received, use the port, if one is not received, go to the next port.

Marius
hmm okie.thank u for quick response.can i fix any time interval for this and after timer expires i can run in a for loop and check all the ports rite??
Vinayaka Karjigi
A: 

I'd tend to prompt the user for the port. NMEA typically comes in as an ASCII string through a COM port. Before bluetooth, this used to typically be COM1 to COM4 with 90% of cases being either COM1 or COM2. It is more common now to connect via bluetooth, where you regularly see COM ports up to COM20 and above, so brute force is a slow option. The time taken to check all ports depends on how often your GPS sends sentances (assuming it does not require prompting) and your time-outs. You could expect a search to take up to 30 seconds. If you enumerate the COM ports this will be much quicker, as there will rarely be more that half a dozen active ports at any one time.

Shane MacLaughlin
A: 

Well, in old times you gave the user of your application the privilege to specify the proper port ;) Or indeed, check all of them. Format and the available set of NMEA sentences can differ depending on the particular device - read some info here, for example, but the sentences should be plain text. (If not then it's not NMEA format :) )

Ashalynd