Using user-space USB drivers: Part 7
After I wrote yesterday's post, I decided to give it one last shot and at least try and implement the workaround. And guess what, it worked! I can successfully connect to a TUSB3410 chip on macOS using Node.js, update its firmware and read data from the device it's connected to. Woot!
I have to say, being able to finally use Wireshark on macOS with High Sierra made things a lot easier. Without USB traces from Wireshark I wouldn't have guessed that the device wasn't being reset by macOS after the firmware was updated.
It seems that libusb_reset_device
has been broken on macOS since El Capitan. Changing
kresult = (*(dpriv->device))->ResetDevice (dpriv->device);
in the libusb_reset_device
function to
kresult = (*(dpriv->device))->USBDeviceReEnumerate (dpriv->device, 0);
works great. It requires recompiling libusb in node-usb and then running npm install --build-from-source
in node-usb. I've reported the bug to libusb, so let's wait and see what they say.