Yes, that is correct. I opened the file and copied the spaces and then just kept pasting them back in untill I felt the file was larg enough.
Sorry to hear about your GPS module, that sucks when things break. For testing I ended up ditching my analog input (while developing because it was easier to not have it attached) device and just read the static value of the pin. The pin is floating so it gives me small differences in results without the need to have my device attached. In your case you are actually reading the serial data (I hope thats correct) coming from your GPS module. While you are in downtime due to the GPS module I would suggest building a function that would return a mockup sample of what you would get from the GPS module so that you can keep working on the SD card code. If your not sure how to go about doing that, make up a sample output and reply to this thread and I'll try to throw together a simple function to help you out there.
Also, One thing I've noticed is that the SD card takes a while to write to. This is the reason I ended up creating a buffer to load my data in before writing to the card. This minimizes the number of times you have to write to the SD card. If the length between GPS readings is long enough than its probably not a problem and you can just write to the SD card at each reading.
Here is my code in my library that I keep talking about. This may not work (or be the best option) for you but I'm just posting it to give you an idea of what I'm talking about.
void ThrustSample::saveSample(){
for(int i=0; i<FRAM_BUFFER_SIZE; i+=2){
int _framBlockValue = i2c_fram_read_int(i);
if(_framBlockValue > 0){
if(i == 0){
_sdBuffer[0] = 'T';
_sdBuffer[1] = secondDigitAscii(_runId);
_sdBuffer[2] = thirdDigitAscii(_runId);
_sdBuffer[3] = fourthDigitAscii(_runId);
_sdBuffer[4] = ',';
_sdBufferPos = 4;
}
else{
if((_sdBufferPos + 5) < 512){
int n = _sdBufferPos;
_sdBuffer[n+1] = firstDigitAscii(_framBlockValue);
_sdBuffer[n+2] = secondDigitAscii(_framBlockValue);
_sdBuffer[n+3] = thirdDigitAscii(_framBlockValue);
_sdBuffer[n+4] = fourthDigitAscii(_framBlockValue);
_sdBuffer[n+5] = ',';
_sdBufferPos = n+5;
}
else{
_sdBuffer[_sdBufferPos+1] = '\0';
SD.print(SAMPLES_FILE, _sdBuffer);
_sdBufferPos = -1;
delay(5);
}
}
}
else{
_sdBuffer[_sdBufferPos+1] = '\0';
SD.print(SAMPLES_FILE, _sdBuffer);
_sdBufferPos = 0;
break;
}
}
_runId ++;
clearBuffer();
}
Here is basically what it is doing...
- Create a loop the size of the memory where the readings were buffered.
- Read the value of the current position in memory
- if it's the first position create the run Id and add it to the buffer.
- if it's not the first position the take the integer value from the current position in memory and convert each digit of the number into a char, add a comma and store that into the buffer
- when the buffer gets full send that buffer to be written to the SD card
- As long as there is still values to be read from memory keep filling up the buffer.
- when there are no more values to read in memory write what remains in the buffer to the SD card
- increment my run id
- clear the buffer memory.