Serial Buffer Getting Odd Characters

I am trying to receive a text file via serial, and store it to the SD card. The data coming in is buffered every 64B and then when I write it to the file, it looks like I must have some sort of overflow going on. I am getting repeating characters every time I got from 64 back to 0.

Attached is my code, the area of concern is in the BufferSerialData function.

http://pastebin.com/NgrPhuaf

Here are the characters that are getting inserted at the gap (obvisouly from SOMETHING in SRAM).

Date: 11-04-2014 Time: 8:45am Initials: MJK Level: Hard Sco¶ L£ re: 4.54 Cardio Score: 4.24 (71 balls hit out of 84) STROKE SC¶ L£ ORE PER MPH DEPTH WIDTH Forehd 4.2 75 62 ¶ L£ 24 10 Backhd 4.2 83 58 24 ¶ L£ 10 ForeVO 4.2 82 50 24 10 ¶ L£ BackVO 4.2 78 45 24 10 Overhd ¶ L£ 4.2 92 85 24 10 Serve ¶ L£ 4.2 91 89 24 10

The goal here is to have a While strtok_r loop that will replace '\n' with " " for html display.

I have that working as well but with the non-serial characters the data looks even worse.

Right now I am just adding the " " at the end of every buffer.

Sorry, this is on an Uno, I am contemplating moving to a Mega for the extra SRAM...

I must of been spacing out, I was having an issue reading until '@' (eof) and must of been picking up garbage on the USB or some other anomoly. Reading until '\n' seems to be working fine and the output is HTML correct.

Date: 11-04-2014 Time: 8:45am Initials: MJK Level: Hard Score: 4.54 Cardio Score: 4.24 (71 balls hit out of 84) STROKE SCORE PER MPH DEPTH WIDTH Forehd 4.2 75 62 24 10 Backhd 4.2 83 58 24 10 ForeVO 4.2 82 50 24 10 BackVO 4.2 78 45 24 10 Overhd 4.2 92 85 24 10 Serve 4.2 91 89 24 10

I guess we can close this one.

Well,

I should of guessed it; but the only thing the ‘\n’ fixed was that every section that I buffered was < 64B.

Once I go over 64B my buffer begins to pick up characters from SRAM.

Has anyone successfully buffered large pieces of serial data?