Quantcast

Errors writing to bulk-out endpoint

classic Classic list List threaded Threaded
2 messages Options
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Errors writing to bulk-out endpoint

Mark E Mason

Hello all,

 

I’m new to libusb, but not to USB programming in general. I have a device with 2 interfaces. The second interface has two bulk endpoints (one in and one out). I’ve coded up a test program that (after finding my device and claiming the interface) attempts to write 32 bytes of data to the OUT endpoint. I’m getting back an EPROTO (-71) error from the kernel when this happens. Any ideas? I’m sure I’m doing something simple wrong, but I’m a bit stumped at this point.

 

I’m using the top-of-tree libusb from git.

 

Code and debug fragments below:

 

    errno = libusb_claim_interface(handle, interface);

    if (errno) {

        fprintf(stderr, "could not claim management interface, errno = %d\n", errno);

        libusb_close(handle);

        libusb_exit(context);

        exit(1);

    }

 

    sprintf(buf, "Hello, World!");

    printf("sending '%s'\n", buf);

 

    errno = libusb_bulk_transfer(handle, out_endpoint, buf, 32, &transferred, 0);

    if (errno < 0) {

        fprintf(stderr, "could not send data, errno = %d\n", errno);

    }

 

From lsusb:

 

    Interface Descriptor:

      bLength                 9

      bDescriptorType         4

      bInterfaceNumber        1

      bAlternateSetting       0

      bNumEndpoints           2

      bInterfaceClass       254 Application Specific Interface

      bInterfaceSubClass      0

      bInterfaceProtocol      0

      iInterface              5

      Endpoint Descriptor:

        bLength                 7

        bDescriptorType         5

        bEndpointAddress     0x02  EP 2 OUT

        bmAttributes            2

          Transfer Type            Bulk

          Synch Type               None

          Usage Type               Data

        wMaxPacketSize     0x0040  1x 64 bytes

        bInterval               0

      Endpoint Descriptor:

        bLength                 7

        bDescriptorType         5

        bEndpointAddress     0x82  EP 2 IN

        bmAttributes            2

          Transfer Type            Bulk

          Synch Type               None

          Usage Type               Data

        wMaxPacketSize     0x0040  1x 64 bytes

        bInterval               0

 

mason@mason-desktop:~/Navigator/sdk/embedded/appl/navigator/src$ uname -a

Linux mason-desktop 2.6.35-22-generic #34-Ubuntu SMP Sun Oct 10 09:24:00 UTC 2010 i686 GNU/Linux

 

mason@mason-desktop:~/Navigator/sdk/embedded/appl/navigator/src$ sudo ./navigator

libusb:debug [libusb_init]

libusb:debug [find_usbfs_path] found usbfs at /dev/bus/usb

libusb:debug [op_init] bulk continuation flag supported

libusb:debug [op_init] found usb devices in sysfs

libusb:debug [usbi_add_pollfd] add fd 3 events 1

libusb:debug [usbi_io_init] using timerfd for timeouts

libusb:debug [usbi_add_pollfd] add fd 5 events 1

libusb:debug [libusb_get_device_list]

libusb:debug [sysfs_scan_device] scan usb1

libusb:debug [sysfs_scan_device] sysfs descriptors available

libusb:debug [sysfs_scan_device] bus=1 dev=1

libusb:debug [enumerate_device] busnum 1 devaddr 1 session_id 257

libusb:debug [enumerate_device] allocating new device for 1/1 (session 257)

libusb:debug [sysfs_scan_device] scan usb2

libusb:debug [sysfs_scan_device] bus=2 dev=1

libusb:debug [enumerate_device] busnum 2 devaddr 1 session_id 513

libusb:debug [enumerate_device] allocating new device for 2/1 (session 513)

libusb:debug [sysfs_scan_device] scan 2-2

libusb:debug [sysfs_scan_device] bus=2 dev=2

libusb:debug [enumerate_device] busnum 2 devaddr 2 session_id 514

libusb:debug [enumerate_device] allocating new device for 2/2 (session 514)

libusb:debug [sysfs_scan_device] scan 1-1

libusb:debug [sysfs_scan_device] bus=1 dev=9

libusb:debug [enumerate_device] busnum 1 devaddr 9 session_id 265

libusb:debug [enumerate_device] allocating new device for 1/9 (session 265)

libusb:debug [libusb_get_device_descriptor]

libusb:debug [libusb_get_device_descriptor]

libusb:debug [libusb_get_device_descriptor]

