VS1053: delete & MOVE files to mSD card via USB from COMPUTE

For other supported Arduino products from Adafruit: Shields, accessories, etc.

Moderators: adafruit_support_bill, adafruit

Please be positive and constructive with your questions and comments.
DanPolka
 
Posts: 108
Joined: Tue Feb 18, 2014 5:31 am

VS1053: delete & MOVE files to mSD card via USB from COMPUTE

Post by DanPolka »

For the VS1053, is it possible via the UNO USB connector to delete specific mp3 files from the microSD card and then add new ones by moving them from the computer, such as track001, track002, etc, and then have the mp3 player program function to correctly play them in the desired numerically sequential order?

I'm just now starting to connect the VS1053 to a UNO to experiment with it, and the reason I ask is that my current intended design (mounting the combined assemblage of shields & breakouts semi-permanently to a location) won't allow for easy removal of microSD card in order to perform delete and add by connecting the card itself to a computer.

Even if I can delete/add via USB, I thought I'd read somewhere that the library can't correctly handle deletes & subsequent adds? May have to re-format & re-record??
Last edited by DanPolka on Sun Mar 23, 2014 3:14 pm, edited 1 time in total.

User avatar
adafruit_support_rick
 
Posts: 35092
Joined: Tue Mar 15, 2011 11:42 am

Re: VS1053: delete & add files to mSD card via USB from UNO?

Post by adafruit_support_rick »

Sure, it's possible. You'll have to write a file manager sketch that can take commands and data over the serial link..
DanPolka wrote:Even if I can delete/add via USB, I thought I'd read somewhere that the library can't correctly handle deletes & subsequent adds? May have to re-format & re-record??
What I think you read is that the VS1053 can't switch from recording to playback without a reset. It has nothing to do with simply adding or deleting files on the SD card.

DanPolka
 
Posts: 108
Joined: Tue Feb 18, 2014 5:31 am

Re: VS1053: delete & add files to mSD card via USB from UNO?

Post by DanPolka »

Ok, thanks! Now, where might I begin to look to figure out how to write a file manager sketch for the serial link? Is there any example of a serial link file manager sketch for VS1053 microSD card?

User avatar
adafruit_support_rick
 
Posts: 35092
Joined: Tue Mar 15, 2011 11:42 am

Re: VS1053: delete & add files to mSD card via USB from UNO?

Post by adafruit_support_rick »

I don't know of any examples of this. However, I did a little search over at the Arduino Playground, and came up with this blog post. It's not exactly what you want, but it's close:
http://www.scenelight.nl/2011/08/29/off ... or-part-2/

DanPolka
 
Posts: 108
Joined: Tue Feb 18, 2014 5:31 am

Re: VS1053: delete & add files to mSD card via USB from UNO?

Post by DanPolka »

Thanks, that does have a little of what I need to see, and I found a little more that's closer here:

Arduino Tutorial #4: Serial Communication
http://www.youtube.com/watch?v=KYWCkdrCUKg
though it's nearly impossible to read! :(

And this one, which is variably easier to read, but also not too close to what I need, but in the right direction:
Matlab Serial Port Communication
http://www.youtube.com/watch?v=vepXrSXtqL0

I'll have to look at them all more closely and think about them, as I don't program too well.

User avatar
adafruit_support_rick
 
Posts: 35092
Joined: Tue Mar 15, 2011 11:42 am

Re: VS1053: delete & add files to mSD card via USB from UNO?

Post by adafruit_support_rick »

Good luck!

DanPolka
 
Posts: 108
Joined: Tue Feb 18, 2014 5:31 am

Re: VS1053: delete & add files to mSD card via USB from UNO?

Post by DanPolka »

Ok, it looks, reasonably enough, that it's a two step process:

1. send a command to Uno via serial link, like, delete all files which begin with "track";
2. have a section of code in running sketch which automatically responds to a simple serial command ("delete all track.*** files"), and implement commands from SD library to do it; ditto for move or write files. As in:
http://arduino.cc/en/Tutorial/Files

