Answer the question
In order to leave comments, you need to log in
Transfer and read data from microcontroller using libusb?
QMessageBox *msg = new QMessageBox(this);
unsigned char input[] = {0x10};
libusb_init(NULL);
libusb_device_handle *dev = libusb_open_device_with_vid_pid(NULL, device->getVID(), device->getPID());
if(dev == NULL) {
msg->setText("Device no Find");
msg->show();
return; }
int transferred;
int ret;
if (libusb_kernel_driver_active(dev,0))
libusb_detach_kernel_driver(dev,0);
if ((ret = libusb_set_configuration(dev, 1)) < 0)
{
msg->setText("Ошибка");
msg->show();
}
if (libusb_claim_interface(dev, 0) < 0)
{
msg->setText("Ошибка");
msg->show();
}
ret = libusb_interrupt_transfer(dev, 0x01, input, sizeof(input), &transferred, 1000);
if (ret < 0){
msg->setText("Ошибка");
msg->show();
}
libusb_attach_kernel_driver(dev, 0);
libusb_release_interface(dev, 0);
libusb_close(dev);
libusb_exit(NULL);
msg->setText(QString(input[0]));
msg->show();
Answer the question
In order to leave comments, you need to log in
Study this guide: habrahabr.ru/post/261955
And in fact, it’s difficult to talk about something without USB descriptors (on Linux: lsusb -v, on Windows: UsbView). Well, check that you really use interrupt transfer and that the code on the device itself is correct.
And so, I don’t see any crime: transfer to the device, which means EP OUT, you have it EP1, which means 0x01. So most likely the problem is on the device. Try, for a start, control transfering.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question