Copying all files from SD to USB
TCP71
Posts: 38
Hello,
I have an SD card and a USB datalogger attached to a propeller. I store backup files on the SD card (small files, each less than 400bytes) that are identified by their date and time. For example, I would have the following files inside the root directory of the SD:
06241108.401
06241108.403
06241108.405
They would be files written on june 24th, 2011 at 8:40:XX am. These files could span many days and times.
I would like to copy every file in the root directory of the SD to a usb stick in the datalogger.
Is there an efficient way to copy all the data from the SD card directly to the USB stick without identifying each file name, opening the file, copying the data to memory, closing the file on the SD, creating the file on the stick, opening the file on the stick, dumping the data from memory to the stick, closing the file on the stick. Seems horribly slow.
I am using DataloggerSPI and SD3.01_FATEngine to access the card/stick. I am not a programmer, so the more basic the explanation the better. Thank you for any and all ideas. This forum has been a wealth of knowledge in getting my project working.
I have an SD card and a USB datalogger attached to a propeller. I store backup files on the SD card (small files, each less than 400bytes) that are identified by their date and time. For example, I would have the following files inside the root directory of the SD:
06241108.401
06241108.403
06241108.405
They would be files written on june 24th, 2011 at 8:40:XX am. These files could span many days and times.
I would like to copy every file in the root directory of the SD to a usb stick in the datalogger.
Is there an efficient way to copy all the data from the SD card directly to the USB stick without identifying each file name, opening the file, copying the data to memory, closing the file on the SD, creating the file on the stick, opening the file on the stick, dumping the data from memory to the stick, closing the file on the stick. Seems horribly slow.
I am using DataloggerSPI and SD3.01_FATEngine to access the card/stick. I am not a programmer, so the more basic the explanation the better. Thank you for any and all ideas. This forum has been a wealth of knowledge in getting my project working.
Comments
1: I don't know what exactly the filenames are ahead of time. Should I search for every possible permutation of numbers that make up the 8:3 filenames and whenever one is recognized, pull the data out of it, or is there some way to scroll through each file sequentially on the SD card and move onto the next once I've got the data without pulling data twice? If I had no concerns about the time it took to transfer all the data to the stick would the find/open/copy/close on SD, then create/open/write/close on stick for each file be a poor method?
2: My SD card is 2Gig. Each file is less than 1k in size, but takes up 32K on the disk. Not a problem as the storage of 62500 files are possible with each at 32k. If i were to have 62500 files and each one is 400bytes, there is the theoretical possibility of having 25Meg of actual file data...too big for storage in memory. I would have to create multiple file of a smaller size, I suppose.
3: Is there any way to look at the data on the card without dealing with a file structure? Just transfering all bytes within the used section of the SD card directly to the stick without change or actually looking at the data?
Here's the data within one file (named 06241116.340):
Any thoughts appreciated.
You need some indentifier in the big file to sparate the single data portions, or perhaps you can use just a fixed datablock size.
Andy
http://forums.parallax.com/showthread.php?131598-New-AppNote-Posted-FAT16-FAT32-Full-File-System-Driver
Set aside some RAM, say a 2K buffer. Get total file size: Read 2k from the source -> 2K Buffer -> Append 2k to the destination file -> Decrement total bytes to read by 2k -> repeat
Sure, similar to the above process.
I'm not sure whether thats still an issue or not, just putting it out there in case you see issues