NewSoftSerial storing a NMEA string

Well here goes. I'm in the process of piecing together a rocket flight computer (overall coming along very nicely, will have site posted shortly), and am stuck on the last bit of code to get the system operational. Basically, what i have been doing is reading from a standard gps (NMEA) using newsoftserial on pins 2,3, then printing the serial output from that. This looks like so:

while (gps.available()) { Serial.print((char)gps.read()); }

That works very nicely in the serial monitor and jazz, good to go no problem. I figured what it was going was loading the entire NMEA string with the gps.read() command and passing it on. What i'm trying to do now is save that gps data to an SD card as well, using the SDFat library. (Using Arduino Pro Mini, plenty of sketch size left) I basically tried to have the gps.read() go to a char variable at first, then quickly realized that all that gps.read() does it spit out a small little chunk of the data, which i didnt notice because all i saw of the data was what spit out the serial. So i made the gps.read() spit out to an array. This worked more or less ok, and i was able to get some output data on the card, as well as the serial, although the serial turned into garbage data from the NMEA strand and the SD card data file had NMEA strings broken into two like so:

$GPGGA,135401.242,,,,,0,00,,,M,0.0,M,,0000*50 $GPGS?,A,y,,, ,,,3,1, $GPGGA,135401.242,,,,,0,00,,,M,0.0,M,,0000*50 $GPGS$.A, .,,v,,,3,1, $GPGGA,135402.248,,,,,0,00,,,M,0.0,M,,0000*59 $GPGS ,A,p,,,f,,,,21, 0610,,*24 02.248,,,,,0,00,,,M,0.0,M,,0000*59 $GPGS .A, .,,a,,,,21, $GPGGA,135403.240,,,,,0,00,,,M,0.0,M,,0000*50 $GPGSÒ,A,Å,,,e,,$GPR, MC,135403.240,V,,,,,,,210610,,*2D M,,0000*50 $GPGS .A, .,,+,,$GPR, $GPGGA,135404.243,,,,,0,0010,,*2D M,,0000*50 $GPGS?/A,?/,,a,,$GPR, ,,,M,0.0,M,,0000*54 $GPGSA,A,1,,,,,,,,,,,,,,,*1E $}PGS,3,S,1,*74,

(there was no gps lock, underneath a metal roof) From what i can tell from this, the array i created is being written, but is incorporating multiple NMEA sentences inside of it. This is also corrupting the regular data output from the program it would appear.

So, My question, is there a nice little compact code for reading & storing a NMEA sentance from newsoftserial that allows me to easily manipulate (send to serial and SD) the values? im guessing this would probably be to a string array? I would/will post the newer version of the code, but i'm still working on recreating it fully after a power loss... Thanks for the help, and feel free to ask me any questions you have. ~Dan

The data is coming into the software serial port from the GPS. It is up to you to recognize when the end of a packet has been received. Typically, the packet ends with a CR or LF. You need to recognize that the character is a CR (or LF). If it is, you write out the accumulated string, and re-initialize the string.

Or, you could use the TinyGPS library, which manages the end of packet handling for you.

So, My question, is there a nice little compact code for reading & storing a NMEA sentance from newsoftserial that allows me to easily manipulate (send to serial and SD) the values? im guessing this would probably be to a string array?

I think I feel your pain. I've been searching for several days now for the code to take the input from a serial port and capture it into a useable string. Lots of suggestions and "snippits", but I have yet to find complete code to read the serial input buffer characters, save the characters in an array (which is what the native arduino processing apparently has to do), then return the contents of that array back as a string that can be parced for desired data. On the below page there is "void append(String thisString)" that may be of use in keeping the process simple. It works quite well in capturing the contents of a GET request if using an ethernet shield.

http://www.arduino.cc/en/Tutorial/TextString