Go Down

Topic: SD Card Directory Listing Fails within Large Application (Read 3095 times) previous topic - next topic

fat16lib

Quote
Which means (I think) that there may still be a bug in the SD library related to where the root directory file object is created.


Not likely.  You just are avoiding the real problem by getting a fresh copy of the root file object.  when you open root, SD.h just gives you a copy of its internal root object. 

CatweazleNZ


Quote
Which means (I think) that there may still be a bug in the SD library related to where the root directory file object is created.

Not likely.  You just are avoiding the real problem by getting a fresh copy of the root file object.  when you open root, SD.h just gives you a copy of its internal root object. 

I will try to do some more testing on the weekend.

At this stage I seem to have posted SD directory reading code that works and code that does not work within my application when everything else remains unchanged. I accept that the logic of my code suggests both types of code should generate the same result - but they do not but I guess my code cannot be corrupting an SD root directory file object if it is not permanently instantiated while the application is off doing other things. Perhaps my application in those circumstances is corrupting other things that I have not yet discovered.

Anyway - until the weekend.

Catweazle NZ

CatweazleNZ

Well I finally got to the bottom of my problem thanks to a few suggestions from fat16lib that forced me into thinking about how to retest my application.

Despite all the suspicion that I was corrupting RAM with an array index overflow my detailed analysis of an obvious candidate procedure within my application found nothing. The issue was actually more obvious and did not need much looking for at all.

My problem is that I am using both ethernet and SD as shared SPI devices. Since I use ethernet for a web site, emails and daily UPD NTP time resets I made ethernet the default active SPI device. That means that SD card operations will fail or be problematic if you do not select the SD card for SPI when needed. It also means that if I don't remember to reselect ethernet for SPI when I am done with an SD card operation then there will be trouble there too. And if you are reading an SD card file line-by-line and writing it to a web page line-by-line (which I do) then your code has to continually switch the SPI devices.

So I rechecked all my SPI device selections and found the problem - everything worked OK.

So over this weekend I have reorganised my use of the SD card and reimplemented multi-level directory browsing with alphabetically sorted files (and file display) on my system's web pages. This also lead to some glitches when I did not get the SPI device (pin) selection correct - but it is all sorted now and all my system's log files are now being written into the required SD card subdirectories and I can browse the card and display any of the files via the system's web site.

Thanks again to those who helped get my mindset pointing in the right direction.

Happy chappy here - now on to the next task.

Catweazle NZ

airinmotion

I think I just encountered this problem. Or at least I think my problem is similar to the one described here.
I use an Arduino Mega. All the SD functions fail and hang-up when my program reaches about 83K in size.  After searching the Internet on this problem, I came across this thread on this forum. After browsing over the postings, I check my functions over and over again, I check my array indices again and did not find anything wrong.

Anyway, I just took Mr. fat16lib's advice and check the array indices again. I may have missed something, so to be safe I increased the all the arrays indices by 1 or more elements and all the SD functions start to works again. I think my problem is due the Array memory overflow. I have yet to figure out which array is causing the problem, but for now, I am just happy the problem is fixed.
airinmotion

Go Up