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:
- Increase kBufferSize to 512 but drive still hangs
- Change 0 to 2000 (timeout) for inPipe->IO method.
Result method returns - 0x2d6(// I/O Timeout)