From 291b3a260cdf9b35f7a8f51cb124d689159123e7 Mon Sep 17 00:00:00 2001 From: Martin Koegler Date: Wed, 26 Jan 2011 13:49:28 +0100 Subject: [PATCH] USB correction for new library Signed-off-by: Martin Koegler --- eibd/backend/usbif.cpp | 39 +++++++++++++++++++-------------------- eibd/usb/findknxusb.cpp | 12 +++++------- eibd/usb/usb.cpp | 2 +- 3 files changed, 25 insertions(+), 28 deletions(-) diff --git a/eibd/backend/usbif.cpp b/eibd/backend/usbif.cpp index efd4289..667654b 100644 --- a/eibd/backend/usbif.cpp +++ b/eibd/backend/usbif.cpp @@ -26,6 +26,8 @@ #include "usbif.h" #include "usb.h" +extern libusb_context *context; + USBEndpoint parseUSBEndpoint (const char *addr) { @@ -129,16 +131,14 @@ check_device (libusb_device * dev, USBEndpoint e, USBDevice & e2) { if (ep->bEndpointAddress & LIBUSB_ENDPOINT_IN) { - if ((ep-> - bmAttributes & LIBUSB_TRANSFER_TYPE_MASK) == - LIBUSB_TRANSFER_TYPE_INTERRUPT) + if ((ep->bmAttributes & LIBUSB_TRANSFER_TYPE_MASK) + == LIBUSB_TRANSFER_TYPE_INTERRUPT) in = ep->bEndpointAddress; } else { - if ((ep-> - bmAttributes & LIBUSB_TRANSFER_TYPE_MASK) == - LIBUSB_TRANSFER_TYPE_INTERRUPT) + if ((ep->bmAttributes & LIBUSB_TRANSFER_TYPE_MASK) + == LIBUSB_TRANSFER_TYPE_INTERRUPT) out = ep->bEndpointAddress; } } @@ -175,7 +175,7 @@ detectUSBEndpoint (USBEndpoint e) int i, count; USBDevice e2; e2.dev = NULL; - count = libusb_get_device_list (NULL, &devs); + count = libusb_get_device_list (context, &devs); for (i = 0; i < count; i++) if (check_device (devs[i], e, e2)) @@ -375,20 +375,19 @@ USBLowLevelDriver::Run (pth_sem_t * stop1) t->TracePacket (0, this, "RecvUSB", res); outqueue.put (new CArray (res)); pth_sem_inc (&out_signal, 1); - if (recvbuf [0] == 0x01 && - recvbuf [1] == 0x13 && - recvbuf [2] == 0x0A && - recvbuf [3] == 0x00 && - recvbuf [4] == 0x08 && - recvbuf [5] == 0x00 && - recvbuf [6] == 0x02 && - recvbuf [7] == 0x0F && - recvbuf [8] == 0x04 && - recvbuf [9] == 0x00 && - recvbuf [10] == 0x00 && - recvbuf [11] == 0x03) + if (recvbuf[0] == 0x01 && + recvbuf[1] == 0x13 && + recvbuf[2] == 0x0A && + recvbuf[3] == 0x00 && + recvbuf[4] == 0x08 && + recvbuf[5] == 0x00 && + recvbuf[6] == 0x02 && + recvbuf[7] == 0x0F && + recvbuf[8] == 0x04 && + recvbuf[9] == 0x00 && + recvbuf[10] == 0x00 && recvbuf[11] == 0x03) { - if (recvbuf [12] & 0x1) + if (recvbuf[12] & 0x1) connection_state = true; else connection_state = false; diff --git a/eibd/usb/findknxusb.cpp b/eibd/usb/findknxusb.cpp index 3314b98..7880165 100644 --- a/eibd/usb/findknxusb.cpp +++ b/eibd/usb/findknxusb.cpp @@ -67,16 +67,14 @@ check_device (libusb_device * dev) { if (ep->bEndpointAddress & LIBUSB_ENDPOINT_IN) { - if ((ep-> - bmAttributes & LIBUSB_TRANSFER_TYPE_MASK) == - LIBUSB_TRANSFER_TYPE_INTERRUPT) + if ((ep->bmAttributes & LIBUSB_TRANSFER_TYPE_MASK) + == LIBUSB_TRANSFER_TYPE_INTERRUPT) in = ep->bEndpointAddress; } else { - if ((ep-> - bmAttributes & LIBUSB_TRANSFER_TYPE_MASK) == - LIBUSB_TRANSFER_TYPE_INTERRUPT) + if ((ep->bmAttributes & LIBUSB_TRANSFER_TYPE_MASK) + == LIBUSB_TRANSFER_TYPE_INTERRUPT) out = ep->bEndpointAddress; } } @@ -127,7 +125,7 @@ main () } libusb_set_debug (context, 0); printf ("Possible addresses for KNX USB devices:\n"); - count = libusb_get_device_list (NULL, &devs); + count = libusb_get_device_list (context, &devs); for (i = 0; i < count; i++) { diff --git a/eibd/usb/usb.cpp b/eibd/usb/usb.cpp index 8ef695d..b7bf38f 100644 --- a/eibd/usb/usb.cpp +++ b/eibd/usb/usb.cpp @@ -95,7 +95,7 @@ USBLoop::Run (pth_sem_t * stop1) pth_event_free (stop, PTH_FREE_THIS); } -static libusb_context *context = 0; +libusb_context *context = 0; static USBLoop *loop = 0; bool -- 2.11.4.GIT