Show Posts
Pages: 1 2 [3] 4 5 ... 26
31  Using Arduino / Programming Questions / Re: Read filename from SD card, store to a string on: November 06, 2012, 03:30:41 pm
 smiley-confuse

Not enough sleep at my end I think.

Everything I have tried I have posted. All I am trying to do is find the function or the method to read the file name using the sdfat library.

I have just searched the sdfat library and cant find a function called available()

Quote
while(file.available() > 0)

Where is this from?
32  Using Arduino / Programming Questions / Re: Read filename from SD card, store to a string on: November 06, 2012, 03:13:46 pm
Why do you want to see my MP3 player code, when its not related to the question I am asking.
I could have a new project with no code, and I want to read the file name using the SDFAT library, and there would be no code to post.

The only thing relating to opening a file is the part I posted above, which is directly out of the example from the SDFAT library, I have gotten no where further than that.
33  Using Arduino / Programming Questions / Re: Read filename from SD card, store to a string on: November 06, 2012, 03:05:10 pm
Quote
Nor, it seems, can you figure out how to post your code.

Um... my code has absolutely nothing to do with this Paul.
If I wanted to post my code I would have done so, but it has absolutely no relevance to this question.

Thanks for the snippet you posted, ill digest it and see if its what I need.

Regards

34  Using Arduino / Programming Questions / Re: Read filename from SD card, store to a string on: November 06, 2012, 05:44:38 am
Essentially I want this:

Code:
//------------------------------------------------------------------------------
/** Print a file's name
 *
 * \param[in] pr Print stream for output.
 *
 * \return The value one, true, is returned for success and
 * the value zero, false, is returned for failure.
 */
bool SdBaseFile::printName(Print* pr) {
  char name[13];
  if (!getFilename(name)) {
    DBG_FAIL_MACRO;
    goto fail;
  }
  return pr->print(name) > 0;

 fail:
  return false;
}

But I dont want to print it to the serial port...

 smiley-confuse

Really showing the gaps in my knowledge here.
35  Using Arduino / Programming Questions / Re: Read filename from SD card, store to a string on: November 06, 2012, 05:24:26 am
Currently I do this

Code:
// open next file in root.  The volume working directory, vwd, is root
  while (sdCardFile.openNext(sdCard.vwd(), O_READ))
{
  MaxFiles++;
   
  sdCardFile.close();
}

which is mostly extracted from one of the examples.
So it just increments through all the files in root, and adds 1 to the count. I then get the total file count out at the end.

Its this I want to extend on, so not only get the file count, but get a list of ints, of all the files present in root.

Cheers
36  Using Arduino / Programming Questions / Re: Read filename from SD card, store to a string on: November 06, 2012, 05:20:33 am
I found this:

Code:
//------------------------------------------------------------------------------
/** Get a file's name
 *
 * \param[out] name An array of 13 characters for the file's name.
 *
 * \return The value one, true, is returned for success and
 * the value zero, false, is returned for failure.
 */
bool SdBaseFile::getFilename(char* name) {
  dir_t* p;
  if (!isOpen()) {
    DBG_FAIL_MACRO;
    goto fail;
  }
  if (isRoot()) {
    name[0] = '/';
    name[1] = '\0';
    return true;
  }
  // cache entry
  p = cacheDirEntry(SdVolume::CACHE_FOR_READ);
  if (!p) {
    DBG_FAIL_MACRO;
    goto fail;
  }
  // format name
  dirName(*p, name);
  return true;

 fail:
  return false;
}

However this is big boys code, and I cant understand what it means exactly, where the name of the file actually goes...

Quote
* \param[out] name An array of 13 characters for the file's name.

what is this param[out] exactly?

or is that wrong...

Is it if I start at the begining of the directory, and call that function, it will tell me yes/no if the file exists...

ie
boolean SongPresent = getFilename("0001.mp3");

?

I could possibly make that work, but ideally I want to start at the beginning of the root directory, and scan through all the files on the card, returning the name of the file, ideally just the name, saving it into an int array.

hmm. The search continues.

*EDIT* Actually, this would be better for that example

