hi the title may busbcom = new UsbCom();
connect(usbcom, SIGNAL(error(QString)), SLOT(usbError(QString)));
usbcom->start();e a little weird but i wasnt sure what to call it.

il try to explain what im trying to do.

i am trying to get data from the usb device with libusb_handle_events function
in my main class i use this code to start the thread for usb communication:
Qt Code:
  1. usbcom = new UsbCom();
  2. connect(usbcom, SIGNAL(error(QString)), SLOT(usbError(QString)));
  3. connect(usbcom, SIGNAL(dataRecieved(QString)), SLOT(usbDataRecieved(QString)));
  4. usbcom->start();
To copy to clipboard, switch view to plain text mode 

UsbCom class:

Qt Code:
  1. #include "usbcom.h"
  2. #include <QtGui>
  3. #include "/usr/local/include/libusb-1.0/libusb.h"
  4. #include "dataemit.h"
  5. #include <QApplication>
  6.  
  7. #define idVENDOR 0x0483
  8. #define idPRODUCT 0x5750
  9. #define EP_INTR_OUT ( 1 | LIBUSB_ENDPOINT_OUT)
  10. #define EP_INTR_IN ( 1 | LIBUSB_ENDPOINT_IN )
  11.  
  12. UsbCom::UsbCom()
  13. {
  14. }
  15.  
  16. void UsbCom::run()
  17. {
  18. int r;
  19. int transf;
  20. unsigned char data[2]={2,5};
  21. r = libusb_init(NULL);
  22. if (r < 0)
  23. {
  24. emit error("Failed to initialize USB!");
  25. exit(1);
  26. }
  27.  
  28. libusb_device_handle *devh = libusb_open_device_with_vid_pid(NULL, idVENDOR, idPRODUCT);
  29.  
  30. if(!devh)
  31. {
  32. emit error("Could not locate device");
  33. exit();
  34. }
  35.  
  36. r = libusb_kernel_driver_active (devh, 0);
  37.  
  38. if (r != 0)
  39. {
  40. if(r==1)
  41. {
  42. r = libusb_detach_kernel_driver(devh, 0);
  43. if (r > 0)
  44. {
  45. emit error("some other random error:"+ QString::number(r));
  46. exit(1);
  47. }
  48. }
  49. }
  50.  
  51. r = libusb_claim_interface(devh, 0);
  52.  
  53. if (r < 0)
  54. {
  55. emit error("usb_claim_interface error"+ QString::number(r));
  56. }
  57.  
  58. r = libusb_interrupt_transfer(devh, EP_INTR_OUT, data, sizeof(data), &transf,50);
  59.  
  60. emit error("did it work? r:" + QString::number(r));
  61.  
  62. irq_transfer = libusb_alloc_transfer(0);
  63. unsigned char irqbuf[2];
  64.  
  65. libusb_fill_interrupt_transfer(irq_transfer, devh, EP_INTR_IN, irqbuf,sizeof(irqbuf), ep_irq_in_cb, NULL, 0);
  66. r = libusb_submit_transfer(irq_transfer);
  67.  
  68. while(1)
  69. {
  70. r = libusb_handle_events(NULL);
  71. }
  72. }
  73.  
  74. void UsbCom::dataRecieve()
  75. {
  76. }
  77.  
  78. void ep_irq_in_cb(libusb_transfer *transfer)
  79. {
  80. if(transfer->status != LIBUSB_TRANSFER_COMPLETED)
  81. {
  82. // fprintf(stderr, "uncompleted transter\n");
  83. }
  84.  
  85. //[COLOR="red"]dont know what code goes here, try to call UsbCom::DataRecieve[/COLOR]
  86.  
  87. if (libusb_submit_transfer(transfer) < 0){
  88. fprintf(stderr,"couldnot resubmit irq \n");
  89. exit(1);
  90. }
  91.  
  92. }
To copy to clipboard, switch view to plain text mode 

the problem is that as you can see the
void ep_irq_in_cb(libusb_transfer *transfer) function is not in the UsbCom class. but when the code executes i need to call the UsbCom:ataRecieve() function so that it connects to the slot in my main thread.

if anyone can help me i would be very gratefull.

Sisco