IOUSBHostPipe::IO hangs on data greater than 256 bytes

We are developing driver for our USB device. We've implemented commutation using IOUSBHostPipe::IO and it perfectly works for data packets that less than 256 bytes. However it hangs when reply from USB device is about 512 bytes. We see 0x2ed // device not responding error when we unplug our device and driver is stopped.

Here is our code for setup:

constexpr uint32_t kOutEndpointAddress = 1;
constexpr uint32_t kInEndpointAddress = 129;

constexpr uint16_t kBufferSize = 256;
.....
struct ForcePlateDriver_IVars {
....
    IOUSBHostPipe            *inPipe;
    IOBufferMemoryDescriptor *inData;
    uint16_t                  maxPacketSize;
};
.....
    ret = ivars->interface->CopyPipe(kInEndpointAddress, &ivars->inPipe);

    ret = ivars->interface->CreateIOBuffer(kIOMemoryDirectionIn,
                                           ivars->maxPacketSize,
                                           &ivars->inData);

We use following code for reading data from USB device:

    uint32_t bytesTransferred = 0;

    ret = ivars->inPipe->IO(
                            ivars->inData,
                            ivars->maxPacketSize,
                            &bytesTransferred,
                            0);

What we tried:

  1. Increase kBufferSize to 512 but drive still hangs
  2. Change 0 to 2000 (timeout) for inPipe->IO method.

Result method returns - 0x2d6(// I/O Timeout)

Answered by myurik2 in 728979022

It looks like it was false alarm. We found issue in our code with wrong buffer size. inPipe->IO works as expected

Accepted Answer

It looks like it was false alarm. We found issue in our code with wrong buffer size. inPipe->IO works as expected

IOUSBHostPipe::IO hangs on data greater than 256 bytes
 
 
Q