]> git.zerfleddert.de Git - usb-driver/blobdiff - usb-driver.c
init libusb
[usb-driver] / usb-driver.c
index 89269b6e80c084e6779cbabfc7990de374c8914b..ea8a7a70085996e0a898e619e790bef3190f1c29 100644 (file)
 #include <sys/stat.h>
 #include <sys/time.h>
 #include <stdio.h>
+#include <usb.h>
 #include "xilinx.h"
 
 static int (*ioctl_func) (int, int, void *) = NULL;
 static int windrvrfd = 0;
+static struct usb_bus *busses = NULL;
 
 void hexdump(unsigned char *buf, int len);
 void diff(unsigned char *buf1, unsigned char *buf2, int len);
@@ -182,7 +184,20 @@ int do_wdioctl(int fd, unsigned int request, unsigned char *wdioctl) {
 
                case EVENT_PULL:
                        fprintf(stderr,"EVENT_PULL\n");
-                       ret = (*ioctl_func) (fd, request, wdioctl);
+                       {
+                               struct event *e = (struct event*)(wdheader->data);
+                               int i;
+
+                               fprintf(stderr,"handle: %lu, action: %lu, status: %lu, eventid: %lu, cardtype: %lu, kplug: %lu, options: %lu, dev: %lx:%lx, unique: %lu, ver: %lu, nummatch: %lu\n", e->handle, e->dwAction, e->dwStatus, e->dwEventId, e->dwCardType, e->hKernelPlugIn, e->dwOptions, e->u.Usb.deviceId.dwVendorId, e->u.Usb.deviceId.dwProductId, e->u.Usb.dwUniqueID, e->dwEventVer, e->dwNumMatchTables);
+                               for (i = 0; i < e->dwNumMatchTables; i++)
+                                       fprintf(stderr,"match: dev: %x:%x, class: %x, subclass: %x, intclass: %x, intsubclass: %x, intproto: %x\n", e->matchTables[i].VendorId, e->matchTables[i].ProductId, e->matchTables[i].bDeviceClass, e->matchTables[i].bDeviceSubClass, e->matchTables[i].bInterfaceClass, e->matchTables[i].bInterfaceSubClass, e->matchTables[i].bInterfaceProtocol);
+
+                               ret = (*ioctl_func) (fd, request, wdioctl);
+
+                               fprintf(stderr,"handle: %lu, action: %lu, status: %lu, eventid: %lu, cardtype: %lu, kplug: %lu, options: %lu, dev: %lx:%lx, unique: %lu, ver: %lu, nummatch: %lu\n", e->handle, e->dwAction, e->dwStatus, e->dwEventId, e->dwCardType, e->hKernelPlugIn, e->dwOptions, e->u.Usb.deviceId.dwVendorId, e->u.Usb.deviceId.dwProductId, e->u.Usb.dwUniqueID, e->dwEventVer, e->dwNumMatchTables);
+                               for (i = 0; i < e->dwNumMatchTables; i++)
+                                       fprintf(stderr,"match: dev: %x:%x, class: %x, subclass: %x, intclass: %x, intsubclass: %x, intproto: %x\n", e->matchTables[i].VendorId, e->matchTables[i].ProductId, e->matchTables[i].bDeviceClass, e->matchTables[i].bDeviceSubClass, e->matchTables[i].bInterfaceClass, e->matchTables[i].bInterfaceSubClass, e->matchTables[i].bInterfaceProtocol);
+                       }
                        break;
 
                default:
@@ -216,6 +231,13 @@ int open (const char *pathname, int flags, ...)
        if (!strcmp (pathname, "/dev/windrvr6")) {
                fprintf(stderr,"opening windrvr6\n");
                windrvrfd = fd;
+               if (!busses) {
+                       usb_init();
+                       usb_find_busses();
+                       usb_find_devices();
+
+                       busses = usb_get_busses();
+               }
        }
 
        return fd;
Impressum, Datenschutz