Gee, sounds easy when I put it like that! :lol:
(I know it won't be!)

User avatar
adafruit_support_rick
 
Posts: 35092
Joined: Tue Mar 15, 2011 11:42 am

Re: VS1053: delete & add files to mSD card via USB from UNO?

Post by adafruit_support_rick »

There things always sound so easy, don't they... :wink:

DanPolka
 
Posts: 108
Joined: Tue Feb 18, 2014 5:31 am

Re: VS1053: delete & add files to mSD card via USB from UNO?

Post by DanPolka »

However, and this is important, I don't yet see any way to specify and accomplish moving a file or files from the computer via the USB serial connection to the Uno or SD card.

How can I do that??

User avatar
adafruit_support_rick
 
Posts: 35092
Joined: Tue Mar 15, 2011 11:42 am

Re: VS1053: delete & MOVE files to mSD card via USB from COM

Post by adafruit_support_rick »

Serial.read and SD.write. You'll have to extend the PC<->Arduino comm protocol to handle data transfers. Transfer a block of 256 bytes of file data at a time. Precede each block with a header which includes the size of the block. Add a simple checksum at the end of each block.

DanPolka
 
Posts: 108
Joined: Tue Feb 18, 2014 5:31 am

Re: VS1053: delete & MOVE files to mSD card via USB from COM

Post by DanPolka »

Yeah, but I still don't understand how do I get the data files from the computer to/through the serial USB port. How do I
extend the PC<->Arduino comm protocol to handle data transfers
??

User avatar
adafruit_support_rick
 
Posts: 35092
Joined: Tue Mar 15, 2011 11:42 am

Re: VS1053: delete & MOVE files to mSD card via USB from COM

Post by adafruit_support_rick »

You'll need to write a program on the PC side.

DanPolka
 
Posts: 108
Joined: Tue Feb 18, 2014 5:31 am

Re: VS1053: delete & MOVE files to mSD card via USB from COM

Post by DanPolka »

Errg, I was afraid of that! :( Fortunately, I may be able to do that. I saw you say that I'd have to "Transfer a block of 256 bytes of file data at a time. Precede each block with a header which includes the size of the block. Add a simple checksum at the end of each block."

I'll try to make a program that'll do that, but is there any protocol or definition of what the header must look like, and how to make a checksum? And what would I do at the end of a file, where the size of what's left wouldn't be 256 bytes?? And very important, these would be .mp3 files, would that present any problem in reading the .mp3 data by "my" (!) program, and in reconstituting it by an Uno sketch??

And is there any example or info somewhere as to how the sketch should accept and handle the transfers?? I anticipate that it'll be a lot of files, at least a hundred at a time, I think.

User avatar
adafruit_support_rick
 
Posts: 35092
Joined: Tue Mar 15, 2011 11:42 am

Re: VS1053: delete & MOVE files to mSD card via USB from COM

Post by adafruit_support_rick »

mp3's are just binary files you don't need to know anything about what they actually contain. It's just a bunch of numbers.

As for protocol, header format, etc., it's whatever you make up. You're writing this from scratch on both sides.

On the PC side, I'll usually use Visual Basic when I want to hack up something like this quickly. The Express edition of Visual Studio is free for the download.

The block header tells how many bytes are in each block, so when you get the last one and it's short, you'll know that.

On the arduino side, it's really just a loop - first read the header to get the number of bytes to read, then loop to do the serial read, then read and check the checksum, then do an SD.write. You can send a header for a 0 length block to signify end of file. When you get that, close the SD file, and you're done.

DanPolka
 
Posts: 108
Joined: Tue Feb 18, 2014 5:31 am

Re: VS1053: delete & MOVE files to mSD card via USB from COM

Post by DanPolka »

I fear 'quickly' is not in my vocabulary, but you've answered most of my questions, so thank you.

Does 'checksum' mean something like how many total ones or zeros were in a particular block of data? Such that I'd have to look at each byte sent and received to see how many of either ones or zeros contributed to a total??

Locked
Please be positive and constructive with your questions and comments.

Return to “Other Arduino products from Adafruit”