Discussion:
[libusb] Ubuntu16.04:libusb_interrupt_transfer error -7
d***@foxmail.com
2017-05-29 07:00:49 UTC
Permalink
Hello
libusb_interrupt_transfer rreturn -7.i dont know why

int interface = 0;
unsigned char data[] = {0x05,0x11,0x70};
// int ret = libusb_bulk_transfer(hd,0x01,data,3,&interface,5000);
// int ret = libusb_control_transfer(hd,CTRL_OUT, USB_RQ,0x08,0,data,sizeof(data),0);

int ret = libusb_interrupt_transfer(hd,0x81,data,sizeof(data), &interface,1000);

log£º
[timestamp] [threadID] facility level [function call]

[ 0.002805] [00001298] libusb: debug [libusb_get_device_list]
5 Devices in list.
[ 0.002895] [00001298] libusb: debug [libusb_get_device_list]
[ 0.002907] [00001298] libusb: debug [libusb_get_device_descriptor]
[ 0.002910] [00001298] libusb: debug [libusb_get_device_descriptor]
[ 0.002912] [00001298] libusb: debug [libusb_open] open 2.5
[ 0.002930] [00001298] libusb: debug [usbi_add_pollfd] add fd 9 events 4
Device Opened
[ 0.002960] [00001298] libusb: debug [libusb_kernel_driver_active] interface 0
[ 0.002969] [00001298] libusb: debug [libusb_claim_interface] interface 0
Claimed Interface
[ 0.003004] [00001298] libusb: debug [libusb_alloc_transfer] transfer 0x80f85e8
[ 0.003013] [00001298] libusb: debug [libusb_submit_transfer] transfer 0x80f85e8
[ 0.003017] [00001298] libusb: debug [add_to_flying_list] arm timerfd for timeout in 1000ms (first in line)
[ 0.003023] [00001298] libusb: debug [submit_bulk_transfer] need 1 urbs for new transfer with length 3
[ 0.003053] [00001298] libusb: debug [libusb_handle_events_timeout_completed] doing our own event handling
[ 0.003073] [00001298] libusb: debug [handle_events] poll fds modified, reallocating
[ 0.003081] [00001298] libusb: debug [handle_events] poll() 3 fds with timeout in 60000ms
[ 1.003615] [00001298] libusb: debug [handle_events] poll() returned 1
[ 1.003649] [00001298] libusb: debug [handle_events] timerfd triggered
[ 1.003656] [00001298] libusb: debug [libusb_cancel_transfer] transfer 0x80f85e8
[ 1.253695] [00001298] libusb: debug [disarm_timerfd]
[ 1.253730] [00001298] libusb: debug [handle_events] poll() 3 fds with timeout in 0ms
[ 1.253738] [00001298] libusb: debug [handle_events] poll() returned 1
[ 1.253764] [00001298] libusb: debug [reap_for_handle] urb type=1 status=-2 transferred=0
[ 1.253772] [00001298] libusb: debug [handle_bulk_completion] handling completion status -2 of bulk urb 1/1
[ 1.253777] [00001298] libusb: debug [handle_bulk_completion] abnormal reap: urb status -2
[ 1.253780] [00001298] libusb: debug [handle_bulk_completion] abnormal reap: last URB handled, reporting
[ 1.253784] [00001298] libusb: debug [usbi_handle_transfer_cancellation] detected timeout cancellation
[ 1.253790] [00001298] libusb: debug [disarm_timerfd]
[ 1.253793] [00001298] libusb: debug [usbi_handle_transfer_completion] transfer 0x80f85e8 has callback 0xb7782510
[ 1.253796] [00001298] libusb: debug [sync_transfer_cb] actual_length=0
[ 1.253805] [00001298] libusb: debug [libusb_free_transfer] transfer 0x80f85e8
ret :-7
interface : 0
[ 1.253837] [00001298] libusb: debug [libusb_close]
[ 1.253850] [00001298] libusb: debug [usbi_remove_pollfd] remove fd 9
[ 1.253878] [00001298] libusb: debug [libusb_exit]
[ 1.253897] [00001298] libusb: debug [libusb_exit] destroying default context



***@foxmail.com
d***@foxmail.com
2017-05-29 07:29:03 UTC
Permalink
Hello
libusb_interrupt_transfer rreturn -7.i dont know why

int interface = 0;
unsigned char data[] = {0x05,0x11,0x70};
// int ret = libusb_bulk_transfer(hd,0x01,data,3,&interface,5000);
// int ret = libusb_control_transfer(hd,CTRL_OUT, USB_RQ,0x08,0,data,sizeof(data),0);

