From: Maik H�nig on
Hi,

I use the ReadfileEx function to get some data from the BulkUSB Sample
driver from ddk. I send ever 400 bytes via usb to the pc. Sometimes I
received less then 400 bytes. But on the next send thes lost data
comes first (for example in first send I got 336 Bytes and on the second 464
Bytes) but if I don�t do another sending these lost data don�t arrieve.

If I do a break at the time less data arrive. I see that the lost data is
already in the Buffer that I gave to readfileex but I don�t got a receive
event.

Can somebody help me?

Best Regards Maik H�nig


From: Sten Westerback (MVP SDK) on

"Maik H�nig" <maih(a)hrz.tu-chemnitz.de> wrote in message
news:el5r5l$t95$1(a)anderson.hrz.tu-chemnitz.de...
> Hi,
>
> I use the ReadfileEx function to get some data from the BulkUSB Sample
> driver from ddk. I send ever 400 bytes via usb to the pc. Sometimes I
> received less then 400 bytes. But on the next send thes lost data
> comes first (for example in first send I got 336 Bytes and on the second
> 464 Bytes) but if I don�t do another sending these lost data don�t
> arrieve.
>
> If I do a break at the time less data arrive. I see that the lost data is
> already in the Buffer that I gave to readfileex but I don�t got a receive
> event.
>
> Can somebody help me?

Maybe.
Are you using WaitForSingleObjectEx()? Note that for the callback to be
called your thread needs to be in a waitable state.

I haven't looked into that driver details. Do they claim it is supposed to
send messages and not just bytes?
My guess is that it works just like serial ports, sockets and bytesmode
pipes -- you can get anything from 0 to all available bytes in the Read that
fits within the timeout period of the source. Timeout again are driver
specific.

If you always send 400 bytes packages then you will have to ensure you get
that size of data by reading at least the missing number of bytes. With a
reasonable timeout you should probably also as well just use syncronous read
with ReadFile.

- Sten