LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Embedded & Single-board computer (https://www.linuxquestions.org/questions/linux-embedded-and-single-board-computer-78/)
-   -   Does usb support control (IN) transfer with wLength = 0? (https://www.linuxquestions.org/questions/linux-embedded-and-single-board-computer-78/does-usb-support-control-in-transfer-with-wlength-%3D-0-a-4175712144/)

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

smallpond 05-18-2022 08:03 AM

Even if its supported by the standard, I doubt anyone tests for it.

Doerthous 06-09-2022 08:38 PM

I noticed that the standard seem like not mention the situation. So, I guess this is an implement-dependent or undefined behavior. I will let go the problem.


All times are GMT -5. The time now is 09:57 AM.