Eleven GPS speedo

The "Eleven" is our Uno-equivalent Arduino-compatible board, but with a number of improvements including prototyping area, a mini-USB connector, LEDs mounted near the edge, and the D13 LED isolated using a FET. [Product page]

Eleven GPS speedo

Postby mjwillia » Wed Aug 01, 2012 1:29 am

I'm very new to Arduino.

I'm making a GPS speedo and I'm trying to read in some serial, store a value from a substring and echo it back via serial.

At the moment I'm having problems storing the substring.

I've gotten to the point where I'm able to get some data between < and >. But the data doesn't come in like that. It's NMEA data stream and the data I want is between ,N, and ,K,

So I've been trying to replace ,N, with < and ,K, with >

Just can't get it to work. I get 'error: request for member 'replace' in 'c', which is of non-class type 'char''

Here's my code so far....
Code: Select all
int indata = 0;
int scrubdata = 0;
char inString[32];
int stringPos = 0;
boolean startRead = false; // is reading?



void setup() {
Serial.begin(4800);
}

void loop() {

String pageValue = readPage();

Serial.print(pageValue);

}

String readPage(){
//read the page, and capture & return everything between '<' and '>'

stringPos = 0;
memset( &inString, 0, 32 ); //clear inString memory

while(true){
if (Serial.available() > 0) {

  char c = Serial.read();
     c.replace(",N,", "<");
     c.replace(",K,", ">");

  if (c == '<' ) { //'<' is our begining character
    startRead = true; //Ready to start reading the part
  }else if(startRead){

    if(c != '>'){ //'>' is our ending character
      inString[stringPos] = c;
      stringPos ++;
    }else{
      //got what we need here! We can disconnect now
      startRead = false;
      return inString;

    }

  }
}

}

}



If there's a better way to do this I'm all ears :)
mjwillia
 
Posts: 4
Joined: Thu Jun 21, 2012 12:11 am

Re: Eleven GPS speedo

Postby Sleurhutje » Mon Aug 06, 2012 6:20 pm

First of all, I would seperate GPS data from other serial data (unless you're simulating something).

Second, use TinyGPS and a second SoftSerial port to connect te GPS to. TinyGPS does all the calculations.
Sleurhutje
 
Posts: 28
Joined: Thu Mar 01, 2012 9:18 am


Return to Eleven

Who is online

Users browsing this forum: No registered users and 1 guest