xxxxx@gmail.com wrote:
Sorry for my wrong information. Bulk endpoint max size is 512 Bytes. am sending 564 bytes buffer in the URB so as Tim said earlier Host driver is splitting it for me.
now i have small doubt…
Which is optimal, Sending a large buffer of non-multiple of 512 in my case 564 bytes to host and let host bother of spliting or Client split the buffer with 512 bytes?
This isn’t really the right question to ask. I thought I asked this
before, but perhaps it wasn’t clear.
There are two ways that your device could send its 564 byte buffers.
Note here that I am talking about the DEVICE, not about your driver.
The device doesn’t *know* how much data your driver is requesting.
That’s not how USB works. The device is just told “transmit now”, and
the DEVICE decides how the data will be sent.
One way would be as alternating packets of 512 and 52:
pkt 0: 512 bytes
pkt 1: 52 bytes, first buffer complete
pkt 2: 512 bytes
pkt 3: 52 bytes, second buffer complete
etc.
The other way would be as a steady stream:
pkt 0: 512 bytes (start of first buffer)
pkt 1: 512 bytes (last 52 bytes of first buffer, first 460 of second
buffer)
pkt 2: 512 bytes (last 104 of second buffer, first 408 of third buffer)
pkt 3: 512 bytes (last 156 of third buffer, first 356 of fourth buffer)
The difference is CRITICALLY important. If the device uses the first
method, then you must submit multiple URBs of 564 bytes. You could try
to submit a larger URB, but the transfer would terminate as soon as the
short packet arrived. Anything less than the maximum packet size
terminates a USB transfer.
If the device uses the second method, as I suspect it does, then you
CANNOT use URBs of 564 bytes. You MUST use URBs that are a multiple of
512 bytes, and divide them into 564-byte buffers in your driver. If you
do not use a multiple of 512, you will get the
USBD_STATUS_BABBLE_DETECTED error.
–
Tim Roberts, xxxxx@probo.com
Providenza & Boekelheide, Inc.