int ret = libusb_interrupt_transfer(hd,0x81,data,sizeof(data), &interface,1000);

log
[timestamp] [threadID] facility level [function call]

[ 0.002805] [00001298] libusb: debug [libusb_get_device_list]
5 Devices in list.
[ 0.002895] [00001298] libusb: debug [libusb_get_device_list]
[ 0.002907] [00001298] libusb: debug [libusb_get_device_descriptor]
[ 0.002910] [00001298] libusb: debug [libusb_get_device_descriptor]
[ 0.002912] [00001298] libusb: debug [libusb_open] open 2.5
[ 0.002930] [00001298] libusb: debug [usbi_add_pollfd] add fd 9 events 4
Device Opened
[ 0.002960] [00001298] libusb: debug [libusb_kernel_driver_active] interface 0
[ 0.002969] [00001298] libusb: debug [libusb_claim_interface] interface 0
Claimed Interface
[ 0.003004] [00001298] libusb: debug [libusb_alloc_transfer] transfer 0x80f85e8
[ 0.003013] [00001298] libusb: debug [libusb_submit_transfer] transfer 0x80f85e8
[ 0.003017] [00001298] libusb: debug [add_to_flying_list] arm timerfd for timeout in 1000ms (first in line)
[ 0.003023] [00001298] libusb: debug [submit_bulk_transfer] need 1 urbs for new transfer with length 3
[ 0.003053] [00001298] libusb: debug [libusb_handle_events_timeout_completed] doing our own event handling
[ 0.003073] [00001298] libusb: debug [handle_events] poll fds modified, reallocating
[ 0.003081] [00001298] libusb: debug [handle_events] poll() 3 fds with timeout in 60000ms
[ 1.003615] [00001298] libusb: debug [handle_events] poll() returned 1
[ 1.003649] [00001298] libusb: debug [handle_events] timerfd triggered
[ 1.003656] [00001298] libusb: debug [libusb_cancel_transfer] transfer 0x80f85e8
[ 1.253695] [00001298] libusb: debug [disarm_timerfd]
[ 1.253730] [00001298] libusb: debug [handle_events] poll() 3 fds with timeout in 0ms
[ 1.253738] [00001298] libusb: debug [handle_events] poll() returned 1
[ 1.253764] [00001298] libusb: debug [reap_for_handle] urb type=1 status=-2 transferred=0
[ 1.253772] [00001298] libusb: debug [handle_bulk_completion] handling completion status -2 of bulk urb 1/1
[ 1.253777] [00001298] libusb: debug [handle_bulk_completion] abnormal reap: urb status -2
[ 1.253780] [00001298] libusb: debug [handle_bulk_completion] abnormal reap: last URB handled, reporting
[ 1.253784] [00001298] libusb: debug [usbi_handle_transfer_cancellation] detected timeout cancellation
[ 1.253790] [00001298] libusb: debug [disarm_timerfd]
[ 1.253793] [00001298] libusb: debug [usbi_handle_transfer_completion] transfer 0x80f85e8 has callback 0xb7782510
[ 1.253796] [00001298] libusb: debug [sync_transfer_cb] actual_length=0
[ 1.253805] [00001298] libusb: debug [libusb_free_transfer] transfer 0x80f85e8
ret :-7
interface : 0
[ 1.253837] [00001298] libusb: debug [libusb_close]
[ 1.253850] [00001298] libusb: debug [usbi_remove_pollfd] remove fd 9
[ 1.253878] [00001298] libusb: debug [libusb_exit]
[ 1.253897] [00001298] libusb: debug [libusb_exit] destroying default context



***@foxmail.com
d***@foxmail.com
2017-05-29 11:17:24 UTC
Permalink
Thanks for reply , Sorry my bad english, i mean is ,i can use Windows System API HidD_SetFeature function send data to device. but at Ubuntu i use libusb_interrupt_transfer function is return -7,cannot send data to device




·¢ŒþÈË£º ***@foxmail.com
·¢ËÍʱŒä£º 2017-05-29 15:00
ÊÕŒþÈË£º libusb-devel
Ö÷Ì⣺ Ubuntu16.04:libusb_interrupt_transfer error -7
Hello
libusb_interrupt_transfer rreturn -7.i dont know why

int interface = 0;
unsigned char data[] = {0x05,0x11,0x70};
// int ret = libusb_bulk_transfer(hd,0x01,data,3,&interface,5000);
// int ret = libusb_control_transfer(hd,CTRL_OUT, USB_RQ,0x08,0,data,sizeof(data),0);

