-Starting with an SD card with several 5,000 KB files on it (lets call this the Master Card)
-Want to copy Master Card files to either a PC or a separate SD card
-These files are encrypted (.CAN)
-Ultimately, the project hardware is going to live in a black box, with the ability to plug the Master Card in one slot, and have either a USB cable that runs to a computer or a second SD card slot to receive the data
-The reason I want to use the Arduino to copy the Master Card rather than just plugging it into a computer is that I don't want the end user to have the ability to delete Master Card files.
-End goal is to hit a button on the black box and have the Arduino copy the Master Card to another memory source
-I have an Arduino Uno and an Adafruit Datalogging shield at the moment. Willing to try other hardware if need be
Current Status:
-Can access Master Card and view file names and sizes (via Arduino SD Card Example "CardInfo")
-Attempted to use Arduino SD Card Example "DumpFile" to transfer to PC. I had three problems with this.
-> Problem 1: I may misunderstand how this sketch functions, but it appears to only print files in the serial monitor (if its actually saving them to the PC I have no idea where)
-> Problem 2: Transferring the 5000 KB files this way is incredibly slow
-> Problem 3: As the files are encrypted, the serial monitor only displays symbols. I have no idea if they're copying right as I can't see where the data is going (see Problem 1)
Questions:
-Is what I'm trying to do feasible?
-Is "DumpFile" saving files to my PC? If not, is there a way to make it?
-Can I transfer from the Master Card to another SD card using the prototyping section of the datalogging shield and another SD card reader? Or even to another Arduino with a separate shield if it cant be done on the same Arduino (not enough ports)?
-Is there a way to send these files faster through serial? Or should I send them a different way?
If your files are encrypted, then they were written as individual bytes, not "records" of a fixed length. Therefore, your copy is also reading one individual byte at a time and sending it. Nothing could be slower.
If you are able to do some programming, you can read and write 512 records until you get to the last record, which will likely be less than 512 bytes, so you need to expect that and handle it as an exception.
You can also double buffer the reading by alternating between two 512 byte buffers and send one while waiting for the other to be read and filled.
There is no magic library that will do all this for you.
And if sending bytes serially to a PC, that buffer will be much smaller, but you can expand that to 512, also.
-Is what I'm trying to do feasible?
-Is "DumpFile" saving files to my PC? If not, is there a way to make it?
-Can I transfer from the Master Card to another SD card using the prototyping section of the datalogging shield and another SD card reader? Or even to another Arduino with a separate shield if it cant be done on the same Arduino (not enough ports)?
-Is there a way to send these files faster through serial? Or should I send them a different way?
Ok. From these answers I've resolved the speed issue and the DumpFile issue. The last problem remaining is dealing with the encrypted file. My current method works if I'm copying a text file, but not with the encrypted .CAN files. Is there a way to copy a file over as is like you would with a computer?
sodaface:
Ok. From these answers I've resolved the speed issue and the DumpFile issue. The last problem remaining is dealing with the encrypted file. My current method works if I'm copying a text file, but not with the encrypted .CAN files. Is there a way to copy a file over as is like you would with a computer?
How can we tell what your current method is? You need to help us help you!
Paul
I'm using the SD card library example "DumpFile", but modified to read and write 512 bytes at a time (to increase the speed). As suggested, I'm using Putty to save this as a new file on the PC receiving the data. This works perfectly for text files. However, this does not work for the encrypted .CAN files I'm working with. They'll transfer to the other card, but be corrupted when they get there.
I'm guessing this is happening as the Arduino is attempting to open the file and parse it. It's struggling as the file is encrypted, and it cant truly open it to copy it this way.
Is there a workaround for this? As I can copy these files fine on my computer, I'm confused on how the Arduino cannot copy them as well. I'm sure I'm missing something here.
I expect that puTTy has a problem with your encrypted files. The reader should not care about the content but since the encrypted files likely contain control characters, if you are trying to receive text they may cause confusion. Can you tell puTTy it's getting a binary file?
I'm confused on how the Arduino cannot copy them as well.
The Arduino does not "copy" the file in the sense that the copy program on a PC works.
The process you are attempting involves independent programs running on the Arduino and on the PC, and the PC program is not handling the incoming data in the way you wish it would.
PuTTy is just a character based terminal. It has no provisions for receiving a binary file. Other program do allow this. I use the freeware program TeraTerm as a terminal emulator. It also supports binary file transfer such as KERMIT, XMODEM, YMODEM, etc. which are very old protocols for dealing with binary data. If you go down this route, you would have to implement the protocol on your adruino before sending it.
An easier method may be to encode it to base64 on the arduino side and then have the PC decode it back to binary.
Either way, it is going to take some work since it is not a "PC copy" operation.