commit | 0b381a81bed9051bfac7a4f5a16358182c7e7f9a | [log] [tgz] |
---|---|---|
author | Juan Cruz Viotti <juan@balena.io> | Wed Mar 20 11:34:41 2019 +0000 |
committer | Nathan Hjelm <hjelmn@me.com> | Fri Apr 05 09:28:52 2019 -0600 |
tree | 8d1308ea8e0e7ef246f98d3e28f662a2a3f28d5c | |
parent | 7997e322ab4b15661355ca3bab30366922709177 [diff] |
darwin: Retry IOCreatePlugInInterfaceForService on failure We have a case where a device might not be detected by libusb if we plug it after initializing the library. We were able to reproduce this issue pretty consistently on a Mac Mini and several MacBook Pros running very recent macOS versions (Mojave) using the Balena Fin board (https://www.balena.io/fin/). I don't know if this happens with other USB devices. Enabling debug output revealed the following: ``` [ 7.901582] [00004f07] libusb: debug [darwin_get_cached_device] finding cached device for sessionID 0x2a9b5279f04 [ 7.901764] [00004f07] libusb: debug [darwin_get_cached_device] matching sessionID 0x2a9b5279f04 against cached device with sessionID 0x17dbd029b6a [ 7.901798] [00004f07] libusb: debug [darwin_get_cached_device] matching sessionID 0x2a9b5279f04 against cached device with sessionID 0x1688763269f [ 7.901818] [00004f07] libusb: debug [darwin_get_cached_device] matching sessionID 0x2a9b5279f04 against cached device with sessionID 0x4c0aefaa [ 7.901831] [00004f07] libusb: debug [darwin_get_cached_device] matching sessionID 0x2a9b5279f04 against cached device with sessionID 0x0 [ 7.901845] [00004f07] libusb: debug [darwin_get_cached_device] caching new device with sessionID 0x2a9b5279f04 [ 7.903377] [00004f07] libusb: debug [darwin_device_from_service] could not set up plugin for service: out of resources [ 8.029152] [00000307] libusb: debug [libusb_get_device_list] ``` The "out of resources" error comes from `IOCreatePlugInInterfaceForService` which will apparently return this error if the `Start` method of the interface is not success (see https://github.com/opensource-apple/IOKitUser/blob/b80a5cbc0ebfb5c4954ef6d757918db0e4dc4b7f/IOCFPlugIn.c#L232). Retrying `IOCreatePlugInInterfaceForService` makes it work for me. Closes #542 Signed-off-by: Juan Cruz Viotti <juan@balena.io> Signed-off-by: Nathan Hjelm <hjelmn@me.com>
libusb is a library for USB device access from Linux, macOS, Windows, OpenBSD/NetBSD and Haiku userspace. It is written in C (Haiku backend in C++) and licensed under the GNU Lesser General Public License version 2.1 or, at your option, any later version (see COPYING).
libusb is abstracted internally in such a way that it can hopefully be ported to other operating systems. Please see the PORTING file for more information.
libusb homepage: http://libusb.info/
Developers will wish to consult the API documentation: http://api.libusb.info
Use the mailing list for questions, comments, etc: http://mailing-list.libusb.info
(Please use the mailing list rather than mailing developers directly)