Tim Roberts wrote:
“The device needs to be modified.” You make it sound so simple.
Haven’t you ever worked with a hardware team? Can’t you already
hear the response? “Well, it works on Linux. It’s a valid design
according to the spec. It’s a Windows problem, go make it work.”
Well, I have the luxury of not having to deal with hardware teams (or even customers) now, so, easy for me to say. However, I’ve been asked to do far worse (making an OID in my CDC ethernet driver that would issue CYCLE_PORT because the device would, in the words of the hardware guys, “get confused sometimes”).
Also, depends on what “spec” you’re referring to. If you mean the USB spec, well, refer to Hagen’s post. If you mean the spec that was shared between hong zhong and his hardware team, well, if the hardware guys say they are not going to terminate their transfers with a short packet, then he can only submit read URBs that are equal in size to the endpoint’s maximum packet size, as PeterGV suggests … then he’s guaranteed to hear every packet and get all his “dada”, but at what cost? I think we all know the answer…
Here’s my tale of two hardware teams faced with this same problem, one of them relatively smart, the other morons:
Back in the day, the Win2k version of usbser.sys would only issue PeterGV-style reads (that is, of the endpoint’s maximum size, 64 bytes for USB 1.1). It also had another critical flaw: if you sent it a zero-length packet, it would just hang forever and stop reading from the device (as far as I know this was never fixed).
So, both teams were faced with the situation where they needed to send exactly 64 bytes to the host. The smart team, knowing they couldn’t send 64 bytes + ZLP, but also knowing they needed to properly terminate their transfers, modified their code to send 63 bytes and then 1 byte. Done and done.
The moron team, however, just changed their code to just not send the ZLP at all. This worked fine, though, because Win2k usbser never read more than 64 bytes, so there was never any risk of a hung transfer.
Well, fast forward to the XP version of usbser.sys which issues 4K reads. Instantly, thousands of devices in the field immediately start failing in bizarre ways and pages like this[1] are born out of the utter confusion. Hacks are made where the Win2k usbser.sys is shipped for use on XP machines (renamed of course) because that’s the only flavor of the driver that will work. Customers complain that the throughput on the “hack” devices are terrible because tiny 64-byte reads are being issued, one at a time.
Then the hardware team ships another device with the ZLP added back in, but with the same PID. Now you have two different devices, indistinguishable by the OS, that can only work with one driver or the other.
I could go on, but the point is, it pays to follow the spec, early on… (duh.)
[1]
http://mark.cdmaforums.com/V710_USBSERSYS.htm