xxxxx@rajko.info wrote:
Hello i have a FT2232H based device, and so far, it’s quite speedy, however, now i have a need to poll the device it’s connected to, and as soon as a bit flips, continue with some action… I am using the FTDI D2XX drivers, and the latency i get from issuing a read command to the device(a few bytes), then reading back one byte (or a bit more) is from 0.8ms-3ms according to QueryHighPerformanceCounter. For this operation, this polling needs to be done a lot, and thus these latencies are high and limits the operation to something like 100KB/s. To have actual proper speed, the polling latency should be somewhere like 0.3ms, since the operation takes from 0.8ms to 1.6ms to actually complete.
So, you have to do a “write” followed by a “read”? The only way to make
that faster is to use overlapped I/O to submit the two requests at the
same time.
USB is not a real-time bus. It’s all scheduled in advance – the host
controller driver schedules all the transfers for a frame, then submits
it to the hardware. Once the frame is gone, it starts scheduling the
next frame. If you submit the write, then wait for that to complete,
and then submit the read, then the two requests cannot be handled in the
same frame. A frame is 1ms.
So, in a very real sense, your device is simply a poor candidate for
USB. It wasn’t designed for this kind of operation. Streaming works
well, but round-trips are especially painful.
Are you talking to the FTDI driver directly, or are you using their
library? If you are making ioctl calls to the driver directly, you can
try using overlapped I/O to submit them both at once. But if you have
to go through their library, it might not support this.
In order to improve this significant drawback, i am ready to write a KMDF usb driver, however, i am not sure if it will allow me to send and receive individual microframes in usb high speed mode…
Well, not really; USB doesn’t work that way. The driver submits URBs,
and the host controller worries about the scheduling.
If you can figure out their packet format, you don’t actually need to
write a driver. You can use WinUSB. It supports overlapped I/O.
The usb device supports max 512 byte IN/OUT transfers in high speed mode, and it reports itself as a BULK device.
All high-speed bulk pipes have 512 byte packets, although I’m not sure
the FT2232 devices actually support that much. They’re pretty
bare-boned devices.
–
Tim Roberts, xxxxx@probo.com
Providenza & Boekelheide, Inc.