We are running a survey to help us improve the experience for all of our members. If you see the survey appear, please take the time to tell us about your experience if you can.
hello dear all, I have a problem in create a text file in SD card. here is my code. it doesn't create text file. i work on LPC1768. would you tell me what is the problem with my code?
FATFS fs; /* Work area (file system object) for logical drive */ FIL fsrc; /* file objects */ FRESULT res; UINT br; int SD_TotalSize(void); char path[512]="0:"; uint8_t textFileBuffer[] = "Thank \r\n"; FRESULT scan_files (char* path); f_mount(0,&fs); res = f_open( &fsrc , "0:/Demo.TXT" , FA_CREATE_NEW | FA_WRITE); if ( res == FR_OK ) { /* Write buffer to file */ res = f_write(&fsrc, textFileBuffer, sizeof(textFileBuffer), &br); printf("Demo.TXT successfully created"); /*close file */ f_close(&fsrc); } else if ( res == FR_EXIST ) { printf("Demo.TXT created in the disk"); } scan_files(path); SD_TotalSize(); /* Infinite loop */ while (1) {} }
You ignore the return from f_mount();
You only check the return code from f_open() for FR_OK and FR_EXIST;
You ignore the return from f_write();
You ignore the return from f_close();
i used these code return, but it show 0x00 for fs(file system object)!! whats the problem with that, it is send back nothing!
Not in the posted code, you don't!
If you've changed the code, then show it - and show what return values you are getting.
I can not show all the code. Someone will steel it.
Yes, there are real big market for fencing broken code. Decide if the coders here are actually capable of writing and debugging their own software.
Break it down to the SD layer, and the diskio.c layer, which have probably both been lifted from other sources. Prove that the SD code is actually functional, and can read/write sector(s) properly. If that doesn't work properly, or handle/manage errors effectively, nothing you layer on top of it is going to be successful.
Yeah - right!
You're using an open-source library, and your code doesn't even work - clearly a prime target for theft!!
And yet you expect people to fix your broken code for free?!
So how about taking the original code you posted, and using that to demonstrate the problem?
Add the return value checks.
See where it's failing,
i don't write "I can not show all the code. Someone will steel it." !!!!! is it possible someone steal my name?!! it's so strange!