From: Doron Holan [MS] on
USB io targets are a superset of the normal io targets. they add additional
formatting funcationality, but the sending and tracking of io remains the
same

d

--
Please do not send e-mail directly to this alias. this alias is for
newsgroup purposes only.
This posting is provided "AS IS" with no warranties, and confers no rights.


"KMDF_FW" <KMDFFW(a)discussions.microsoft.com> wrote in message
news:96CB90C0-806A-4013-ADD4-15EBAC7FC4C3(a)microsoft.com...
> Doron:
>
> Hi, thanks for taking time to answer my Q at late night :)
>
> And here are my further questions:
>
> - many KMDF API's are for IOTarget or UsbTarget. What's the difference
> between these
> two different kinds of targets?
> - I have tried the api WdfUsbTargetPipeWriteSynchronously to send the
> request and got the
> STATUS_INVALID_DEVICE_REQUEST error. And according to the docu, there are
> many
> things that can lead to this error. Is there a way we can get KMDF
> framework to isolate the
> source of problem beside manually verifying each of the potential source?
>
> Thanks.
>
> AT
>
> "Doron Holan [MS]" wrote:
>
>> to write data on the INT pipe, use WdfUsbTargetPipeWriteSynchronously (or
>> WdfUsbTargetPipeFormatRequestForWrite + WdfRequestSend).
>>
>> Typically you should only use WdfUsbTargetDeviceSendUrbSynchronously when
>> there is no built in KMDF routine that does what you need. In the case
>> of
>> sending a vendor command, you can do this
>>
>> WDF_USB_CONTROL_SETUP_PACKET setup;
>> WDF_USB_CONTROL_SETUP_PACKET_INIT_VENDOR(&setup, <insert your
>> parameters>);
>>
>> WdfUsbTargetDeviceSendControlTransferSynchronously(usbDevice, ...,
>> &setup,
>> ....);
>>
>> You do not need to break up the data, the usb core will do this for you,
>> just write the entire buffer in one shot.
>>
>> d
>>
>> --
>> Please do not send e-mail directly to this alias. this alias is for
>> newsgroup purposes only.
>> This posting is provided "AS IS" with no warranties, and confers no
>> rights.
>>
>>
>> "KMDF_FW" <KMDFFW(a)discussions.microsoft.com> wrote in message
>> news:97CE50BF-ED67-4223-8C23-E98255389C92(a)microsoft.com...
>> > Hi, I am writing a KMDF driver to send about 10K data to a USB device.
>> > However, the device only has a interrupt pipe, not bulk write pipe.
>> > does
>> > anyone know what is the right approach in sending the data over? I can
>> > use
>> > api
>> >
>> > WdfUsbTargetDeviceSendUrbSynchronously()
>> >
>> > to send an URB that contains a vendor command after I fill up the urb
>> > using
>> > its UrbControlVendorClassRequest substructure. But I do not think I can
>> > use
>> > the same approach in sending data data longer than 8 bytes. I read
>> > somewhere
>> > that in cases like this, we need to break up the data stream into
>> > smaller
>> > segments and send them over sequnentially. But I did not find any
>> > sample
>> > KMDF
>> > code in WDF kit for cases like this. The sample available show how to
>> > do
>> > read/write for device with ISOChronous or bulkwrite pipe present on the
>> > device.
>> >
>> > I would appreciate it if someone can share their thoughts on how to do
>> > this.
>> >
>> > AT
>>
>>
>>


From: Tim Roberts on
KMDF_FW <KMDFFW(a)discussions.microsoft.com> wrote:
>
>Here is another thing that I need to check with you regarding USB device.
>To verify the end point of the USB that I works on, I used the USB view from
>sdk yesterday, and it's shown that it's an IN pipe of INT type. The part of
>info that surprise me is the wMaxPacketSize of the device is 0. Does that
>mean the pipe can not be used for writing data? And there is only one
>endpoint/pipe for this device.

This means you are looking at "alternate setting zero". Interrupt and
isochronous pipes cause bandwidth to be reserved. If there isn't enough
bandwidth available, the pipe is not allowed to become active. Because of
that, the default interface ("alternate setting zero") is required to have
wMaxPacketSize = 0, so it can always be activated.

Your device will also have other alternate setttings that have
wMaxPacketsize > 0. You just have to choose one of those alternate
settings (using USB_FUNCTION_SELECT_INTERFACE) before you start reading
data.

However, I thought you said you wanted to SEND data? USB endpoints go in
one direction only. An "IN" pipe transfers from the device to the host. To
send data, you need to use an "OUT" pipe.
--
Tim Roberts, timr(a)probo.com
Providenza & Boekelheide, Inc.
From: KMDF_FW on
Doron:

As for using API WdfUsbTargetDeviceSendControlTransferSynchronously() to
send vendor
command to USB device, I tried it and got an error status of 0xc0000004,
which is the
STATUS_INFO_LENGTH_MISMATCH, where "The specified information record length
does not match the length required for the specified information class."
After checking the memory
descriptor that I used for the control transfer, I did not see an error. Do
you know how this error can be generated?

