Returning true would be the right behavior because if it returns false you'll lose the packets that were sent before the removal. If data was sent the host is expected not to lose them.
Any I'll double check to see if there is any host controller spec on this.
Please let me know the value of BytesReturned and the buffer. Is it reflecting the packets that were sent till the point of disconnect?
Yes, indeed, you are right. I have rechecked everything once again, driver works correctly - if I plug off USB cable during transfer in progress, it returns true + number of bytes actually read, and it is less than number of bytes requested. So I can see that device was suddenly disconnected.
Problem I described in my first post appears only when I power off device by switching it off, not by unplugging USB cable. It seems to be hardware related - when power disappears part of hardware that provides data "dies" faster than FX2 chip, so FX2 transfer all data requested but data is invalid. That is why I have got TRUE from driver and BytesReturned==BytesRequested but data were invalid.
The OS won't really know the difference between a powered-off device and a disconnected device. It will just realize that a device has been disconnected.
When you say you're getting invalid data, is the entire data invalid or just the last part. Did you hook up a CATC to correlate what is going on in the USB bus?