Re: WinUsb Control_Transfer Question by Doron
Doron
Tue Mar 11 23:55:53 CDT 2008
there is a direction indicated in the setup packet. if you indicate the
direction as IN you will be able to write to the buffer in your hw
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.
"Erwin School" <ErwinSchool@discussions.microsoft.com> wrote in message
news:B704110D-D660-4554-BB98-3503CF56C966@microsoft.com...
> But if you send the length of DataBuffer then the Control_Transfer
> function
> will send that many bytes from DataBuffer to the device. In return it will
> also receive the same amount of data from the device. But i only need to
> receive data and dont want to send data (exept for the setup packet
> ofcourse).
>
>
> "Doron Holan [MSFT]" wrote:
>
>> > bResult = WinUsb_ControlTransfer( WinUSB_Handle, SetupPacket,
>> > DataBuffer,
>> > 0,
>> > &bytesTransferred, NULL );
>> I am pretty sure that you need to pass the length of DataBuffer instead
>> of 0
>> and then you will get the results you want
>>
>> 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.
>>
>>
>> "Erwin School" <Erwin School@discussions.microsoft.com> wrote in message
>> news:65685EFC-7B77-4030-B2C0-7C4FB76D49F6@microsoft.com...
>> > Hi,
>> >
>> > I need to send a setuppacket (without extra data) to my usb device and
>> > the
>> > device must respond by sending data back (for example a getstatus
>> > request).
>> >
>> > Code example:
>> > WINUSB_SETUP_PACKET SetupPacket;
>> > SetupPacket.RequestType = 0xA1;
>> > SetupPacket.Request = 0x01;
>> > SetupPacket.Value = 0;
>> > SetupPacket.Index = 0;
>> > SetupPacket.Length = 8;
>> >
>> > bResult = WinUsb_ControlTransfer( WinUSB_Handle, SetupPacket,
>> > DataBuffer,
>> > 0,
>> > &bytesTransferred, NULL );
>> >
>> > When i look at the raw usb data with a USB protocol analyser the
>> > .Length
>> > member of the setuppacket is send as 0. It seems that the BufferLength
>> > value
>> > of WinUsb_ControlTransfer overwrites this value. Why? Now the device
>> > doesnt
>> > know that is must return data.
>> > When the BufferLength value of WinUsb_ControlTransfer is set to the
>> > value
>> > of
>> > Setuppacket.Length it is possible to receive data from the device but
>> > it
>> > the
>> > WinUsb_ControlTransfer function also sends useless data to the device.
>> >
>> > So i would like to know how to read data from the control pipe.
>> > Is it possible to use the WinUsb_Read_Pipe function to read from a
>> > control
>> > pipe? when i try it returns false and the error code is 87 (invalid
>> > value).
>> >
>> > Thanks,
>> > Erwin School.
>>
>>