Thanks.

AT

"Doron Holan [MS]" wrote:

> to write data on the INT pipe, use WdfUsbTargetPipeWriteSynchronously (or
> WdfUsbTargetPipeFormatRequestForWrite + WdfRequestSend).
>
> Typically you should only use WdfUsbTargetDeviceSendUrbSynchronously when
> there is no built in KMDF routine that does what you need. In the case of
> sending a vendor command, you can do this
>
> WDF_USB_CONTROL_SETUP_PACKET setup;
> WDF_USB_CONTROL_SETUP_PACKET_INIT_VENDOR(&setup, <insert your parameters>);
>
> WdfUsbTargetDeviceSendControlTransferSynchronously(usbDevice, ..., &setup,
> ....);
>
> You do not need to break up the data, the usb core will do this for you,
> just write the entire buffer in one shot.
>
> d
>
> --
> Please do not send e-mail directly to this alias. this alias is for
> newsgroup purposes only.
> This posting is provided "AS IS" with no warranties, and confers no rights.
>
>
> "KMDF_FW" <KMDFFW(a)discussions.microsoft.com> wrote in message
> news:97CE50BF-ED67-4223-8C23-E98255389C92(a)microsoft.com...
> > Hi, I am writing a KMDF driver to send about 10K data to a USB device.
> > However, the device only has a interrupt pipe, not bulk write pipe. does
> > anyone know what is the right approach in sending the data over? I can use
> > api
> >
> > WdfUsbTargetDeviceSendUrbSynchronously()
> >
> > to send an URB that contains a vendor command after I fill up the urb
> > using
> > its UrbControlVendorClassRequest substructure. But I do not think I can
> > use
> > the same approach in sending data data longer than 8 bytes. I read
> > somewhere
> > that in cases like this, we need to break up the data stream into smaller
> > segments and send them over sequnentially. But I did not find any sample
> > KMDF
> > code in WDF kit for cases like this. The sample available show how to do
> > read/write for device with ISOChronous or bulkwrite pipe present on the
> > device.
> >
> > I would appreciate it if someone can share their thoughts on how to do
> > this.
> >
> > AT
>
>
>
From: Doron Holan [MS] on
did you initialize the setup packet using the INIT() routine? in general,
you can use KMDF's log (accessible via !wdfkd.wdflogdump) to see what the
error is, read http://blogs.msdn.com/doronh/archive/2006/07/31/684531.aspx
for more info and links on how to use this extension command

d

--
Please do not send e-mail directly to this alias. this alias is for
newsgroup purposes only.
This posting is provided "AS IS" with no warranties, and confers no rights.


"KMDF_FW" <KMDFFW(a)discussions.microsoft.com> wrote in message
news:A37F470D-1AD1-4502-BC7C-490220AA93A5(a)microsoft.com...
> Doron:
>
> As for using API WdfUsbTargetDeviceSendControlTransferSynchronously() to
> send vendor
> command to USB device, I tried it and got an error status of 0xc0000004,
> which is the
> STATUS_INFO_LENGTH_MISMATCH, where "The specified information record
> length
> does not match the length required for the specified information class."
> After checking the memory
> descriptor that I used for the control transfer, I did not see an error.
> Do
> you know how this error can be generated?
>
> Thanks.
>
> AT
>
> "Doron Holan [MS]" wrote:
>
>> to write data on the INT pipe, use WdfUsbTargetPipeWriteSynchronously (or
>> WdfUsbTargetPipeFormatRequestForWrite + WdfRequestSend).
>>
>> Typically you should only use WdfUsbTargetDeviceSendUrbSynchronously when
>> there is no built in KMDF routine that does what you need. In the case
>> of
>> sending a vendor command, you can do this
>>
>> WDF_USB_CONTROL_SETUP_PACKET setup;
>> WDF_USB_CONTROL_SETUP_PACKET_INIT_VENDOR(&setup, <insert your
>> parameters>);
>>
>> WdfUsbTargetDeviceSendControlTransferSynchronously(usbDevice, ...,
>> &setup,
>> ....);
>>
>> You do not need to break up the data, the usb core will do this for you,
>> just write the entire buffer in one shot.
>>
>> d
>>
>> --
>> Please do not send e-mail directly to this alias. this alias is for
>> newsgroup purposes only.
>> This posting is provided "AS IS" with no warranties, and confers no
>> rights.
>>
>>
>> "KMDF_FW" <KMDFFW(a)discussions.microsoft.com> wrote in message
>> news:97CE50BF-ED67-4223-8C23-E98255389C92(a)microsoft.com...
>> > Hi, I am writing a KMDF driver to send about 10K data to a USB device.
>> > However, the device only has a interrupt pipe, not bulk write pipe.
>> > does
>> > anyone know what is the right approach in sending the data over? I can
>> > use
>> > api
>> >
>> > WdfUsbTargetDeviceSendUrbSynchronously()
>> >
>> > to send an URB that contains a vendor command after I fill up the urb
>> > using
>> > its UrbControlVendorClassRequest substructure. But I do not think I can
>> > use
>> > the same approach in sending data data longer than 8 bytes. I read
>> > somewhere
>> > that in cases like this, we need to break up the data stream into
>> > smaller
>> > segments and send them over sequnentially. But I did not find any
>> > sample
>> > KMDF
>> > code in WDF kit for cases like this. The sample available show how to
>> > do
>> > read/write for device with ISOChronous or bulkwrite pipe present on the
>> > device.
>> >
>> > I would appreciate it if someone can share their thoughts on how to do
>> > this.
>> >
>> > AT
>>
>>
>>


