Skip to main content
Visitor II
March 23, 2020
Question

Reagarding USB HOST reading the .abs file in stm32h750

  • March 23, 2020
  • 2 replies
  • 750 views

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

    This topic has been closed for replies.

    2 replies

    Graduate II
    March 23, 2020

    What are you talking about?

    MSury.1Author
    Visitor II
    March 24, 2020

    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);

    }