I am developing a driver based on the example located in examples\wdm\usbisoch for a USB device capable of isochronous data transfers.
When plugging/unplugging devices other than the device under development from the USB-system, the IRP's to the device under development fail.
Usbisoch:iso read irp failed status : 0xc000009c.
This message was send by the usbisoch driver from UsbIsocDevice::UsbIsocReadComplete routine.
Q: Are these failures due to CRC-errors in the iso-data packets ?
Since I need continuous transfer of data, I want to resubmit the failed URB, or create and submit a new URB. When I try to do this from the UsbIsocDevice::UsbIsocReadComplete routine the driver hangs. To create and (re)submit urbs I use the methods shown in the example.
Q: What do I need to do to ensure continuity of the data transfers. How do I safely queue (new) urbs after the failures described.
If the device is unplugged while an Isochronous URB is outstanding, there will be a failure code of 0xC000009C STATUS_DEVICE_DATA_ERROR. Since the device is not present, obviously no data transfer can take place. Since all of the URBs will fail with 0xc000009c, the outstanding request count will be decremented to zero. At this point the driver should receive IRP_MJ_PNP/IRP_MN_SURPRISE_REMOVAL under Windows 2000 and IRP_MJ_PNP/IRP_MN_REMOVE_DEVICE under Windows 98. If there are no open handles to the device, then the Destructor for the KPnpDevice subclass will be called and the driver will be unloaded. Then when the device is plugged in again, the driver will be loaded, and AddDevice and IRP_MJ_PNP/IRP_MN_START_DEVICE will be sent to the driver.
However, if the application does not close the handle to the device, then the driver is not unloaded and AddDevice will be called with a second DEVICE_OBJECT created by the system. Not a good situation.
So the application needs to receive notification of device removal and arrival and properly close handles (and NOT submit ReadFile and WriteFile requests!). This can be done by handling WM_DEVICE_CHANGE. This is documented by Microsoft. Once a removed device is detected in this message, Close the handle to the device. When the device arrival is detected, open a handle to the device and starting performing I/O.