This discussion is archived
7 Replies Latest reply: Jul 11, 2012 3:30 AM by 946406 RSS

How to detect if GPS device is connected to com port.

946406 Newbie
Currently Being Moderated
Actually I am using Java Comm API for to get NMEA string from GPS receiver.

But i want to know, how to automatically find which serial port has the GPS Receiver connection using java program?

Please reply me if anybody know?

Thanks ,

Regards,

Manoharan G
  • 1. Re: How to detect if GPS device is connected to com port.
    sabre150 Expert
    Currently Being Moderated
    Iterate over the serial ports until one responds correctly.
  • 2. Re: How to detect if GPS device is connected to com port.
    946406 Newbie
    Currently Being Moderated
    Gps receiver takes atleast 5 minutes to fix the satellite and receive the signal .Till that time there is no response from any COM port.

    My concern is how to know to which COM port the device is attached even when it has not fixed satellite .
  • 3. Re: How to detect if GPS device is connected to com port.
    EJP Guru
    Currently Being Moderated
    If the correct COM port takes 5 minutes to respond then you have to wait 5 minutes. There is no magic bullet.
  • 4. Re: How to detect if GPS device is connected to com port.
    946406 Newbie
    Currently Being Moderated
    Thanks for your reply.Though i was looking some way to detect the device but i guess there is no solution other than to wait for signal.
  • 5. Re: How to detect if GPS device is connected to com port.
    EJP Guru
    Currently Being Moderated
    There isn't. Only the device can provide the data that identifies the device. Apart from that all devices attached to a COM port are just serial devices.
  • 6. Re: How to detect if GPS device is connected to com port.
    946406 Newbie
    Currently Being Moderated
    This is okay but the Utility program in the HOLUX device cd (Which i am using) can find COM port of the GPS device even when the satellite are not fixed .It means there is some way to detect earlier.I also got know the GPS device will transmit NMEA string with all zero's as soon as connected even if it is not fix satellite.

    May be i will try read this zero's value NMEA string.

    Thanks ,i will update you

    Regards,
    Manoharan G
  • 7. Re: How to detect if GPS device is connected to com port.
    946406 Newbie
    Currently Being Moderated
    I got the solution for this problem.So i want to say thanks for you.

    I didn't know GPS device send NMEA string even if it is not fix the satellite.

    So i can follow your approach what you already said.(Iterate over the serial ports until one responds correctly)

    My code using javax.com library:

                        //For every com port we have to follow below approach
                        serPort = (SerialPort) portId.open(
                             "GPS_Locator", // Name of the application asking for the port
                             10000 // Wait max. 10 sec. to acquire port
                   );
                        serPort.setSerialPortParams(4800,SerialPort.DATABITS_8, SerialPort.STOPBITS_1,SerialPort.PARITY_NONE);
                        instream = new BufferedReader(new InputStreamReader(serPort.getInputStream()));
                        is=serPort.getInputStream();
                        System.out.println("The current is "+serPort.getName()+" "+is.available());
    //Important
                        if(is.available()>0){  //Get GPS receiver port if it is true
                                  System.out.println(instream.readLine());
                        }

    Thanks,
    Regards,

    Manoharan G

    Edited by: 943403 on Jul 11, 2012 3:29 AM

Legend

  • Correct Answers - 10 points
  • Helpful Answers - 5 points