[tuxdroid-user] usb_read_TuxDroid() correctness
Status: Beta
Brought to you by:
ks156
From: neimad <ror...@gm...> - 2007-06-04 20:27:57
|
I have comments and questions about usb_read_TuxDroid(): (1) It uses a for loop to read data from USB, and tampers with the loop index within the loop's body. This is generally not a good idea; a while loop would be preferable in such a case. (2) Where does the loop's upper bound (5) come from ? Does it have anything to do with TUX_RECV_LENGTH, which also happens to be 5 (but soon to be fixed) ? (3) The documentation[1] of usb_interrupt_read() doesn't say much, but I guess it may read fewer bytes than requested, and even return 0 in case of a timeout. This means that the loop could have read data in several iterations and still reset the loop index to 0. [1] http://libusb.sourceforge.net/doc/function.usbinterruptread.html I don't get what this is supposed to do. If this code is indeed correct, it should be rewritten and/or commented. Damien |