Search code examples
javagpsjava-native-interfacejavax.comm

javax.comm : Identify which serial port my GPS device is operating


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.


Solution

  • 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.