Quote
//------------------------------------------------------------------------------
/** Test for the existence of a file in a directory
 *
 * \param[in] name Name of the file to be tested for.
 *
 * The calling instance must be an open directory file.
 *
 * dirFile.exists("TOFIND.TXT") searches for "TOFIND.TXT" in  the directory
 * dirFile.
 *
 * \return true if the file exists else false.
 */
bool SdBaseFile::exists(const char* name) {
  SdBaseFile file;
  return file.open(this, name, O_READ);

Not really sure what the one above is for.
37  Using Arduino / Programming Questions / Read filename from SD card, store to a string on: November 06, 2012, 04:52:14 am
Hello,

Been scratching my head for a little while, I cant seem to figure out how to read a file name of a file I have on SD card, and save the file name (not its contents, just the file name itself) to a string.
What I am trying to do is build an array of file names. I am using the SDFAT library.

Better yet, the files are actually numbers, ranging from 0001.mp3 to 9999.mp3

Can someone point me in the right direction for reading the file name, say 0001.mp3, and saving this an int variable. So it will be 1 to 9999.

Thanks in advance.
38  Using Arduino / Microcontrollers / Re: atMega1284P-AU @ 20Mhz on: October 25, 2012, 02:34:40 pm
Code stops executing.
Im writing to the serial port, and now and then it just stops dead in its tracks, LED stops blinking (that I have to indicate it being alive) and it just grinds to a halt.

Sadly I cant use UART1 as I have my 4 layer PCB already printed smiley-sad

Found an Optiboot version 4.5 using UART0 @ 16Mhz which seems to be working so far, for the few minutes of testing I have done.
Ideally would like a 20Mhz version working though, but such is life.

Thanks
J
39  Using Arduino / Microcontrollers / Re: atMega1284P-AU @ 20Mhz on: October 25, 2012, 07:20:00 am
Processor seems to be locking up constantly, not sure what is going on.

Changed to 16Mhz version of "Mighty 1284p 16MHz using Optiboot", but I cant get that to let me upload over the uART0.
Not sure if this is setup for UART0 or UART1.

Programming over ICSP at the moment, and it seems stable.
Not sure whats going on at 20 Mhz

Which is the prefered 16Mhz 1284P bootloader for UART0 ?

Thanks
J
40  Using Arduino / Microcontrollers / Re: atMega1284P-AU @ 20Mhz on: October 25, 2012, 05:13:39 am
Reloaded bootloader, took another 5 minutes or so (is this normal?) and now I can program over serial, strange. But Yay smiley
41  Using Arduino / Microcontrollers / Re: atMega1284P-AU @ 20Mhz on: October 25, 2012, 04:19:59 am
No luck with serial programming yet.

Constantly get

avrdude: stk500_getsync(): not in sync: resp=0x00
42  Using Arduino / Microcontrollers / Re: atMega1284P-AU @ 20Mhz on: October 25, 2012, 03:34:38 am
Burnt the bootloader, but got this error:

avrdude: verification error, first mismatch at byte 0x10000
         0xff != 0x04
avrdude: verification error; content mismatch

I have had it before, so I tried the blink sketch modified to D10 for my board, and it seems to work.
Was running off internal oscillator /8 at initial power up, so the blink was incredibly slow, but after the bootloader it is 1s on 1s off, so that appears to have worked.

Using Sparkfun AVR Pocket Programmer for ICSP programming, USBtinyISP selection in the IDE.

Bootloader took a good few minutes to burn... seemed longer than usual. 1Mhz internal clock probably didnt help...

Cheers
J
43  Using Arduino / Programming Questions / Re: SPI Between 'Arduinos' on: October 24, 2012, 05:46:54 pm
PM me your email, ill flick you my files
44  Using Arduino / Programming Questions / Re: SPI Between 'Arduinos' on: October 24, 2012, 05:34:59 pm
Code on the last page should work, from memory

Ill do some digging on my hard drive and find the code I got working on both ends
45  Using Arduino / Programming Questions / Re: SPI Between 'Arduinos' on: October 24, 2012, 04:00:20 pm
Sure did

Whats up?
Pages: 1 2 [3] 4 5 ... 26