Hello Sir,
I am working on USB host using LPC2468. I am facing a problem when i try to create 6 different file it creates 5 files on pendrive 6th file is not creating my code is like that
for(file_no =1;file_no<=6;file_no++) files_on_pendrive(); void files_on_pendrive(void){ switch(file_no){ case 1: cashier_dbase(); break; case 2: tax_dbase(); break; case 3: billsumm_dbase(); break; case 4: crd_trans_dbase(); break; case 5: bill_copy_dbase(); break; case 6: pagewise_dbase(); break; } }
in the above code each switch case creates a file but case6 is not creating the file if i place case 5 function in place of case6 function then again case6 is not creating a file what,s the reason behind it.
Sir,I apologize for this mistake.
I tell you each and everything briefly
1 i am using FAT32 file system ,Try to create file on pendrive, As far as debugging is concerned when I debug through case 6 in source code which i post you in last thread every thing is ok each and every function is performing their operation as like in other cases.
2 I am closing each file after creating it and writing data to it.
3 I want to know how to modify the file system so that it supports more than 5 open files.
One more thing I am creating file name with date and time append to it as shown below
sprintf(filename, "CASHIER-%d-%02d-%02d-%02d-%02d.RTF", RTC_DOW, RTC_MONTH, RTC_YEAR,RTC_HOUR,RTC_MIN); host_write(filename,tot_bytes, pac_nob); void host_write(UWORD8 *file_name,UWORD32 tot_byte2_write,UWORD16 pac_nob1) { UWORD16 host_nob,host_pac_nob; SWORD32 fdw; UWORD32 write_size; UWORD32 bytes_written,tot_bytes_written; UWORD16 host_var0; write_size=tot_byte2_write; host_pac_nob =pac_nob1; fdw = FILE_Open(file_name, RDWR); if (fdw > 0) { tot_bytes_written = 0; if(tot_byte2_write> MAX_BUFFER_SIZE) host_nob=MAX_BUFFER_SIZE; else host_nob=tot_byte2_write; if(ext_pac_nob==0) host_var0 =0; else host_var0 =13; for(; host_var0<host_nob;host_var0++) { if(host_pac_nob==0){ *UserBuffer++ = s_chksum >> 8; *UserBuffer++ = (UWORD8) s_chksum; *UserBuffer++ = 0x64; break; } else { trf_time_srch(); host_pac_nob--; } } UserBuffer-=host_nob; do { if(write_size> MAX_BUFFER_SIZE) bytes_written = FILE_Write(fdw, UserBuffer,MAX_BUFFER_SIZE); else bytes_written = FILE_Write(fdw, UserBuffer,write_size); tot_bytes_written += bytes_written; write_size-=bytes_written; if(write_size!=0 && write_size<MAX_BUFFER_SIZE) { for(host_var0=0; host_var0<write_size;host_var0++) { if(host_pac_nob==0){ *UserBuffer++ = s_chksum >> 8; *UserBuffer++ = (UWORD8) s_chksum;; *UserBuffer++ = 0x64; break; } else { trf_time_srch(); host_pac_nob--; } } UserBuffer-= write_size; } else { if(write_size!=0) { for(host_var0=0; host_var0<MAX_BUFFER_SIZE;host_var0++) { trf_time_srch(); host_pac_nob--; } UserBuffer-=MAX_BUFFER_SIZE; } } } while (write_size!=0); fl_host_lnk =FALSE; FILE_Close(fdw); } else{ return; } }
This host_write function is called in all 6 cases. Sir when i remove date and time from file name I am able to create 6 files successfully. What,s the reason behind it.