Open diablodale opened 1 year ago
added commit that should resolve this issue.
⚠️🔬 The commit now uses the libusb bcdUSB
value during the boot process of usb_boot()
. If this is not wanted, it is an easy remove. FYI: my OAK-D and OAK-D-Lite sensors always report USB 2.00
while unbooted.
added commit that should resolve this issue.
The commit now uses the libusb bcdUSB value during the boot process of usb_boot(). If this is not wanted, it is an easy remove. FYI: my OAK-D and OAK-D-Lite sensors always report USB 2.00 while unbooted.
Awesome, Thanks! Yes, MX's BL is USB2.0 only, I assume this was the reason this wasn't an issue before.
Otherwise, on the why's, its both probably an refactor artifact that stayed behind
I see suspicious code regarding the global
bulk_chunklen
, the localbulk_chunklen
, andbcdusb
used as an param and local. Can you explain more about the intention -or- review these locations to see if the code is correct?bulk_chunklen
there is a global
bulk_chunklen
that has no atomic/mutex protecting it. https://github.com/luxonis/XLink/blob/457b23fb33e1146610e1a4e52defa7565046977a/src/pc/protocols/usb_host.cpp#L42It is assigned only one place in the codebase. Within
usb_open_device()
. It is never read. It has no reason to exist. This globalbulk_chunklen
is set to a value during the open of a specific device yet libusb can open devices in parallel. Technically, if something read this var (which nothing does) then the var changes as different devices with different chunks are opened in parallel. https://github.com/luxonis/XLink/blob/457b23fb33e1146610e1a4e52defa7565046977a/src/pc/protocols/usb_host.cpp#L555Then there is a local
bulk_chunklen
which hides the global with the same name. What is the relationship between the local and global vars with the same name? https://github.com/luxonis/XLink/blob/457b23fb33e1146610e1a4e52defa7565046977a/src/pc/protocols/usb_host.cpp#L573-L588bcdusb
bcdusb
starts as a local var inusb_boot()
. It is an UINT16_T set to the value-1
. This is suspicious signed/unsigned. It is never set or changed again. This is suspicious as it should therefore be a const/macro. https://github.com/luxonis/XLink/blob/457b23fb33e1146610e1a4e52defa7565046977a/src/pc/protocols/usb_host.cpp#L626This local
bcdusb
is passed as a param tosend_file()
https://github.com/luxonis/XLink/blob/457b23fb33e1146610e1a4e52defa7565046977a/src/pc/protocols/usb_host.cpp#L651in
send_file()
thisbcdusb
param is compared against hex 0x200 aka 512 decimal. This is suspicious since it will always be false because -1 stored in that uint16_t is(uint16_t)65535U
==>65535 < 512 = false
https://github.com/luxonis/XLink/blob/457b23fb33e1146610e1a4e52defa7565046977a/src/pc/protocols/usb_host.cpp#L578