problem in NMEA parser

Discussion in 'General GPS Discussion' started by naina, Feb 19, 2011.

  1. naina

    naina

    Joined:
    Feb 19, 2011
    Messages:
    1
    Likes Received:
    0
    hello everybody, i am having difficulty to calculate speed from bluetooth GPS
    i am using the following codes,
    public void readNMEASentences() {
    try {
    if (!isConnected) {
    return;
    }
    // check characters available
    int size = in.available();
    if (size <= 0) {
    return;
    }
    // read data
    for (int j = 0; j < size; j++) {
    int i = in.read();
    if (i != -1) {
    char l = (char) i;
    switch (mode) {
    case (STATE_SEARCH_SENTENCE_BEGIN): {
    // search for the sentence begin
    if (l == '$') {
    // found begin of sentence
    mode = 1;
    sb.setLength(0);
    }
    }
    break;
    case (STATE_READ_DATA_TYPE): {
    // check what kind of sentence we have
    sb.append(l);
    if (sb.length() == 6) {
    if (sb.toString().startsWith("GPGGA")) {
    mode = STATE_READ_SENTENCE;
    sb.setLength(0);
    } else {
    mode = STATE_SEARCH_SENTENCE_BEGIN;
    sb.setLength(0);
    }
    }
    }
    break;
    case (STATE_READ_SENTENCE): {
    // read data from sentence
    sb.append(l);
    if ((l == 13) || (l == 10) || (l == '$')) {
    mode = STATE_SEARCH_SENTENCE_BEGIN;
    currentInfo = new String(sb.toString());
    }
    }
    break;
    }

    } else {
    close();
    }
    }

    } catch (Exception e) {
    close();
    }
    }


    and can't figure out where to place GPRMC exactly, am always having errors, plz help
    Thank u
     
    naina, Feb 19, 2011
    #1
Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments (here). After that, you can post your question and our members will help you out.
Similar Threads
There are no similar threads yet.
Loading...