Problem of using usbd-io

bridged with qdn.public.ddk.usb
Post Reply
sonic

Problem of using usbd-io

Post by sonic » Thu Feb 27, 2003 4:11 am

Hello all,

I would like to write a class driver for a force feed back driving wheel.
Data can be read from the wheel by modifying the class driver for mouse.
Since there is another endpoint for interrupt out, I establish another pipe
for interrupt out and add a function .write for sending data to the device.

In the write function, i call the usdb_io in the following way
.......
memcpy(wheel->ep_out_buf, init1, 15);
usbd_setup_interrupt( wheel->urb, URB_DIR_OUT, wheel->ep_out_buf, 15 );
if( status = usbd_io( wheel->urb, wheel->ep_out, NULL, wheel,
USBD_TIME_INFINITY ) ) {
return( status );
}

After returning from the above and the write function, there is no effect to
the device. In addition, I get blocked by calling the read function
afterward. What am I doing wrong? Thank you for advice.

Sonic

Henry Van Dyke

Re: Problem of using usbd-io

Post by Henry Van Dyke » Fri Feb 28, 2003 8:52 pm

sonic (sonic@sega.co.jp) wrote:
: Hello all,

: I would like to write a class driver for a force feed back driving wheel.
: Data can be read from the wheel by modifying the class driver for mouse.
: Since there is another endpoint for interrupt out, I establish another pipe
: for interrupt out and add a function .write for sending data to the device.

: In the write function, i call the usdb_io in the following way
: ......
: memcpy(wheel->ep_out_buf, init1, 15);
: usbd_setup_interrupt( wheel->urb, URB_DIR_OUT, wheel->ep_out_buf, 15 );
: if( status = usbd_io( wheel->urb, wheel->ep_out, NULL, wheel,
: USBD_TIME_INFINITY ) ) {
: return( status );
: }

Are you using a separate URB for the In and Out Endpoint ?




: After returning from the above and the write function, there is no effect to
: the device. In addition, I get blocked by calling the read function
: afterward. What am I doing wrong? Thank you for advice.

: Sonic

sonic

Re: Problem of using usbd-io

Post by sonic » Sat Mar 01, 2003 6:52 am

yes, I am using separate endpoints. wheel->ep_out and wheel->ep_int

"Henry Van Dyke" <henry@93.com> ¼¶¼g©ó¶l¥ó·s»D:b3oi72$ada$1@nntp.qnx.com...
sonic (sonic@sega.co.jp) wrote:
: Hello all,

: I would like to write a class driver for a force feed back driving
wheel.
: Data can be read from the wheel by modifying the class driver for mouse.
: Since there is another endpoint for interrupt out, I establish another
pipe
: for interrupt out and add a function .write for sending data to the
device.

: In the write function, i call the usdb_io in the following way
: ......
: memcpy(wheel->ep_out_buf, init1, 15);
: usbd_setup_interrupt( wheel->urb, URB_DIR_OUT, wheel->ep_out_buf, 15 );
: if( status = usbd_io( wheel->urb, wheel->ep_out, NULL, wheel,
: USBD_TIME_INFINITY ) ) {
: return( status );
: }

Are you using a separate URB for the In and Out Endpoint ?




: After returning from the above and the write function, there is no
effect to
: the device. In addition, I get blocked by calling the read function
: afterward. What am I doing wrong? Thank you for advice.

: Sonic

Henry Van Dyke

Re: Problem of using usbd-io

Post by Henry Van Dyke » Sat Mar 01, 2003 3:54 pm

sonic (sonic@sonicteam.co.jp) wrote:
: yes, I am using separate endpoints. wheel->ep_out and wheel->ep_int


My question was more related the allocated URB that gets passed in the
the calls to usbd_setup_interrupt() and usbd_io. Are you using the same
allocated URB for both interrupt In and Out transacations. (wheel->urb)



