<html><head><meta http-equiv="Content-Type" content="text/html charset=us-ascii"></head><body style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space;" class=""><br class=""><div><blockquote type="cite" class=""><div class="">On Sep 30, 2019, at 12:05 AM, Anton Lundin <<a href="mailto:glance@acc.umu.se" class="">glance@acc.umu.se</a>> wrote:</div><div class=""><div class=""><blockquote type="cite" class=""><br class="">I honestly think that this is the right approach. I started staring at the code and<br class="">as expected the more I look the more I worry that I will get started and never<br class="">get finished. My challenge is that I don't understand the libusb data structures.<br class="">So which part of the libusb_context do I need to populate from the information <br class="">we get back from the JNI calls? That structure has quite a few members that I <br class="">have no idea what to do with. And reading the Linux code that initializes this <br class="">structure in the regular case really doesn't make me any smarter as just trying <br class="">to follow the code is making me break out in a rash...<br class=""></blockquote><br class=""><br class="">Yea, its a quite complex call chain, but I thin it can be simplified to<br class="">filling out struct libusb_device and calling usbi_connect_device on<br class="">those.<br class=""><br class="">UsbManager.getDeviceList() gives us enough to fill in the libusb_device<br class="">structs.<br class=""></div></div></blockquote><div><br class=""></div>Hmm - I hadn't planned to go that route. We already have the intent handling</div><div>that talks to us when a device is connected. And that gives us the one USB</div><div>device that we need to talk to - so why even get that list?</div><div><br class=""></div><div><div>Look at the code here:</div><div><a href="https://github.com/Subsurface-divelog/subsurface/blob/eecca6aab0a1970c7474df7ac8408d810a5d0bbd/android-mobile/src/org/subsurfacedivelog/mobile/SubsurfaceMobileActivity.java#L90" class="">https://github.com/Subsurface-divelog/subsurface/blob/eecca6aab0a1970c7474df7ac8408d810a5d0bbd/android-mobile/src/org/subsurfacedivelog/mobile/SubsurfaceMobileActivity.java#L90</a></div><div class=""><br class=""></div></div><div>So I have a UsbDevice structure already</div><div><a href="https://developer.android.com/reference/android/hardware/usb/UsbDevice" class="">https://developer.android.com/reference/android/hardware/usb/UsbDevice</a></div><div><br class=""></div><div>But then how do I go from that to fill the libusb_device?</div><div> <br class=""><blockquote type="cite" class=""><div class=""><div class=""><blockquote type="cite" class="">I have a branch for this but I don't recommend that anybody hope that I'll make<br class="">a lot of progress. I'm just dealing with way too many other issues that people<br class="">are equally desperately hoping for me to work on (like the UI issues and crashes<br class="">on Android that I think the latest beta finally addresses - which means I need to<br class="">make another release...)<br class=""></blockquote><br class="">Do you have a link to that branch?<br class=""><br class=""><a href="https://github.com/glance-/libusb/commit/50e2690f27a04011c4eae215d8b100851278e544" class="">https://github.com/glance-/libusb/commit/50e2690f27a04011c4eae215d8b100851278e544</a><br class="">Is basically the libusb patch needed, the rest of the code needed would<br class="">end up in the callback subsurface would provide.<br class=""><br class="">I had a half written variant of such code somewhere but I can't find it<br class="">right now.<br class=""></div></div></blockquote></div><div class=""><br class=""></div><div class="">I have something slightly more hacky in my version, but yeah, same idea.</div><div class="">It's that other half of the code that I'm struggling with.</div><div class=""><br class=""></div><div class="">I started this response email, wanting to send you a dump of what we already</div><div class="">log about the new device that's connected after we get the intent, but unfortunately </div><div class="">I can't seem to revive my my last FTDI dive computer. It had been super flaky the </div><div class="">last couple of times I played with it, but I now can't turn it on anymore.</div><div class=""><br class=""></div><div class="">If you connect your FTDI dive computer, we are logging a string representation</div><div class="">of the UsbDevice structure </div><div class=""><br class=""></div><div class=""><a href="https://github.com/Subsurface-divelog/subsurface/blob/eecca6aab0a1970c7474df7ac8408d810a5d0bbd/core/android.cpp#L179" class="">https://github.com/Subsurface-divelog/subsurface/blob/eecca6aab0a1970c7474df7ac8408d810a5d0bbd/core/android.cpp#L179</a></div><div class=""><br class=""></div><div class="">Do you have code that can convert that into a libusb_device structure? </div><div class="">Because if you have that code, I think I can piece the rest together. Well,</div><div class="">maybe. If I had a working FTDI dive computer to test with...</div><div class=""><br class=""></div><div class="">What's the cheapest FTDI dive computer one can buy these days? Or does </div><div class="">someone have one lying around that they don't need anymore? Like an old</div><div class="">style Suunto with a download cable?</div><div class=""><br class=""></div><div class="">/D</div></body></html>