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

Kinect serial number fallback to audio device serial number always throws warning on success. #657

Closed
kptrofatter opened this issue Jun 13, 2022 · 0 comments
Milestone

Comments

@kptrofatter
Copy link

If a Kinect camera device does not have a serial number, a fallback is to use the audio device serial number. However the logic in the fallback for testing the success of reading the audio device is broken and throws a warning on success.

The broken test is in src/usb_lib10.c at line 229.

src/usb_lib10.c:229
res = libusb_get_string_descriptor_ascii(audio_handle, audio_desc.iSerialNumber, serial, 256);
libusb_close(audio_handle);
if (res != 0)
{
FN_WARNING("Failed to get audio serial of K4W or 1473 device: %s\n", libusb_error_name(res));
}

The function libusb_get_string_descriptor_ascii() returns an int equal to the number of characters read on success, or a LIBUSB_ERROR code on failure [1]. The LIBUSB_SUCCESS code is 0 [2]. The code is trying to test for errors by looking for nonzero values, but in this case a positive value indicates success and a negative value indicates an error (all errors are given negative enum values). Thus the above code will always throw a warning on success and print "UNKNOWN" as an error string.

[1] https://libusb.sourceforge.io/api-1.0/group__libusb__desc.html#ga240aac96d92cb9f51e3aea79a4adbf42
[2] https://libusb.sourceforge.io/api-1.0/group__libusb__misc.html#gab2323aa0f04bc22038e7e1740b2f29ef

The code should be modified to test for a positive number of characters read (reading 0 characters successfully is not really a success). All that needs to be done is to change != into <=

src/usb_lib10.c:229
res = libusb_get_string_descriptor_ascii(audio_handle, audio_desc.iSerialNumber, serial, 256);
libusb_close(audio_handle);
if (res <= 0)
{
FN_WARNING("Failed to get audio serial of K4W or 1473 device: %s\n", libusb_error_name(res));
}

Regards,
Parker

@piedar piedar closed this as completed in b9cb6bd Sep 19, 2022
@piedar piedar added this to the next milestone Sep 19, 2022
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

No branches or pull requests

2 participants