diff --git a/include/usbhost/usbhost.h b/include/usbhost/usbhost.h index 04c494da2..f7cc52e5a 100644 --- a/include/usbhost/usbhost.h +++ b/include/usbhost/usbhost.h @@ -84,6 +84,8 @@ const char* usb_device_get_name(struct usb_device *device); */ int usb_device_get_unique_id(struct usb_device *device); +int usb_device_get_unique_id_from_name(const char* name); + /* Returns the USB vendor ID from the device descriptor for the USB device */ uint16_t usb_device_get_vendor_id(struct usb_device *device); diff --git a/libusbhost/usbhost.c b/libusbhost/usbhost.c index 613dbaad8..98ccf7c5d 100644 --- a/libusbhost/usbhost.c +++ b/libusbhost/usbhost.c @@ -270,6 +270,13 @@ int usb_device_get_unique_id(struct usb_device *device) return bus * 1000 + dev; } +int usb_device_get_unique_id_from_name(const char* name) +{ + int bus = 0, dev = 0; + sscanf(name, USB_FS_ID_SCANNER, &bus, &dev); + return bus * 1000 + dev; +} + uint16_t usb_device_get_vendor_id(struct usb_device *device) { struct usb_device_descriptor* desc = (struct usb_device_descriptor*)device->desc;