usb-io problem

bridged with qdn.public.ddk.usb
Post Reply
David Raimond

usb-io problem

Post by David Raimond » Mon Nov 26, 2001 6:46 pm

Hi all,

I wrote a device driver for an usb scanner. I meet the "usual" problem
with usb-io callbacks. When I write a frame on the bulk pipe, the device
receives the command but it seems that my "usb-io callback" is never
called on the transfer completion. Many messages in this newsgroups
speak about this problem but I must recognize that I have some
difficulties in understanding the solution. I used the prn device driver
sample to develop my driver. This driver uses a callback to send a
signal (pthread_sleepon_signal) which unlocks the waiting function
(blocked on a pthread_sleepon_wait). Does it really work ? In Rob
message answer (03/13/2001) we can read :"You can not wait for urb
completion within a callback handler". I will be really happy to
understand what we can do or not ! Is there any solution for this
problem ? Can anyone explain to me how to unblock my pthread_sleepon_wait ?

Thanks for your help,
Regards,
David.


========================================================================
void CallbackWrite ( struct usbd_urb *pUrb,
struct usbd_pipe *pPipe,
void *pArg)
{
pthread_sleepon_lock ();
pthread_sleepon_signal (pUrb);
pthread_sleepon_unlock ();
return;
}


int tusb_writePipeQnx (...)
{
(...)
usbd_setup_bulk (pUrb, URB_DIR_OUT | URB_SHORT_XFER_OK, pAlloc,len);
usbd_io (pUrb, pPipe, CallbackWrite, NULL, USBD_TIME_DEFAULT))

// wait for call back completion
pthread_sleepon_lock ();
while (usbd_urb_status (pUrb, &uStatus, (_uint32 *)pdwLen) == EBUSY)
pthread_sleepon_wait (pUrb);
pthread_sleepon_unlock ();
(...)
}

Kevin Chiles

Re: usb-io problem

Post by Kevin Chiles » Fri Nov 30, 2001 1:00 pm

What stack are you using (devu-uhci or devu-ohci)? Are you working on
Neutrino or QNX4? What is the date/version of the stack?

It is hard tell what is happening with the small snipit of code you
posted. Has the URB that you are using for the bulk transfer been
used on a control transfer? There was a bug a while ago where
usbd_setup_bulk didn't clear a flag in the URB that would cause it
not to perform a callback. This bug can be worked-around by allocating
separate URBs for bulk and control transfers.

David Raimond <david.raimond@free.fr> wrote:
Hi all,

I wrote a device driver for an usb scanner. I meet the "usual" problem
with usb-io callbacks. When I write a frame on the bulk pipe, the device
receives the command but it seems that my "usb-io callback" is never
called on the transfer completion. Many messages in this newsgroups
speak about this problem but I must recognize that I have some
difficulties in understanding the solution. I used the prn device driver
sample to develop my driver. This driver uses a callback to send a
signal (pthread_sleepon_signal) which unlocks the waiting function
(blocked on a pthread_sleepon_wait). Does it really work ? In Rob
message answer (03/13/2001) we can read :"You can not wait for urb
completion within a callback handler". I will be really happy to
understand what we can do or not ! Is there any solution for this
problem ? Can anyone explain to me how to unblock my pthread_sleepon_wait ?
[sinp]

David Raimond

Re: usb-io problem

Post by David Raimond » Fri Dec 07, 2001 6:35 pm

Thanks Kevin for your answer, I posted a new message (05/12/01) to give
more information on my problem...
Regards,
David.


Kevin Chiles wrote:
What stack are you using (devu-uhci or devu-ohci)? Are you working on
Neutrino or QNX4? What is the date/version of the stack?

It is hard tell what is happening with the small snipit of code you
posted. Has the URB that you are using for the bulk transfer been
used on a control transfer? There was a bug a while ago where
usbd_setup_bulk didn't clear a flag in the URB that would cause it
not to perform a callback. This bug can be worked-around by allocating
separate URBs for bulk and control transfers.

David Raimond <david.raimond@free.fr> wrote:

Hi all,


I wrote a device driver for an usb scanner. I meet the "usual" problem
with usb-io callbacks. When I write a frame on the bulk pipe, the device
receives the command but it seems that my "usb-io callback" is never
called on the transfer completion. Many messages in this newsgroups
speak about this problem but I must recognize that I have some
difficulties in understanding the solution. I used the prn device driver
sample to develop my driver. This driver uses a callback to send a
signal (pthread_sleepon_signal) which unlocks the waiting function
(blocked on a pthread_sleepon_wait). Does it really work ? In Rob
message answer (03/13/2001) we can read :"You can not wait for urb
completion within a callback handler". I will be really happy to
understand what we can do or not ! Is there any solution for this
problem ? Can anyone explain to me how to unblock my pthread_sleepon_wait ?


[sinp]

Post Reply

Return to “qdn.public.ddk.usb”