Loading include/usbhost/usbhost.h +5 −0 Original line number Diff line number Diff line Loading @@ -57,6 +57,11 @@ void usb_device_close(struct usb_device *device); */ const char* usb_device_get_name(struct usb_device *device); /* Returns a unique ID for the device. Currently this is generated from the * dev_name path. */ int usb_device_get_unique_id(struct usb_device *device); /* Returns the USB vendor ID from the device descriptor for the USB device */ uint16_t usb_device_get_vendor_id(struct usb_device *device); Loading libusbhost/usbhost.c +8 −0 Original line number Diff line number Diff line Loading @@ -41,6 +41,7 @@ #include "usbhost/usbhost.h" #define USB_FS_DIR "/dev/bus/usb" #define USB_FS_ID_SCANNER "/dev/bus/usb/%d/%d" #if 0 #define D printf Loading Loading @@ -243,6 +244,13 @@ const char* usb_device_get_name(struct usb_device *device) return device->dev_name; } int usb_device_get_unique_id(struct usb_device *device) { int bus = 0, dev = 0; sscanf(device->dev_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; Loading Loading
include/usbhost/usbhost.h +5 −0 Original line number Diff line number Diff line Loading @@ -57,6 +57,11 @@ void usb_device_close(struct usb_device *device); */ const char* usb_device_get_name(struct usb_device *device); /* Returns a unique ID for the device. Currently this is generated from the * dev_name path. */ int usb_device_get_unique_id(struct usb_device *device); /* Returns the USB vendor ID from the device descriptor for the USB device */ uint16_t usb_device_get_vendor_id(struct usb_device *device); Loading
libusbhost/usbhost.c +8 −0 Original line number Diff line number Diff line Loading @@ -41,6 +41,7 @@ #include "usbhost/usbhost.h" #define USB_FS_DIR "/dev/bus/usb" #define USB_FS_ID_SCANNER "/dev/bus/usb/%d/%d" #if 0 #define D printf Loading Loading @@ -243,6 +244,13 @@ const char* usb_device_get_name(struct usb_device *device) return device->dev_name; } int usb_device_get_unique_id(struct usb_device *device) { int bus = 0, dev = 0; sscanf(device->dev_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; Loading