From: KMDF_FW on
Doron:

Thanks for the useful link. And I did the initialization for the setup packet.
Later on I found the error that I encountered was caused by incorrect
data flow direction specified.

Meanwhile, I am wondering whether there is a corresponding kernel API
like Sleep() from user mode? I know there are timer object defined in kernel
mode, but it's kind of overkill for my situation as I just want to have
something
like Sleep(30) since my device is not able to process incoming data fast
enough.

Thanks.

AT
"Doron Holan [MS]" wrote:

> did you initialize the setup packet using the INIT() routine? in general,
> you can use KMDF's log (accessible via !wdfkd.wdflogdump) to see what the
> error is, read http://blogs.msdn.com/doronh/archive/2006/07/31/684531.aspx
> for more info and links on how to use this extension command
>
> d
>
> --
> Please do not send e-mail directly to this alias. this alias is for
> newsgroup purposes only.
> This posting is provided "AS IS" with no warranties, and confers no rights.
>
>
> "KMDF_FW" <KMDFFW(a)discussions.microsoft.com> wrote in message
> news:A37F470D-1AD1-4502-BC7C-490220AA93A5(a)microsoft.com...
> > Doron:
> >
> > As for using API WdfUsbTargetDeviceSendControlTransferSynchronously() to
> > send vendor
> > command to USB device, I tried it and got an error status of 0xc0000004,
> > which is the
> > STATUS_INFO_LENGTH_MISMATCH, where "The specified information record
> > length
> > does not match the length required for the specified information class."
> > After checking the memory
> > descriptor that I used for the control transfer, I did not see an error.
> > Do
> > you know how this error can be generated?
> >
> > Thanks.
> >
> > AT
> >
> > "Doron Holan [MS]" wrote:
> >
> >> to write data on the INT pipe, use WdfUsbTargetPipeWriteSynchronously (or
> >> WdfUsbTargetPipeFormatRequestForWrite + WdfRequestSend).
> >>
> >> Typically you should only use WdfUsbTargetDeviceSendUrbSynchronously when
> >> there is no built in KMDF routine that does what you need. In the case
> >> of
> >> sending a vendor command, you can do this
> >>
> >> WDF_USB_CONTROL_SETUP_PACKET setup;
> >> WDF_USB_CONTROL_SETUP_PACKET_INIT_VENDOR(&setup, <insert your
> >> parameters>);
> >>
> >> WdfUsbTargetDeviceSendControlTransferSynchronously(usbDevice, ...,
> >> &setup,
> >> ....);
> >>
> >> You do not need to break up the data, the usb core will do this for you,
> >> just write the entire buffer in one shot.
> >>
> >> d
> >>
> >> --
> >> Please do not send e-mail directly to this alias. this alias is for
> >> newsgroup purposes only.
> >> This posting is provided "AS IS" with no warranties, and confers no
> >> rights.
> >>
> >>
> >> "KMDF_FW" <KMDFFW(a)discussions.microsoft.com> wrote in message
> >> news:97CE50BF-ED67-4223-8C23-E98255389C92(a)microsoft.com...
> >> > Hi, I am writing a KMDF driver to send about 10K data to a USB device.
> >> > However, the device only has a interrupt pipe, not bulk write pipe.
> >> > does
> >> > anyone know what is the right approach in sending the data over? I can
> >> > use
> >> > api
> >> >
> >> > WdfUsbTargetDeviceSendUrbSynchronously()
> >> >
> >> > to send an URB that contains a vendor command after I fill up the urb
> >> > using
> >> > its UrbControlVendorClassRequest substructure. But I do not think I can
> >> > use
> >> > the same approach in sending data data longer than 8 bytes. I read
> >> > somewhere
> >> > that in cases like this, we need to break up the data stream into
> >> > smaller
> >> > segments and send them over sequnentially. But I did not find any
> >> > sample
> >> > KMDF
> >> > code in WDF kit for cases like this. The sample available show how to
> >> > do
> >> > read/write for device with ISOChronous or bulkwrite pipe present on the
> >> > device.
> >> >
> >> > I would appreciate it if someone can share their thoughts on how to do
> >> > this.
> >> >
> >> > AT
> >>
> >>
> >>
>
>
>