This project is read-only.

usb_DataReceived Non Functional?

Jan 4, 2013 at 10:54 AM

In usb_DataReceived, byteCount is declared as an integer of -1 but it is never set to anything before checked in the if statement below. The if statement checks of this bytecount is > 0 then calls connectionlost because this was never set to anything.

Is BytesToRead supposed to by byteCount?

Is this USB functionality tested?

 

Mar 27, 2013 at 3:27 PM
Edited Mar 28, 2013 at 1:38 PM
I've just encountered the same problem, sadly I didn't notice your post but at least I've only lost a little time on it.

I've corrected, if that's the word, by adding
byteCount = bytesRead;
so that the code is now
                        buffer = (byte[])ar.AsyncState;
                        int bytesRead = _stream.EndRead(ar);
                        byteCount = bytesRead;
                        if (bytesRead > 0)
although I've now encountered a new problem. On sending the first command it sends the response to the data received event twice.