Bulk pipe question

This question has the same theme as Mr. Douglas’ post from Feb 21.
I am writing a device driver for a device that communicates with the host
using the usual two bulk endpoints.
I have set up a CBW in a buffer allocated using usbd_alloc(), and then set
up the URB using:

dev->bulkURB = usbd_alloc_urb( NULL );
usbd_setup_bulk( dev->bulkURB, URB_DIR_OUT, dev->buffer, size );
usbd_io( dev->bulkURB, dev->ep_out, NULL, dev, USBD_TIME_INFINITY );

// then I wait on the URB using:

pthread_sleepon_lock();
while (usbd_urb_status( dev->bulkURB, &status, &length ) == EBUSY)
pthread_sleepon_wait( urb );
pthread_sleepon_unlock();

Pretty straightforward, I thought.
The problem is this: The URB is constantly stuck “in progress”. I don’t know
why it is stuck on the USB stack. I have not been able to find a sniffer for
QNX and I don’t have a device like the Hitex USB Agent, so I am not exactly
sure what is going on. Is there something I am missing? Can anyone shed some
light on this? I am doing this in the insertion callback, as I am requesting
some device info. Is there a sniffer available anywhere?

Rob S <rob@altsoftware.com> wrote:

This question has the same theme as Mr. Douglas’ post from Feb 21.
I am writing a device driver for a device that communicates with the host
using the usual two bulk endpoints.
I have set up a CBW in a buffer allocated using usbd_alloc(), and then set
up the URB using:

dev->bulkURB = usbd_alloc_urb( NULL );
usbd_setup_bulk( dev->bulkURB, URB_DIR_OUT, dev->buffer, size );
usbd_io( dev->bulkURB, dev->ep_out, NULL, dev, USBD_TIME_INFINITY );

// then I wait on the URB using:

pthread_sleepon_lock();
while (usbd_urb_status( dev->bulkURB, &status, &length ) == EBUSY)
pthread_sleepon_wait( urb );
pthread_sleepon_unlock();

Pretty straightforward, I thought.
The problem is this: The URB is constantly stuck “in progress”. I don’t know
why it is stuck on the USB stack. I have not been able to find a sniffer for
QNX and I don’t have a device like the Hitex USB Agent, so I am not exactly
sure what is going on. Is there something I am missing? Can anyone shed some
light on this? I am doing this in the insertion callback, as I am requesting
some device info. Is there a sniffer available anywhere?

You can not wait for urb completion within a callback handler. You will
need to move the code that waits for the completion to another thread.