From fdb1a05b6b5c84b67e3df107288f5046b763647e Mon Sep 17 00:00:00 2001 From: Burt P Date: Fri, 18 Aug 2017 02:14:47 -0500 Subject: usb_util.c A set of functions for getting information for a single USB device, or a list of all devices. The only implemented method is using `lsusb`, which is slow. A method using sysfs would be much better. The existing sysfs and procfs methods in devices/usb.c do not appear to work, so it would have to be something new. devices/usb.c modified to use usb_util, but all the old code is still there. Signed-off-by: Burt P --- includes/usb_util.h | 35 +++++++++++++++++++++++++++++++++++ 1 file changed, 35 insertions(+) create mode 100644 includes/usb_util.h (limited to 'includes/usb_util.h') diff --git a/includes/usb_util.h b/includes/usb_util.h new file mode 100644 index 00000000..5d7f55bf --- /dev/null +++ b/includes/usb_util.h @@ -0,0 +1,35 @@ +#ifndef __USB_UTIL_H__ +#define __USB_UTIL_H__ + +/* this is a linked list */ +typedef struct usbd { + int bus, dev; + int vendor_id, product_id; + char *vendor; + char *product; + + int dev_class; + int dev_subclass; + char *dev_class_str; + char *dev_subclass_str; + + char *usb_version; + char *device_version; /* bcdDevice */ + + int max_curr_ma; + + int speed_mbs; /* TODO: */ + + int user_scan; /* not scanned as root */ + + struct usbd *next; +} usbd; + +usbd *usb_get_device_list(); +int usbd_list_count(usbd *); +void usbd_list_free(usbd *); + +usbd *usb_get_device(int bus, int dev); +void usbd_free(usbd *); + +#endif -- cgit v1.2.3