Skip to main content
VCapu
Associate III
June 27, 2022
Question

How to know the remaining capacity of the USB key connected to board configured as USB host?

..

This topic has been closed for replies.

3 replies

Tesla DeLorean
Guru
June 27, 2022

The underlying capacity via GET CAPACITY type query, for file system you'd have to navigate the structure and find free space. FATFS provided for a method to get used/free space.​

Tips, Buy me a coffee, or three.. PayPal Venmo (See Profile) Up vote any posts that you find helpful, it shows what's working..
VCapu
VCapuAuthor
Associate III
June 27, 2022

Is there an example? In the libraries in my code I have found USBH_MSC_SCSI_ReadCapacity(), but I didn't managed to make it work.

I initialized USB with MX_USB_HOST_Init() and in the while(1) loop I use MX_USB_HOST_Process(). But I see that in the libraries the function USBH_MSC_SCSI_ReadCapacity() is called inside USBH_StatusTypeDef USBH_MSC_Process(USBH_HandleTypeDef *phost)

Andrew Neil
Super User
June 27, 2022

@VCapu​  "Is there an example?"

what filesystem are you using?

Have you looked in its documentation?

eg, FatFs documentation is here: http://elm-chan.org/fsw/ff/00index_e.html - you can see there's a function to "Get free space on the volume" ...

A complex system that works is invariably found to have evolved from a simple system that worked.A complex system designed from scratch never works and cannot be patched up to make it work.