0

I am writing a small application which uses the javax.comm api to return an enumeration of comms ports, using the following syntax CommPortIdentifier.getPortIdentifiers(); My question is how would one programmatically identify which port my GPS device is operting on. Anyone got any ideas??

T.

T-Pane
  • 3
  • 1

1 Answers1

1

You have to probe each one individually: Open it, set baudrate, wait for NMEA sentences. Every GPS that I know of sends NMEA data once a second, so if you don't get NMEA data after a few secs (or can not open the port) then its not your GPS. In java the GPS port is indistinguishable from other COM ports.

BTW: Don't try to run too many checks in parallel, the serial driver architecture does not like that too much, especially if bluetooth serial ports are involved.

Turbo J
  • 7,563
  • 1
  • 23
  • 43
  • 1
    Excellent! Yeah I thought I would have to do some parsing of NMEA formatted strings. I think each string in the NMEA protocol starts with $, so this shouldn't be too difficult (http://en.wikipedia.org/wiki/NMEA_0183). Just wanted to make sure this was the correct approach. Thanks for the swift answer. – T-Pane May 04 '11 at 13:10