Keil Logo Arm Logo

USB host

Next Thread | Thread List | Previous Thread Start a Thread | Settings

Details Message
Read-Only
Author
rohit kumar
Posted
12-Apr-2012 09:48 GMT
Toolset
ARM
New! USB host

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.

Read-Only
Author
Per Westermark
Posted
12-Apr-2012 13:04 GMT
Toolset
ARM
New! RE: USB host

Exactly what have this with "USB Host" to do?

Read-Only
Author
rohit kumar
Posted
16-Apr-2012 04:47 GMT
Toolset
ARM
New! RE: USB host

Sir,

I know usb host has no role in this .I think you didn,t understand the question.

Anyway thanks for your kind support

Read-Only
Author
Per Westermark
Posted
16-Apr-2012 08:40 GMT
Toolset
ARM
New! RE: USB host

I think I did.

Your first post specifically said you were working on a USB host.

But your issue don't seem to relate to any USB host.

So then the issue is that you haven't really given us any information at all.

You create files, you say. Using what file system? Saving to what media? Doing what debugging?

I think you haven't understood the question yourself, since you haven't given us anything to work on.

Maybe, just maybe the file system library supports 5 open files, and you have forgotten to close the current file before you start creating the next file. So when you try to create file number 6, you get a failure. By the way - don't you log failures? Are there absolutely zero function calls that fails?

Read-Only
Author
rohit kumar
Posted
16-Apr-2012 09:43 GMT
Toolset
ARM
New! RE: file system

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.

Next Thread | Thread List | Previous Thread Start a Thread | Settings

Keil logo

Arm logo
Important information

This site uses cookies to store information on your computer. By continuing to use our site, you consent to our cookies.