View previous topic :: View next topic |
Author |
Message |
stoyanoff
Joined: 20 Jul 2011 Posts: 375
|
I can`t create folder with mdd stack |
Posted: Sun Jun 23, 2013 1:16 am |
|
|
Greatings! I`m using mplab 8.91 and ccs stack v4.134, mdd stack 2012-06-22. I can create files and add data to them, but when I try to create folder the FSmkdir(dir) returns 0 (as it has to be ex_fat)
Code: |
if(FSmkdir(dir))
{
printf("Error creating directory");
return;
}
printf("OK");
|
But after that I don`t have folder in the card. I tried several definitions for dir:
Code: |
char dir[]="Folder";
char dir[7]="Folder";
|
As I said I can create files and add data to them!
If I use FSmkdir("Folder") it`s OK!
What am I doing wrong? What error I`m doing with the dir variable?
Thanks! |
|
|
Ttelmah
Joined: 11 Mar 2010 Posts: 19539
|
|
Posted: Sun Jun 23, 2013 1:50 am |
|
|
Have you done a Chdir first?.
If not, then your path should (must?) have a leading '\' to say 'put this in the root directory'. Otherwise it is created 'relative' to where Chdir selected, and unless you have used Chdir, it can go awry....
So try:
Code: |
char dir[]="\Folder\";
|
I've had 'oddities' with this function in the past....
Best Wishes |
|
|
FvM
Joined: 27 Aug 2008 Posts: 2337 Location: Germany
|
|
Posted: Sun Jun 23, 2013 2:39 am |
|
|
After calling FSInit(), the root directory is the current directory. In so far, FSmkdir("Folder") will work.
If the current directory is unknown and you want to create a folder in the root directory, a leading
backslash is required.
The MDD directory related functions don't expect a trailing backslash.
What is "mdd stack 2012-06-22", MDD V1.40? |
|
|
stoyanoff
Joined: 20 Jul 2011 Posts: 375
|
|
Posted: Sun Jun 23, 2013 2:59 am |
|
|
I fixed it! It seems I have to use a pointer to the char array when I`m using
FSmkdir in a function:
Code: |
void FunctionName(char *dir)
{
....
}
|
Can I ask one more thing? Why I can`t use pic kit 3 debugger with this mmd stack? It always stops and returns pic kit 3 has halted with errors?
Thanks! |
|
|
FvM
Joined: 27 Aug 2008 Posts: 2337 Location: Germany
|
|
Posted: Sun Jun 23, 2013 10:12 am |
|
|
Quote: | I fixed it! It seems I have to use a pointer to the char array when I`m using FSmkdir in a function |
Yes of course, as with any string argument. The problem was unfortunately hidden by the incompletely posted code.
Please notice that string objects like char[] or char[7] are equivalent to char*.
Quote: | Why I can`t use pic kit 3 debugger with this mmd stack? It always stops and returns pic kit 3 has halted with errors? |
No idea, please post details. Which processor? |
|
|
stoyanoff
Joined: 20 Jul 2011 Posts: 375
|
|
Posted: Sun Jun 23, 2013 11:39 pm |
|
|
I'm using PIC18F66J60, Clock=10M, SD card 2G! |
|
|
|