Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Dependents: ELEC350_Project2 SDcard
Revision 16:23b3be671415, committed 2019-01-03
- Comitter:
- Swabey89
- Date:
- Thu Jan 03 10:32:41 2019 +0000
- Parent:
- 15:e1f62dd17e3c
- Child:
- 17:c9ac3fc764b9
- Commit message:
- Updates
Changed in this revision
| SDCard.cpp | Show annotated file Show diff for this revision Revisions of this file |
--- a/SDCard.cpp Wed Jan 02 19:45:11 2019 +0000
+++ b/SDCard.cpp Thu Jan 03 10:32:41 2019 +0000
@@ -48,7 +48,7 @@
pc->printf("WARNING: COULD NOT OPEN FILE FOR WRITE\n\r");
printlock.unlock();
*/
- printQueue.call(printf,"WARNING: COULD NOT OPEN FILE FOR WRITE\n\r");
+ printQueue.call(printf,"WARNING: COULD NOT OPEN FILE FOR WRITE\r\n\n");
//lcd.cls();
//lcd.printf("CANNOT OPEN FILE\n\n");
//errorCode(FATAL);
@@ -60,7 +60,7 @@
pc->printf("FILE OPEN FOR WRITING\n\n\n\r");
printlock.unlock();
*/
- printQueue.call(printf,"FILE OPEN FOR WRITING\n\n\n\r");
+ printQueue.call(printf,"FILE OPEN FOR WRITING\r\n\n");
sd_init = true;
}
fclose(fp);
@@ -131,7 +131,7 @@
strftime(fileDate, 30, "sd/log_%d_%m_%y.csv", timeData);
timeLock.unlock();
- fp = fopen(fileDate,"a"); //issue if file already open?
+ fp = fopen(fileDate,"a");
if (fp == NULL)
{
@@ -144,6 +144,7 @@
printQueue.call(printf,"WARNING: FILE COULD NOT BE OPENED\r\n\n");
sd_init = false;
samplesInBuffer.release();
+ oldestIndex = (oldestIndex?oldestIndex:BUFFERSIZE)-1; //Doesn't work properly - oldestindex will be increased by the conditional statement in the producer
}
else
{
@@ -151,7 +152,7 @@
fclose(fp);
}
- if(logging)
+ if(logging && sd_init)
{
/*
printlock.lock();
@@ -160,11 +161,15 @@
pc->printf("oldestIndex position %d\r\n\n",oldestIndex);
printlock.unlock();
*/
- //printQueue.call(printf,"Log file %s updated with sample from position %d in buffer\r\nnewestIndex position %d\r\noldestIndex position %d\r\n\n", fileDate, buffind, newestIndex, oldestIndex);
- printQueue.call(printf,"Log file updated with sample from position %d in buffer\r\nnewestIndex position %d\r\noldestIndex position %d\r\n\n", buffind, newestIndex, oldestIndex);
+ printQueue.call(printf,"Log file %s updated with sample from position %d in buffer\r\nnewestIndex position %d\r\noldestIndex position %d\r\n\n", fileDate, buffind, newestIndex, oldestIndex);
+ //printQueue.call(printf,"Log file updated with sample from position %d in buffer\r\nnewestIndex position %d\r\noldestIndex position %d\r\n\n", buffind, newestIndex, oldestIndex);
}
}
- else samplesInBuffer.release();
+ else
+ {
+ samplesInBuffer.release();
+ oldestIndex = (oldestIndex?oldestIndex:BUFFERSIZE)-1; //Doesn't work properly - oldestindex will be increased by the conditional statement in the producer
+ }
}
/*