int ret = libusb_interrupt_transfer(hd,0x81,data,sizeof(data), &interface,1000);

log£º
[timestamp] [threadID] facility level [function call]

[ 0.002805] [00001298] libusb: debug [libusb_get_device_list]
5 Devices in list.
[ 0.002895] [00001298] libusb: debug [libusb_get_device_list]
[ 0.002907] [00001298] libusb: debug [libusb_get_device_descriptor]
[ 0.002910] [00001298] libusb: debug [libusb_get_device_descriptor]
[ 0.002912] [00001298] libusb: debug [libusb_open] open 2.5
[ 0.002930] [00001298] libusb: debug [usbi_add_pollfd] add fd 9 events 4
Device Opened
[ 0.002960] [00001298] libusb: debug [libusb_kernel_driver_active] interface 0
[ 0.002969] [00001298] libusb: debug [libusb_claim_interface] interface 0
Claimed Interface
[ 0.003004] [00001298] libusb: debug [libusb_alloc_transfer] transfer 0x80f85e8
[ 0.003013] [00001298] libusb: debug [libusb_submit_transfer] transfer 0x80f85e8
[ 0.003017] [00001298] libusb: debug [add_to_flying_list] arm timerfd for timeout in 1000ms (first in line)
[ 0.003023] [00001298] libusb: debug [submit_bulk_transfer] need 1 urbs for new transfer with length 3
[ 0.003053] [00001298] libusb: debug [libusb_handle_events_timeout_completed] doing our own event handling
[ 0.003073] [00001298] libusb: debug [handle_events] poll fds modified, reallocating
[ 0.003081] [00001298] libusb: debug [handle_events] poll() 3 fds with timeout in 60000ms
[ 1.003615] [00001298] libusb: debug [handle_events] poll() returned 1
[ 1.003649] [00001298] libusb: debug [handle_events] timerfd triggered
[ 1.003656] [00001298] libusb: debug [libusb_cancel_transfer] transfer 0x80f85e8
[ 1.253695] [00001298] libusb: debug [disarm_timerfd]
[ 1.253730] [00001298] libusb: debug [handle_events] poll() 3 fds with timeout in 0ms
[ 1.253738] [00001298] libusb: debug [handle_events] poll() returned 1
[ 1.253764] [00001298] libusb: debug [reap_for_handle] urb type=1 status=-2 transferred=0
[ 1.253772] [00001298] libusb: debug [handle_bulk_completion] handling completion status -2 of bulk urb 1/1
[ 1.253777] [00001298] libusb: debug [handle_bulk_completion] abnormal reap: urb status -2
[ 1.253780] [00001298] libusb: debug [handle_bulk_completion] abnormal reap: last URB handled, reporting
[ 1.253784] [00001298] libusb: debug [usbi_handle_transfer_cancellation] detected timeout cancellation
[ 1.253790] [00001298] libusb: debug [disarm_timerfd]
[ 1.253793] [00001298] libusb: debug [usbi_handle_transfer_completion] transfer 0x80f85e8 has callback 0xb7782510
[ 1.253796] [00001298] libusb: debug [sync_transfer_cb] actual_length=0
[ 1.253805] [00001298] libusb: debug [libusb_free_transfer] transfer 0x80f85e8
ret :-7
interface : 0
[ 1.253837] [00001298] libusb: debug [libusb_close]
[ 1.253850] [00001298] libusb: debug [usbi_remove_pollfd] remove fd 9
[ 1.253878] [00001298] libusb: debug [libusb_exit]
[ 1.253897] [00001298] libusb: debug [libusb_exit] destroying default context



***@foxmail.com
d***@foxmail.com
2017-05-29 15:59:00 UTC
Permalink
Thanks for reply , Sorry my bad english, i mean is ,i can use Windows System API HidD_SetFeature function send data to device. but at Ubuntu i use libusb_interrupt_transfer function is return -7,cannot send data to device




发件人 ***@foxmail.com
发送时闎 2017-05-29 15:00
收件人 libusb-devel
䞻题 Ubuntu16.04:libusb_interrupt_transfer error -7
Hello
libusb_interrupt_transfer rreturn -7.i dont know why

int interface = 0;
unsigned char data[] = {0x05,0x11,0x70};
// int ret = libusb_bulk_transfer(hd,0x01,data,3,&interface,5000);
// int ret = libusb_control_transfer(hd,CTRL_OUT, USB_RQ,0x08,0,data,sizeof(data),0);