: "Henry Van Dyke" <henry@93.com> ¼¶¼g©ó¶l¥ó·s»D:b3oi72$ada$1@nntp.qnx.com...
: > sonic (sonic@sega.co.jp) wrote:
: > : Hello all,
: >
: > : I would like to write a class driver for a force feed back driving
: wheel.
: > : Data can be read from the wheel by modifying the class driver for mouse.
: > : Since there is another endpoint for interrupt out, I establish another
: pipe
: > : for interrupt out and add a function .write for sending data to the
: device.
: >
: > : In the write function, i call the usdb_io in the following way
: > : ......
: > : memcpy(wheel->ep_out_buf, init1, 15);
: > : usbd_setup_interrupt( wheel->urb, URB_DIR_OUT, wheel->ep_out_buf, 15 );
: > : if( status = usbd_io( wheel->urb, wheel->ep_out, NULL, wheel,
: > : USBD_TIME_INFINITY ) ) {
: > : return( status );
: > : }
: >
: > Are you using a separate URB for the In and Out Endpoint ?
: >
: >
: >
: >
: > : After returning from the above and the write function, there is no
: effect to
: > : the device. In addition, I get blocked by calling the read function
: > : afterward. What am I doing wrong? Thank you for advice.
: >
: > : Sonic
: >
: >

sonic

Re: Problem of using usbd-io

Post by sonic » Sat Mar 01, 2003 5:34 pm

oh, I am using same wheel->urb for both in and out transacations. Is it the
reason? Thank.

"Henry Van Dyke" <henry@93.com> ¼¶¼g©ó¶l¥ó·s»D:b3ql3r$k0f$1@nntp.qnx.com...
sonic (sonic@sonicteam.co.jp) wrote:
: yes, I am using separate endpoints. wheel->ep_out and wheel->ep_int


My question was more related the allocated URB that gets passed in the
the calls to usbd_setup_interrupt() and usbd_io. Are you using the same
allocated URB for both interrupt In and Out transacations. (wheel->urb)



: "Henry Van Dyke" <henry@93.com> ¼¶¼g©ó¶l¥ó·s»D
:b3oi72$ada$1@nntp.qnx.com...
: > sonic (sonic@sega.co.jp) wrote:
: > : Hello all,
:
: > : I would like to write a class driver for a force feed back driving
: wheel.
: > : Data can be read from the wheel by modifying the class driver for
mouse.
: > : Since there is another endpoint for interrupt out, I establish
another
: pipe
: > : for interrupt out and add a function .write for sending data to the
: device.
:
: > : In the write function, i call the usdb_io in the following way
: > : ......
: > : memcpy(wheel->ep_out_buf, init1, 15);
: > : usbd_setup_interrupt( wheel->urb, URB_DIR_OUT, wheel->ep_out_buf,
15 );
: > : if( status = usbd_io( wheel->urb, wheel->ep_out, NULL, wheel,
: > : USBD_TIME_INFINITY ) ) {
: > : return( status );
: > : }
:
: > Are you using a separate URB for the In and Out Endpoint ?
:
:
:
:
: > : After returning from the above and the write function, there is no
: effect to
: > : the device. In addition, I get blocked by calling the read function
: > : afterward. What am I doing wrong? Thank you for advice.
:
: > : Sonic
:
:

sonic

Re: Problem of using usbd-io

Post by sonic » Sun Mar 02, 2003 3:07 pm

It 's work now. Thank you.
By the way, I would like to ask why we need to a buffer allocated by
usbd_alloc() ? What 's the problem if not using it? Also, can we set the
usbd-io to be blocking?

"sonic" <sonic@sonicteam.co.jp> ¼¶¼g©ó¶l¥ó·s»D:b3qq43$jtj$1@inn.qnx.com...
oh, I am using same wheel->urb for both in and out transacations. Is it
the
reason? Thank.

"Henry Van Dyke" <henry@93.com> ¼¶¼g©ó¶l¥ó·s»D
:b3ql3r$k0f$1@nntp.qnx.com...
sonic (sonic@sonicteam.co.jp) wrote:
: yes, I am using separate endpoints. wheel->ep_out and wheel->ep_int


My question was more related the allocated URB that gets passed in the
the calls to usbd_setup_interrupt() and usbd_io. Are you using the same
allocated URB for both interrupt In and Out transacations. (wheel->urb)



