I need my software to be notifed that usb mass storage stick has been inserterd, also i need locationa where this stick has been mounted. Is it possible to obtain this information, especially location on fs where stick has been mounted from any C library ?
For instertion i already know usbd_connect() and i'm using it. Unfortunatelly there is no information with respect to location on fs.
regards JosiP
io-usb should be up and running on your target.
Add the library "usbdi" to your project.
Then use the following code snipet :
#include <sys/usbdi.h>
static struct usbd_connection *conn_usb = NULL;
static void cbinsert(struct usbd_connection *connection, usbd_device_instance_t *ins);
static void cbremove(struct usbd_connection *connection, usbd_device_instance_t *ins);
int init(void)
{
usbd_funcs_t funcs = { _USBDI_NFUNCS, cbinsert, cbremove, NULL };
usbd_connect_parm_t parm = {NULL, USB_VERSION, USBD_VERSION, 0, 0, NULL, 0, NULL, &funcs,0};
if (usbd_connect(&parm, &conn_usb) != EOK) {
/* write your own error handler */
}
And then, add your customized handler :
static void cbinsert(struct usbd_connection *usb_connection,usbd_device_instance_t *usb_instance)
{
if (usb_instance->ident.dclass == 8 && usb_instance->ident.subclass == 6) {
/* USB mass storage */
} else if (usb_instance->ident.dclass == 3 && usb_instance->ident.subclass == 1) {
/* USB mouse */
} else {
/* unknown device */
}
This is an example. You will have to customized it. But everything you need is there.
Hope this help ! Emmanuel