Closed idoybh closed 1 year ago
having this same issue I think I almost have a solution (which is less hacky than the existing code as well!) basically we have to access the GUsbDevice private data, then the libusb_device_handle, the the os_priv variable stored in that
having this same issue I think I almost have a solution (which is less hacky than the existing code as well!) basically we have to access the GUsbDevice private data, then the libusb_device_handle, the the os_priv variable stored in that
oh that's nice. yea, I saw that private struct in the libgusb diff
Honestly it was just a matter of time until that piece of code broke, however it was the only way I found to obtain the device FD without introducing all sorts of other issues. Anyway, I'll very likely just adjust the offsets / field names tomorrow, unless @Etaash-mathamsetty's solution is a cleaner one (if I understood correctly, it's the exact same thing, as my offsets basically go through the exact chain of references / fields they describe)
solution goes something like this:
GUsbDevicePrivate* usb_dev_private = (GUsbDevicePrivate*)(usb_dev + g_type_class_get_instance_private_offset(usb_dev->parent_instance.g_type_instance.g_class));
tdev->usb_fd = usb_dev_private->handle->os_priv;
Oh cool, I didn't know that that function existed. I'll definetly use it, thanks! Also, aren't libusb's private structures only defined in internal headers, and as such inaccesible to us?
Oh cool, I didn't know that that function existed. I'll definetly use it, thanks! Also, aren't libusb's private structures only defined in internal headers, and as such inaccesible to us?
yeah that's true, that's what I am trying to fix, I re defined them in the code to see if it would work not working atm you can get more code here: https://android.googlesource.com/platform/external/libusb/+/refs/heads/o-preview-2/libusb/os/linux_usbfs.c
I ended up with this code, we just have to find out what magic_number
is:
GUsbDevicePrivate* usb_dev_private = (GUsbDevicePrivate*)(usb_dev + g_type_class_get_instance_private_offset(usb_dev->parent_instance.g_type_instance.g_class));
tdev->usb_fd = ((struct linux_device_handle_priv *)(usb_dev_private->handle + magic_number))->fd;
any updates on this?
I should have pushed a commit (cb0db2e65afe7e0f525133e0fd6e771eaca73555) adding compatibility just now, but I don't have a device with me right now to test if it works
it seems to be working
Oh good, if @idoybh can confirm this as well I'll close this issue now.
Oh good, if @idoybh can confirm this as well I'll close this issue now.
Shouldn't the check for version check if the version is greater or equal to 0.4.0 rather than checking if it's exactly 0.4.0? Or is that function already doing that? I can confirm new HEAD works just fine at runtime and build.
Oh good, if @idoybh can confirm this as well I'll close this issue now.
Shouldn't the check for version check if the version is greater or equal to 0.4.0 rather than checking if it's exactly 0.4.0? Or is that function already doing that? I can confirm new HEAD works just fine at runtime and build.
The macro should only check the major version number for an exact match, the minor version can be larger. Also, am gonna close this now, thanks for reporting!
Thank you @Popax21.
So we'll have to stay alert for 0.5 haha
Thank you @Popax21.
So we'll have to stay alert for 0.5 haha
this is a more permanent solution, unless they change something about the private data in 0.5 then it should still work
Hello again, After updating from libgusb version 0.3.10 to 0.4.0 the driver crashes with: fprintd.log tudor.log coredump.log
Build fails as well with:
when downgrading back to 0.3.10 everything works properly again.
Thank you, again, for this driver 👍🏾