ENOENT error from libusb_submit_transfer

View: New views
2 Messages — Rating Filter:   Alert me  

ENOENT error from libusb_submit_transfer

by jeffp :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Hello,


I am trying to do a bulk read from my device and get a ENOENT (no such file/directory)
when I call libusb_submit_transfer. I show my function and the gdb output below.
When the ioctl to submit the urb in os/linux_usbfs.c:1268 is called is when the errno
is set to ENOENT.

it looks to me like the relevant structures and their contents have reasonable values in them.
I can do control transfers to the device successfully, and bulk reads and writes to it using
the libusb 0.1 (synchronous apis), so I know the device works fine and Linux can successfully access it.


does anyone have any ideas or suggestions about why this may be occuring ?

thanks so much for any insight here

jeff p

---------

myFailingFunction()
{


  int                 ret;
  int                 val;
  int                 idx;

  char                dataBuf[MAX_SAMPLE_SIZE];
  unsigned char      *pBuffer;

  int                           idx;

  struct libusb_device_handle *handle;
  struct libusb_device        *device;
  struct libusb_device_handle *devHandle

 static struct libusb_transfer *bulkXfer = NULL;


  handle = libusb_open_device_with_vid_pid(NULL,0x1605,0x8040);
*******> this call suceeds and returns a non-NULL handle

    // vendor request to tell device to start collecting AtoD samples
    ret = libusb_control_transfer(handle,
                          USB_WRITE_TO_DEV,
                          BULK_ACQUIRE,
                          val,
                          idx,
                          pBuf, // unused
                          0,
                          TIMEOUT_1_SEC);

   ret = libusb_claim_interface(handle,0);
*******> this call suceeds and returns 0


   bulkXfer  = libusb_alloc_transfer(0);
*******> this call suceeds and returns non-NULL xfer struct


   libusb_fill_bulk_transfer(bulkXfer,
                             handle,
          (2 | LIBUSB_ENDPOINT_IN),  // also tried value of 6 for ep; that is the bulk read for my device
                             pBuf ,
                             numBytes,
                             bulkReadCallBack,
                             NULL,
                             0);
                                       
*******> this call suceeds


   ret = libusb_submit_transfer(bulkXfer);
*******> this call fails with -1 , and from gdb I see
         it is seeing a ENOENT in one of the ioctl calls made
         during the process


 } // end myFailingFunction



FROM GDB :
---------

.
.
.


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

breakpoint 6, 0xb7ea3000 in ioctl () from /lib/libc.so.6

(gdb) n
submit_bulk_transfer (itransfer=0x8051ba8, urb_type=3 '\003')

(gdb) where
#0  submit_bulk_transfer (itransfer=0x8051ba8, urb_type=3 '\003')
    at os/linux_usbfs.c:1268
#1  0xb7f5c3c4 in libusb_submit_transfer (transfer=0x8051bc4) at io.c:1005
#2  0x0804a89a in AIO_ADC_Usb_BulkAcquire (devIdx=1, pBuf=0xbf80c2dc "",

#3  0x0804b3af in main () at aiotest.c:430


(gdb) n
    at os/linux_usbfs.c:1268
<<<***********>>>
(gdb) p *dpriv
$1={fd = 9}
1267                    r = ioctl(dpriv->fd, IOCTL_USBFS_SUBMITURB, urb);
(gdb) p r
$27 = -1
<<*** ERRNO is set to ENOENT here after this ioctl call ***>>>

<<<***********>>>


<<<***********>>>
(gdb) p itransfer
$28 = (struct usbi_transfer *) 0x8051ba8
(gdb) p *itransfer
$29 = {num_iso_packets = 0, list = {prev = 0x8050050, next = 0x8050050},
  timeout = {tv_sec = 0, tv_usec = 0}, transferred = 0, flags = 0 '\0'}
<<<***********>>>


<<<********>>>
I moved up to the calling stack frame;
and below is from the stack frame of myFailingFunction()  --show above
where I called libusb_submit_transfer...


<<<************>>>
(gdb) p *bulkXfer
                                     

<<************>>>
(gdb) p *bulkXfer
$30 = {dev_handle = 0x8051a48, flags = 0 '\0', endpoint = 130 '\202',
  type = 2 '\002', timeout = 0, status = LIBUSB_TRANSFER_COMPLETED,
  length = 1000, actual_length = 0, callback = 0x8048ab8 <bulkReadCallBack>,
  user_data = 0x0, buffer = 0xbf80c2dc "", num_iso_packets = 0,
  iso_packet_desc = 0x8051bec}
<<<************>>>


<<<************>>>
(gdb) p *bulkXfer->dev_handle
$31 = {lock = {__data = {__lock = 0, __count = 0, __owner = 0, __kind = 0,
      __nusers = 0, {__spins = 0, __list = {__next = 0x0}}},
    __size = '\0' <repeats 23 times>, __align = 0}, claimed_interfaces = 1,
  list = {prev = 0x8050030, next = 0x8051a0c}, dev = 0x8052148,
  os_priv = 0x8051a70 "\037"}
<<<************>>>


<<<************>>>
(gdb) p *bulkXfer->dev_handle->dev
$32 = {lock = {__data = {__lock = 0, __count = 0, __owner = 0, __kind = 0,
      __nusers = 0, {__spins = 0, __list = {__next = 0x0}}},
    __size = '\0' <repeats 23 times>, __align = 0}, refcnt = 26,
  ctx = 0x8050008, bus_number = 1 '\001', device_address = 4 '\004',
  num_configurations = 1 '\001', list = {prev = 0x8050010, next = 0x8050010},
  session_data = 260, os_priv = 0x8052178 ""}
<<<************>>>
(gdb)
                                     

Re: ENOENT error from libusb_submit_transfer

by Daniel Drake :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

jeffp wrote:
>
> I am trying to do a bulk read from my device and get a ENOENT (no such
> file/directory)
> when I call libusb_submit_transfer. I show my function and the gdb output
> below.
> When the ioctl to submit the urb in os/linux_usbfs.c:1268 is called is when
> the errno
> is set to ENOENT.

This happens when the endpoint address is wrong. Judging from a comment
in your code, you are not too clear on which endpoint you should be
using. You need to include your device descriptors (lsusb -v) for people
to help you further.

Daniel


-------------------------------------------------------------------------
This SF.Net email is sponsored by the Moblin Your Move Developer's challenge
Build the coolest Linux based applications with Moblin SDK & win great prizes
Grand prize is a trip for two to an Open Source event anywhere in the world
http://moblin-contest.org/redirect.php?banner_id=100&url=/
_______________________________________________
Libusb-devel mailing list
Libusb-devel@...
https://lists.sourceforge.net/lists/listinfo/libusb-devel
LightInTheBox - Buy quality products at wholesale price!