SD Card access on different COG's
trancefreak
Posts: 186
Hi,
I've a question with regards to accessing files on a SD Card with simpletools.h.
Is it possible, that two cogs are accessing two separate files at the same time using the sd driver of simpletools?
Or do I have to use two different SD Cards to achieve that?
To be more precise:
I need one cog to access file A on the SD card while another cog accesses file B on the same SD card.
Is that possible?
Thx,
Christian
I've a question with regards to accessing files on a SD Card with simpletools.h.
Is it possible, that two cogs are accessing two separate files at the same time using the sd driver of simpletools?
Or do I have to use two different SD Cards to achieve that?
To be more precise:
I need one cog to access file A on the SD card while another cog accesses file B on the same SD card.
Is that possible?
Thx,
Christian
Comments
Thanks very much for your reply and clarification!!
Thx,
Christian
Yes, that was what I wanted to know.
I'm planning an implementation where two cogs are reading from one sd card. I need to play wav files. One file is background music and one is fx (speech, fx, ...).
So my idea was to have two cogs which read the audio content from sd card. So is this possible or do I have to use two sd cards to achieve this?
Regards,
Christian
I gave the most appropriate answer I could think of.
Here's an answer from Andy whose thoughts I asked for outside of this thread:
...multiple files work. Starting with examples in SimpleIDE\Learn\Examples\Devices\Memory, only use one sd_mount call, and then multiple FILE *pointer = fopen statements with different pointer names. Then, use fwrite and fread and just make sure to use the right pointer. (Avoid fprintf and fscanf, they are memory hogs!)
Here's an example with a not recommended lack of tests. (The same can be done to the "with Tests" example, which tests to make sure the file successfully opened and all that.)
Thanks for your answers. Yes, I will do the sd access with one cog and the others will just get the file data from the "sd cog".
Question is, how the mechanism could look like to tell the "sd cog" to deliver some data. The cogs can only communicate through a mailbox. Is someone used to such a design, how to tell
another cog to deliver data from a file into buffer?
Maybe the mailbox itself has two buffers, which are filled by the "sd cog" and the buffers are filled by using flags to tell the "sd cog" to do it and another flag which is set to true, if the buffer is
filled.
Or is there a cleaner, nicer way to do this?
Christian