Doerthous |
05-15-2022 08:28 AM |
Does usb support control (IN) transfer with wLength = 0?
Recently, I'm learning usb protocol with libusb and linux gadget (g_zero). When I do the following control transfer, the usb device just stucks.
Code:
libusb_control_transfer(devh
0xC0, // bRequestType (IN, device to host)
0x5C, // bRequest
0x0000, // wValue
0x0000, // wIndex
NULL, // buffer
0, // buffer length
1000 // timeout
)
I also use a usb analyzer to monitor the usb packets, it show as follow:
Code:
Setup Stage:
SETUP Packet
DATA0 Packet: c0 5c 00 00 00 00 00 00
ACK Packet
Data Stage:
nothing here, then follow immediately with
Status Stage:
OUT Packet
DATA1 Packet (length: 0)
NAK Packet
PING Packet // then PING Packet infinitely
After that, I search the usb 2.0 specification and found (in ch 8.5.3) that the specification describes only three type of control transfer:
Code:
Setup Data Status
Stage Stage Stage
/---------\ /------------------------------------\ /-------\
Control <Setup (0)> <Out (1)> <Out (0)> ... <Out (0/1)> <In (1)>
Write DATA0 DATA1 DATA0 DATA0/1 DATA1
Control <Setup (0)> <In (1)> <In (0)> ... <In (0/1)> <Out (1)>
Read DATA0 DATA1 DATA0 DATA0/1 DATA1
Setup Status
Stage Stage
/---------\ /-------\
No-Data <Setup (0)> <IN (1)>
Control DATA0 DATA1
So I guess maybe usb doesn't support Ctrl-IN-0 transfer?
https://stackoverflow.com/questions/...with-wlength-0
|