int ret = libusb_interrupt_transfer(hd,0x81,data,sizeof(data), &interface,1000);

log
[timestamp] [threadID] facility level [function call]

[ 0.002805] [00001298] libusb: debug [libusb_get_device_list]
5 Devices in list.
[ 0.002895] [00001298] libusb: debug [libusb_get_device_list]
[ 0.002907] [00001298] libusb: debug [libusb_get_device_descriptor]
[ 0.002910] [00001298] libusb: debug [libusb_get_device_descriptor]
[ 0.002912] [00001298] libusb: debug [libusb_open] open 2.5
[ 0.002930] [00001298] libusb: debug [usbi_add_pollfd] add fd 9 events 4
Device Opened
[ 0.002960] [00001298] libusb: debug [libusb_kernel_driver_active] interface 0
[ 0.002969] [00001298] libusb: debug [libusb_claim_interface] interface 0
Claimed Interface
[ 0.003004] [00001298] libusb: debug [libusb_alloc_transfer] transfer 0x80f85e8
[ 0.003013] [00001298] libusb: debug [libusb_submit_transfer] transfer 0x80f85e8
[ 0.003017] [00001298] libusb: debug [add_to_flying_list] arm timerfd for timeout in 1000ms (first in line)
[ 0.003023] [00001298] libusb: debug [submit_bulk_transfer] need 1 urbs for new transfer with length 3
[ 0.003053] [00001298] libusb: debug [libusb_handle_events_timeout_completed] doing our own event handling
[ 0.003073] [00001298] libusb: debug [handle_events] poll fds modified, reallocating
[ 0.003081] [00001298] libusb: debug [handle_events] poll() 3 fds with timeout in 60000ms
[ 1.003615] [00001298] libusb: debug [handle_events] poll() returned 1
[ 1.003649] [00001298] libusb: debug [handle_events] timerfd triggered
[ 1.003656] [00001298] libusb: debug [libusb_cancel_transfer] transfer 0x80f85e8
[ 1.253695] [00001298] libusb: debug [disarm_timerfd]
[ 1.253730] [00001298] libusb: debug [handle_events] poll() 3 fds with timeout in 0ms
[ 1.253738] [00001298] libusb: debug [handle_events] poll() returned 1
[ 1.253764] [00001298] libusb: debug [reap_for_handle] urb type=1 status=-2 transferred=0
[ 1.253772] [00001298] libusb: debug [handle_bulk_completion] handling completion status -2 of bulk urb 1/1
[ 1.253777] [00001298] libusb: debug [handle_bulk_completion] abnormal reap: urb status -2
[ 1.253780] [00001298] libusb: debug [handle_bulk_completion] abnormal reap: last URB handled, reporting
[ 1.253784] [00001298] libusb: debug [usbi_handle_transfer_cancellation] detected timeout cancellation
[ 1.253790] [00001298] libusb: debug [disarm_timerfd]
[ 1.253793] [00001298] libusb: debug [usbi_handle_transfer_completion] transfer 0x80f85e8 has callback 0xb7782510
[ 1.253796] [00001298] libusb: debug [sync_transfer_cb] actual_length=0
[ 1.253805] [00001298] libusb: debug [libusb_free_transfer] transfer 0x80f85e8
ret :-7
interface : 0
[ 1.253837] [00001298] libusb: debug [libusb_close]
[ 1.253850] [00001298] libusb: debug [usbi_remove_pollfd] remove fd 9
[ 1.253878] [00001298] libusb: debug [libusb_exit]
[ 1.253897] [00001298] libusb: debug [libusb_exit] destroying default context



***@foxmail.com
Tim Roberts
2017-05-30 02:22:55 UTC
Permalink
On May 29, 2017, at 8:59 AM, ***@foxmail.com<mailto:***@foxmail.com> wrote:

Maybe i use the wrong functionshould be use libusb_control_transfer functionmy Ubuntu is at VMWareat BUS Hound i can see the data has been sendedbut my device is not respondi should find a real machine to test itfunction libusb_control_transferThe second parameter is 0x21The third parameter is 0x09The fourth parameter is variable 0x30xx How do i define it ?

You have to know these things, from the device specifications. A control transfer has a number of fields. bmRequestType is a byte, bRequest is a byte, wIndex is a word, and wValue is a word. You have to KNOW what values to provide in those fields.

Once you know the values, it's just a matter of plugging them into the libusb_control_transfer function.
—
Tim Roberts, ***@probo.com<mailto:***@probo.com>
Providenza & Boekelheide, Inc.
Loading...