Results 1 to 2 of 2
  1. #1
    steven6282 is offline Member
    Join Date
    Dec 2011
    Rep Power

    Default Receiving GPS data through Comm port

    EDIT: Dumb mistake... see reply if you don't want to waste time reading this first post.

    Hello all,
    I just recently started working on a project in Java. So I'm rather new to java, but I have been programming for around 13 years now. This project among other things has a need to receive GPS data from a USB GPS Receiver that is connected as a Comm port. I know the Comm number and can get the GPS data by connecting directly to that comm port using putty, but having some problems doing it in Java.

    I downloaded and am using the Rxtx comm library. I first tried using their example serialreader code, but that spit out complete gibberish. So I have written my own code that is returning some non gibberish information, but it is as though it's completely missing some of the data.

    This is my code I'm using currently to read the incoming data from the com. (Some preliminary information, is an InputStream that is passed into the function. The inputstream is created using the rxtx method (SerialPort)commPort.getInputStream() after successfully connecting to the correct port.

    Java Code:
    String readIn="";
    boolean processing=true;
    try {
         while(processing) {
              if (!=-1) readIn = new String (readIn + (char);
              if (
                   if (readIn != "") System.out.println(readIn);
    } catch (IOException e) {
    I know the code is probably not the best tactic in the world to do this but atm I'm just experimenting and trying to get it to work. This is the kind of output I'm seeing from this code:

    Java Code:
    Like I said, it looks like it is picking up some of the characters and just completely missing others, really strange.

    I know there are projects and stuff already out there to work with GPS devices and such, but I'm doing this as a hobby and enjoy trying to figure things out and write it from scratch myself. Sometimes though I get stumped on something like this and just can't figure out why it's doing what it's doing so I have to seek help :)

    It would be nice if there was a bare minimalistic project out there for reading data from the serial port on Windows with no bells and whistles so that I could figure out the root concept and build on it.

    Any help on this would be appreciated.
    Last edited by steven6282; 12-08-2011 at 10:06 PM.

  2. #2
    steven6282 is offline Member
    Join Date
    Dec 2011
    Rep Power

    Default Re: Receiving GPS data through Comm port


    what a dumb mistake.

    I looked at that code right after posting it reviewing my post.. and realized I'm calling multiple times.. and it just makes sense that every time I call it, it's reading the next character, so of course I'm missing characters, I'm only capturing 1 in 3 characters...

    *sigh*.... *facepalm*

    Sorry to have wasted your time reading that post! If a mod wants to delete the post feel free, I'm leaving it there as a reference on how to make dumb mistakes and look foolish posting them .. haha.
    Last edited by steven6282; 12-08-2011 at 10:05 PM.

Similar Threads

  1. Replies: 1
    Last Post: 12-08-2011, 04:39 PM
  2. Replies: 2
    Last Post: 03-04-2011, 09:14 AM
  3. GIOVYNET Java Serial Comm Port Question
    By the_justin in forum New To Java
    Replies: 1
    Last Post: 11-30-2010, 12:13 PM
  4. Replies: 7
    Last Post: 06-22-2010, 10:49 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts