darwin: fix reset device
authorNathan Hjelm <hjelmn@me.com>
Thu, 4 Apr 2019 18:02:25 +0000 (12:02 -0600)
committerNathan Hjelm <hjelmn@cs.unm.edu>
Fri, 5 Apr 2019 01:08:51 +0000 (19:08 -0600)
commita0b5d27fa7f2bba11965e2b70533f925a5772808
tree0e9089f36a5ed203b13cfe016857b3d9cc5a4a73
parent2a7372db54094a406a755f0b8548b614ba8c78ec
darwin: fix reset device

This commit fixes the backend of reset device to restore the state
of the device if possible. This fixes a bug introduced in
c14ab5fc4d22749aab9e3534d56012718a0b0f67. The previous commit
was necessary due to changes in the system USB stack that
essentially turned the ResetDevice function into a no-op. This
required libusb to move to USBDevuceReEnumerate to effectively
reset the device. The problem is that both the device handle and
libusb devices became invalid. This commit fixes the bug by
waiting for the re-enumeration to complete then 1) checking
whether the descriptors changed, 2) restoring the active
configuration, and 3) restoring claimed interfaces.

Closes #523

Signed-off-by: Nathan Hjelm <hjelmn@me.com>
libusb/os/darwin_usb.c
libusb/os/darwin_usb.h
libusb/version_nano.h