: "Henry Van Dyke" <henry@93.com> ¼¶¼g©ó¶l¥ó·s»D
:b3oi72$ada$1@nntp.qnx.com...
: > sonic (sonic@sega.co.jp) wrote:
: > : Hello all,
:
: > : I would like to write a class driver for a force feed back driving
: wheel.
: > : Data can be read from the wheel by modifying the class driver for
mouse.
: > : Since there is another endpoint for interrupt out, I establish
another
: pipe
: > : for interrupt out and add a function .write for sending data to
the
: device.
:
: > : In the write function, i call the usdb_io in the following way
: > : ......
: > : memcpy(wheel->ep_out_buf, init1, 15);
: > : usbd_setup_interrupt( wheel->urb, URB_DIR_OUT, wheel->ep_out_buf,
15 );
: > : if( status = usbd_io( wheel->urb, wheel->ep_out, NULL, wheel,
: > : USBD_TIME_INFINITY ) ) {
: > : return( status );
: > : }
:
: > Are you using a separate URB for the In and Out Endpoint ?
:
:
:
:
: > : After returning from the above and the write function, there is no
: effect to
: > : the device. In addition, I get blocked by calling the read
function
: > : afterward. What am I doing wrong? Thank you for advice.
:
: > : Sonic
:
:



Henry Van Dyke

Re: Problem of using usbd-io

Post by Henry Van Dyke » Mon Mar 03, 2003 2:48 pm

sonic (sonic@sonicteam.co.jp) wrote:
: It 's work now. Thank you.

Thats great.

: By the way, I would like to ask why we need to a buffer allocated by
: usbd_alloc() ? What 's the problem if not using it?

usbd_alloc is used that the USB stack can do quick translations of the
client buffer from virtual to physical addresses. Physical addresses
for a client buffer are given to the USB chip for it put data coming
from a device.

Does using usbd_alloc cause you problems? ie. Are you required to use
memory from a specific memory pool ?


: Also, can we set the : usbd-io to be blocking?

We do not support this.

You can achieve this in your class driver by providing the neccessary
callback to usbd_io and using pthread_sleepon_wait() and in your callback
using pthread_sleepon_signal().

Have a look at the printer source for an example.

Henry



: "sonic" <sonic@sonicteam.co.jp> ¼¶¼g©ó¶l¥ó·s»D:b3qq43$jtj$1@inn.qnx.com...
: > oh, I am using same wheel->urb for both in and out transacations. Is it
: the
: > reason? Thank.
: >
: > "Henry Van Dyke" <henry@93.com> ¼¶¼g©ó¶l¥ó·s»D
: :b3ql3r$k0f$1@nntp.qnx.com...
: > > sonic (sonic@sonicteam.co.jp) wrote:
: > > : yes, I am using separate endpoints. wheel->ep_out and wheel->ep_int
: > >
: > >
: > > My question was more related the allocated URB that gets passed in the
: > > the calls to usbd_setup_interrupt() and usbd_io. Are you using the same
: > > allocated URB for both interrupt In and Out transacations. (wheel->urb)
: > >
: > >
: > >
: > > : "Henry Van Dyke" <henry@93.com> ¼¶¼g©ó¶l¥ó·s»D
: > :b3oi72$ada$1@nntp.qnx.com...
: > > : > sonic (sonic@sega.co.jp) wrote:
: > > : > : Hello all,
: > > : >
: > > : > : I would like to write a class driver for a force feed back driving
: > > : wheel.
: > > : > : Data can be read from the wheel by modifying the class driver for
: > mouse.
: > > : > : Since there is another endpoint for interrupt out, I establish
: > another
: > > : pipe
: > > : > : for interrupt out and add a function .write for sending data to
: the
: > > : device.
: > > : >
: > > : > : In the write function, i call the usdb_io in the following way
: > > : > : ......
: > > : > : memcpy(wheel->ep_out_buf, init1, 15);
: > > : > : usbd_setup_interrupt( wheel->urb, URB_DIR_OUT, wheel->ep_out_buf,
: > 15 );
: > > : > : if( status = usbd_io( wheel->urb, wheel->ep_out, NULL, wheel,
: > > : > : USBD_TIME_INFINITY ) ) {
: > > : > : return( status );
: > > : > : }
: > > : >
: > > : > Are you using a separate URB for the In and Out Endpoint ?
: > > : >
: > > : >
: > > : >
: > > : >
: > > : > : After returning from the above and the write function, there is no
: > > : effect to
: > > : > : the device. In addition, I get blocked by calling the read
: function
: > > : > : afterward. What am I doing wrong? Thank you for advice.
: > > : >
: > > : > : Sonic
: > > : >
: > > : >
: > >
: > >
: >
: >

