cancel
Showing results for 
Search instead for 
Did you mean: 

Reagarding USB HOST reading the .abs file in stm32h750

MSury.1
Associate II

When I am read .text file then code works fine and reading file also fine but when I am reading the .abs and .bin file in usb host flash then I got the error reading ​file is faile ,so please suggestions me what I am do to read the .abs and .bin file stm32h750 ASAP

2 REPLIES 2

What are you talking about?

Tips, Buy me a coffee, or three.. PayPal Venmo
Up vote any posts that you find helpful, it shows what's working..
MSury.1
Associate II

i run the code USB Host in stm32h750 .its is working fine when i read .txt file but when i am read the .abs file from pendrive then this file can not read using F_read() function. so i want to read . abs file from pendrive using stm32h750 MPU. this is my code attached

bool UsbTest_write(void)

{

   //Open and Created file for writing

   if(f_open(&myFile,"TEST2.TXT",FA_CREATE_ALWAYS | FA_WRITE)!=FR_OK)

   {

      return 0;

   }

   else

   {

      //copy to string into the temporary variable

      sprintf(rwtext ,"Froom MANOJ");

      //write to text file

      res= f_write(&myFile,(const void *)rwtext,strlen(rwtext),&byteswritten);

      if( (res != FR_OK)|| (byteswritten==0) )

      {

         return 0;

      }

      f_close(&myFile);

      return 1;

   }

}

void UsbTest_Read(void)

{

   res=f_open(&myFile, "TEST2.TXT", FA_READ);

   if (res == FR_OK)

   {

      printf("File eTEST.TXT sucessfully opened!\n");

   }

   size = f_size(&myFile);

   char * data = NULL;

   data = malloc(size); /* allocate memory to store image data */

   printf("File size: %d bytes\n", size);

   res = f_read(&myFile, data, (UINT) size, &bytesread);

    if (res == FR_OK){

                      printf("File successfully read!\n");

                      printf("%d bytes read\n", bytesread);

                      for (int i=0; i < bytesread; i++)

                      {

                          printf("data[%d]: 0x%x\n", i, data[i]);

                      }

                  }

                   free(data); // free allocated memory when you don't need it

                    f_close(&myFile);

}