KMDF how to send vendor request to device

I’m going to go with Tamil.

mm

-----Original Message-----
From: xxxxx@lists.osr.com
[mailto:xxxxx@lists.osr.com] On Behalf Of xxxxx@osr.com
Sent: Friday, August 20, 2010 4:36 PM
To: Windows System Software Devs Interest List
Subject: RE:[ntdev] KMDF how to send vendor request to device





I would say Japanese…


NTDEV is sponsored by OSR

For our schedule of WDF, WDM, debugging and other seminars visit:
http://www.osr.com/seminars

To unsubscribe, visit the List Server section of OSR Online at
http://www.osronline.com/page.cfm?name=ListServer


!!! (<<< There’s a word in Tamil just there… did it actually get sent?)

Tamil?

Because of the complexity of the writing (it’s VERY pretty)? Thai is supposed to be difficult for this reason, as well.

From a casual review, Tamil doesn’t seem that difficult for a native Western speaker to pronounce. But, you know, that’s from watching 5 minutes of a Tamil lesson on YouTube.

Learning to speak Japanese is not that difficult. There is a standard
version which is the Tokyo version taught in all schools. In ordinary life
for native Japanese there are several different levels of politeness that
require living in the society as an insider to understand when to use what
version. There is position, gender, and current circumstances that require
a speaker to use different levels. There is an accent to Japanese but you
can get by without using the accents until you can hear them. The family
name of the founder of Panasonic appears to require 4 syllables but is
really said with 3.

Writing Japanese is difficult but not as much as Chinese.

wrote in message news:xxxxx@ntdev…
>
>
>


>
> I would say Japanese…
>
>
>

who can give me some advice to solve this problem.
thank you all my friend,now,I have a question.

I am beginner in wdf,and can not send vendor request. I send vendor request
through UsbBuildVendorRequest function. and the prototype is
void UsbBuildVendorRequest(
[in] PURB Urb,
[in] USHORT Function,
[in] USHORT Length,
[in] ULONG TransferFlags,
[in] UCHAR ReservedBits,
[in] UCHAR Request,
[in] USHORT Value,
[in] USHORT Index,
[in, optional] PVOID TransferBuffer,
[in, optional] PMDL TransferBufferMDL,
[in] ULONG TransferBufferLength,
[in] PURB Link
);

but i use wdf’s function WDF_USB_CONTROL_SETUP_PACKET_INIT_VENDOR and
WdfUsbTargetDeviceSendControlTransferSynchronously to send the vendor request
,but how to fill the controlSetupPacket,such as transfer length .my code is:

case IOCTL_USBSAMP_CUSTOM_COMMAND:

status=WdfRequestRetrieveInputBuffer(Request,10,&ioBuffer,&bufLength);

cmd=((UCHAR*)ioBuffer)[1];

WDF_REQUEST_SEND_OPTIONS_INIT(
&sendOptions,
WDF_REQUEST_SEND_OPTION_TIMEOUT
);

WDF_REQUEST_SEND_OPTIONS_SET_TIMEOUT(
&sendOptions,
DEFAULT_CONTROL_TRANSFER_TIMEOUT
);

WDF_USB_CONTROL_SETUP_PACKET_INIT_VENDOR(&controlSetupPacket,
BmRequestHostToDevice,
BmRequestToDevice,
cmd, // Request
0, // Value
0); // Index

status = WdfUsbTargetDeviceSendControlTransferSynchronously(
pDevContext->WdfUsbTargetDevice,
WDF_NO_HANDLE, // Optional WDFREQUEST
&sendOptions,
&controlSetupPacket,
NULL, // MemoryDescriptor
NULL); // BytesTransferred

if(!NT_SUCCESS(status)) {
UsbSamp_DbgPrint(1, (“UsbBuildVendorRequest Failed\n”));

}
status= STATUS_SUCCESS;
break;

in my appliction i use deviceiocontrol send control command ,and i use
bushound to see the packet that send to driver,but I find the SetupPacket’s
length=0. how to fill the length,such as wdm usbbuildvendorrequest function 's
TransferBufferLength.

OK, back on topic (sigh! The languages question was interesting…

OP… you’re not supplying a transfer buffer (you would do that with the MemoryDescriptor argument to WdfUsbTargetDeviceSendControlTransferSynchronously). So, the transfer buffer length SHOULD be zero. It HAS to be zero. Not only that, but the transfer buffer address too.

Not every vendor command HAS a buffer associated with it…

Peter
OSR

thank you Peter Viscarola,

you are right,I change the WdfUsbTargetDeviceSendControlTransferSynchronously function,the fourth parameter,and supplying a transfer buffer.

WDF_MEMORY_DESCRIPTOR_INIT_BUFFER(&memDesc,ioBuffer,bufLength);

status = WdfUsbTargetDeviceSendControlTransferSynchronously( pDevContext->WdfUsbTargetDevice,
WDF_NO_HANDLE, // Optional WDFREQUEST
&sendOptions,
&controlSetupPacket,
&memDesc, // MemoryDescriptor
&bufLength); // BytesTransferred

and solve the program

but i have a question ,my camera usual go well,but sometime usb bus RSET,and not receive any data.

Hmmmm… I don’t know. Probably a device issue?

Without a trace of activity on the USB bus I suspect that’s going to be hard to diagnose.

Once again let me advise people writing USB drivers to acquire and use a USB hardware analyzer. I *know* people think software analyzers are enough, and for SOME things they are… but the cost of a hardware analyzer can be really worth it, and in most situations quite affordable (from US$400 and up).

Peter
OSR

zhonghong200@163.com wrote:

who can give me some advice to solve this problem.
thank you all my friend,now,I have a question.

Doron and I have both answered this question. If you are not able to
understand the answers you are getting, you should tell us which parts
you are still confusing to you. Asking again will not improve the answers.


Tim Roberts, xxxxx@probo.com
Providenza & Boekelheide, Inc.