sonic

Re: Problem of using usbd-io

Post by sonic » Mon Mar 03, 2003 3:59 pm

Thank you for kind and detail reply.
"Henry Van Dyke" <henry@93.com> ¼¶¼g©ó¶l¥ó·s»D:b3vpvb$r2i$1@nntp.qnx.com...
sonic (sonic@sonicteam.co.jp) wrote:
: It 's work now. Thank you.

Thats great.

: By the way, I would like to ask why we need to a buffer allocated by
: usbd_alloc() ? What 's the problem if not using it?

usbd_alloc is used that the USB stack can do quick translations of the
client buffer from virtual to physical addresses. Physical addresses
for a client buffer are given to the USB chip for it put data coming
from a device.

Does using usbd_alloc cause you problems? ie. Are you required to use
memory from a specific memory pool ?


: Also, can we set the : usbd-io to be blocking?

We do not support this.

You can achieve this in your class driver by providing the neccessary
callback to usbd_io and using pthread_sleepon_wait() and in your
callback
using pthread_sleepon_signal().

Have a look at the printer source for an example.

Henry



: "sonic" <sonic@sonicteam.co.jp> ¼¶¼g©ó¶l¥ó·s»D
:b3qq43$jtj$1@inn.qnx.com...
: > oh, I am using same wheel->urb for both in and out transacations. Is
it
: the
: > reason? Thank.
:
: > "Henry Van Dyke" <henry@93.com> ¼¶¼g©ó¶l¥ó·s»D
: :b3ql3r$k0f$1@nntp.qnx.com...
: > > sonic (sonic@sonicteam.co.jp) wrote:
: > > : yes, I am using separate endpoints. wheel->ep_out and
wheel->ep_int
:
:
: > > My question was more related the allocated URB that gets passed in
the
: > > the calls to usbd_setup_interrupt() and usbd_io. Are you using the
same
: > > allocated URB for both interrupt In and Out transacations.
(wheel->urb)
:
:
:
: > > : "Henry Van Dyke" <henry@93.com> ¼¶¼g©ó¶l¥ó·s»D
: > :b3oi72$ada$1@nntp.qnx.com...
: > > : > sonic (sonic@sega.co.jp) wrote:
: > > : > : Hello all,
: > > :
: > > : > : I would like to write a class driver for a force feed back
driving
: > > : wheel.
: > > : > : Data can be read from the wheel by modifying the class driver
for
: > mouse.
: > > : > : Since there is another endpoint for interrupt out, I establish
: > another
: > > : pipe
: > > : > : for interrupt out and add a function .write for sending data
to
: the
: > > : device.
: > > :
: > > : > : In the write function, i call the usdb_io in the following way
: > > : > : ......
: > > : > : memcpy(wheel->ep_out_buf, init1, 15);
: > > : > : usbd_setup_interrupt( wheel->urb, URB_DIR_OUT,
wheel->ep_out_buf,
: > 15 );
: > > : > : if( status = usbd_io( wheel->urb, wheel->ep_out, NULL, wheel,
: > > : > : USBD_TIME_INFINITY ) ) {
: > > : > : return( status );
: > > : > : }
: > > :
: > > : > Are you using a separate URB for the In and Out Endpoint ?
: > > :
: > > :
: > > :
: > > :
: > > : > : After returning from the above and the write function, there
is no
: > > : effect to
: > > : > : the device. In addition, I get blocked by calling the read
: function
: > > : > : afterward. What am I doing wrong? Thank you for advice.
: > > :
: > > : > : Sonic
: > > :
: > > :
:
:
:
:

Post Reply

Return to “qdn.public.ddk.usb”