PORTS Forum
Ports and Interfaces => USB => Topic started by: lcpoon on June 06, 2015, 09:40:29 am
-
I am not sure if I setuppacket information is correct or not:
Public Function GetEndpointDescriptor_new() As String
Dim setuppacket As WINUSB_SETUP_PACKET
Dim buffer As Byte() = New Byte(255) {}
Dim transfered As UInteger
Dim success As Boolean
setuppacket.RequestType = CByte(Hex2Dec("80"))
setuppacket.Request = 6
setuppacket.Value = CUShort(CInt(Hex2Dec("500")))
setuppacket.Index = CUShort(0)
setuppacket.Length = CUShort(7)
success = WinUsb_ControlTransfer(myDevInfo.winUsbHandle, setuppacket, buffer, CUInt(buffer.Length), transfered, IntPtr.Zero)
*Hex2Dec = Long.Parse(junk, Globalization.NumberStyles.AllowHexSpecifier)
-
My device endpoint descriptor information:
===>Endpoint Descriptor<===
bLength: 0x07
bDescriptorType: 0x05
bEndpointAddress: 0x01 -> Direction: OUT - EndpointID: 1
bmAttributes: 0x02 -> Bulk Transfer Type
wMaxPacketSize: 0x0200 = 0x200 max bytes
bInterval: 0x01
===>Endpoint Descriptor<===
bLength: 0x07
bDescriptorType: 0x05
bEndpointAddress: 0x81 -> Direction: IN - EndpointID: 1
bmAttributes: 0x02 -> Bulk Transfer Type
wMaxPacketSize: 0x0200 = 0x200 max bytes
bInterval: 0x01
---===>Full Configuration Descriptor<===---
===>Configuration Descriptor<===
bLength: 0x09
bDescriptorType: 0x02
wTotalLength: 0x0020 -> Validated
bNumInterfaces: 0x01
bConfigurationValue: 0x01
iConfiguration: 0x00
bmAttributes: 0x80 -> Bus Powered
MaxPower: 0xFA = 500 mA
===>Interface Descriptor<===
bLength: 0x09
bDescriptorType: 0x04
bInterfaceNumber: 0x00
bAlternateSetting: 0x00
bNumEndpoints: 0x02
bInterfaceClass: 0xFF -> Interface Class Unknown to USBView
bInterfaceSubClass: 0xFF
bInterfaceProtocol: 0xFF
iInterface: 0x00
-
Most bulk endpoints set bInterval = 0.
wMaxPacketSize = 0x200 assumes high speed or higher.
What problem are you seeing?
-
success = WinUsb_ControlTransfer(myDevInfo.winUsbHandle, setuppacket, buffer, CUInt(buffer.Length), transfered, IntPtr.Zero) failed to read the data at all.
-
What error message did the API call return?
https://msdn.microsoft.com/en-us/library/system.runtime.interopservices.marshal.getlastwin32error%28v=vs.100%29.aspx
Use a protocol analyzer or whatever debugging tools you have to find out if the device received the setup packet and if firmware detected the request, placed the requested data in the endpoint's buffer, and armed the endpoint to return the data in the request's Data stage.
-
Found the answer where I have to use this:
setuppacket.RequestType = CByte(Hex2Dec("80"))
setuppacket.Request = 6
setuppacket.Value = CUShort(CInt(Hex2Dec("200")))
setuppacket.Index = CUShort(0)
setuppacket.Length = CUShort(255)
success = WinUsb_ControlTransfer(myDevInfo.winUsbHandle, setuppacket, buffer, CUInt(buffer.Length), transfered, IntPtr.Zero)
From USB 2.0: A request for a configuration descriptor returns the configuration descriptor, all interface descriptors, and endpoint descriptors for all of the interfaces in a single request.
-
Glad you got it working. Thanks for reporting what you found.