libusb:debug [libusb_get_device_descriptor]

libusb:debug [libusb_open] open 1.9

libusb:debug [usbi_add_pollfd] add fd 6 events 4

libusb:debug [libusb_kernel_driver_active] interface 1

libusb:debug [libusb_claim_interface] interface 1

sending 'Hello, World!'

libusb:debug [submit_bulk_transfer] need 1 urbs for new transfer with length 32

libusb:debug [handle_events] poll() 3 fds with timeout in 60000ms

libusb:debug [handle_events] poll() returned 1

libusb:debug [reap_for_handle] urb type=3 status=-71 transferred=0

libusb:debug [handle_bulk_completion] handling completion status -71 of bulk urb 1/1

libusb:debug [handle_bulk_completion] low level error -71

libusb:debug [disarm_timerfd]

libusb:debug [bulk_transfer_cb] actual_length=0

libusb:warning [do_sync_bulk_transfer] unrecognised status code 1

could not send data, errno = -99

libusb:debug [libusb_release_interface] interface 1

libusb:debug [libusb_close]

libusb:debug [usbi_remove_pollfd] remove fd 6

libusb:debug [libusb_unref_device] destroy device 1.1

libusb:debug [libusb_unref_device] destroy device 2.1

libusb:debug [libusb_unref_device] destroy device 2.2

libusb:debug [libusb_unref_device] destroy device 1.9

libusb:debug [libusb_exit]

libusb:debug [usbi_remove_pollfd] remove fd 3

libusb:debug [usbi_remove_pollfd] remove fd 5

 

I also turned on snooping in usbfs in the kernel, and got the following from dmesg:

 

[923718.512855] usb 1-1: opened by process 32492: navigator

[923718.512875] usb 1-1: usbdev_do_ioctl: GETDRIVER

[923718.512885] usb 1-1: usbdev_do_ioctl: CLAIMINTERFACE

[923718.512910] usb 1-1: usbdev_do_ioctl: SUBMITURB

[923718.512914] usb 1-1: userurb 08cc6238, ep2 bulk-out, length 32

[923718.512917] data: 48 65 6c 6c 6f 2c 20 57 6f 72 6c 64 21 00 00 00 64 fe 3d 00 02 00 00 00 00 00 00 00 e8 1d 24 00  Hello, World!...d.=...........$.

[923719.098605] usb 1-1: urb complete

[923719.098613] usb 1-1: userurb 08cc6238, ep2 bulk-out, actual_length 0 status -71

[923719.098738] usb 1-1: usbdev_do_ioctl: REAPURBNDELAY

[923719.098827] usb 1-1: usbdev_do_ioctl: RELEASEINTERFACE

mason@mason-desktop:~/Navigator/sdk/embedded/appl/navigator/src$


------------------------------------------------------------------------------
Nokia and AT&T present the 2010 Calling All Innovators-North America contest
Create new apps & games for the Nokia N8 for consumers in  U.S. and Canada
$10 million total in prizes - $4M cash, 500 devices, nearly $6M in marketing
Develop with Nokia Qt SDK, Web Runtime, or Java and Publish to Ovi Store
http://p.sf.net/sfu/nokia-dev2dev
_______________________________________________
Libusb-devel mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/libusb-devel
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Errors writing to bulk-out endpoint

Peter Stuge
Hi Mark,

Mark E Mason wrote:
> I'm new to libusb, but not to USB programming in general. I have a
> device with 2 interfaces. The second interface has two bulk
> endpoints (one in and one out). I've coded up a test program that
> (after finding my device and claiming the interface) attempts to
> write 32 bytes of data to the OUT endpoint. I'm getting back an
> EPROTO (-71) error from the kernel when this happens. Any ideas?

EPROTO from the kernel means that there was a low-level bus protocol
error. libusb-wise you're doing it right.

What happens in your device during this transfer? Can you tell if it
ACKs the packet?

Have you been able to perform the same transfer without libusb? If
yes, which system and how did that code look?


//Peter

------------------------------------------------------------------------------
Nokia and AT&T present the 2010 Calling All Innovators-North America contest
Create new apps & games for the Nokia N8 for consumers in  U.S. and Canada
$10 million total in prizes - $4M cash, 500 devices, nearly $6M in marketing
Develop with Nokia Qt SDK, Web Runtime, or Java and Publish to Ovi Store
http://p.sf.net/sfu/nokia-dev2dev
_______________________________________________
Libusb-devel mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/libusb-devel
Loading...