You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
where the skimmed version of the function retrieveSDCardFilenames is:
voidretrieveSDCardFilenames(File folder, SDCardFiles &filesVector)
{
int fileCount = 0;
while (true)
{
File entry = folder.openNextFile();
if (!entry)
{
folder.rewindDirectory();
break;
}
else
{
fileCount++;
}
entry.close();
}
for (int i = 0; i < fileCount; i++)
{
File document = folder.openNextFile();
constchar *fn = (constchar *const)document.name();
DEBUG_PRINT(i + 1);
DEBUG_PRINT(". Fn >> ");
DEBUG_PRINTLN(fn);
// printing names here is OK!
filesVector.push_back((constchar *const)document.name());
sprintf(debugBuffer, "%d. %s\n", i+1, filesVector.at(i));
DEBUG_PRINTLN(debugBuffer);
// this printout is OK too!
document.close();
}
}
This is a section of the serial console with the result that I am getting. I can see the elements from the vector passed by reference inside of the functions, however, they are lost out of its scope, however, I am passing it by reference.
Please ignore the two lines that read:
Files created:
MIS1_003.txt
MIS2_006.txt
as these belong to another section of my code that DOES work fine using vectors from this library.
Any ideas?
The text was updated successfully, but these errors were encountered:
On a strange turn of events, I can confirm that my code fails ONLY on Arduino (ATMEGA2560). I have created a near-identical copy compatible with C++11 and the code works FLAWLESSLY.
I will describe in another comment my test setup to confirm that it only fails on the Arduino-based board.
To give you a brief preview, here is another screenshot of my serial console:
where the Vector filesCreated is exclusively used inside the main .cpp source file while the Vector filesInCard is passed by reference to a function. Inside it, the values are correctly retrieved and printed, HOWEVER, once the code goes back to the main source, the Vector is EMPTY.
Hi there
I am trying to implement an SDCard reader of the filenames inside of it by using
Vector
ofconst char*
as follows.When I pass the vector by reference, I can retrieve the total number of elements found, HOWEVER, the
const char*
elements with the filenames are lost.I have tried reassigning a storage array inside the function, passing pointers, returning another vector by copy, returning pointers, etc. No luck
where the skimmed version of the function
retrieveSDCardFilenames
is:This is a section of the serial console with the result that I am getting. I can see the elements from the vector passed by reference inside of the functions, however, they are lost out of its scope, however, I am passing it by reference.
Please ignore the two lines that read:
as these belong to another section of my code that DOES work fine using vectors from this library.
Any ideas?
The text was updated successfully, but these errors were encountered: