Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix fake UVC device serial generated from VID/PID #2

Closed
wants to merge 1 commit into from

Conversation

Windwoes
Copy link
Member

@Windwoes Windwoes commented Apr 14, 2020

This patch fixes the fake serial number generation using PID/VID for UVC devices.

The way the SDK identifies UVC devices is by their serial number. But if the UVC device doesn't have a serial, the SDK makes up a fake one from the PID and VID USB metadata. However, this latter functionality was broken, because the calls to get PID and VID were returning "0" and thus the fake serial number was "0:0". What's more, although UVC devices could be correctly detected (or have their absence detected) when their serial was "0:0", when you go to actually USE it (I tested with the Vuforia webcam example and my own webcam example for EasyOpenCV) it would not work correctly.

This patch fixes the PID and VID being reported as "0" by replacing the calls to native C++ code to get those values with calls to the Android Java API. The heart of the change is the diff for the LibUsbDevice.java file. The rest of the changes were simply things that had to be changed as the result of the change to LibUsbDevice.java. Some legacy code (which was already disabled thanks to a boolean flag) had to be commented out, but that really shouldn't be a big deal given that it was not actually being used at all....

I was testing with my UVC-compatible microscope, which does not report a serial number. Before the change it was detected as "0:0". After the change, it was detected as "7758:265".

Results when running Vuforia Webcam sample before change (no preview and/or crash), and after the change (works great!):

Untitled-1

@Windwoes
Copy link
Member Author

Relevant SDK issue: ftctechnh/ftc_app#638

@Windwoes
Copy link
Member Author

Relevant issue from my EasyOpenCV library: OpenFTC/EasyOpenCV#3

@Lunerwalker2
Copy link

Lunerwalker2 commented May 4, 2020

Yay! My webcam will work! ;)

@Windwoes Windwoes closed this May 26, 2020
@Windwoes Windwoes deleted the uvcSerialNumberFix branch December 18, 2020 18:26
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants