Usb problem with el capitan

Hi Chris,

We are using a labjack U6 for the I/O with MWorks. The labjack uses the exodriver as the USB driver. The exodriver uses the libusb 1.0 library to setup USB communications with the labjack (the labjack only uses libraries to function).

We recently upgraded to OSX El Capitan and noted that the USB communication with the labjack often fails at MWorks startup: an error occurs when configuring the ports.

The error does not occur when we unplug (which also powers it down) and replug the labjack. But if we afterwards restart MWorks, and thereby reinitialize the labjack-usb communication, the error (frequently, but for some reason not always) occurs. So we have a work around (unplugging and replugging and restarting MWorks) but it’s certainly not optimal.

We were wondering if you have more information on this issue with El Capitan and if you know of a solution?
Although not the best solution, one way to solve this problem for us would be to temporarily power down/disconnect the labjack/USB when MWorks starts up. Do you know how we could do this (in case there is no better solution)?

Thanks in advance.
Greetings,
Bram

Hi Bram,

I’m not experiencing this problem with my U6 on El Capitan. I’m using the latest LabJack-provided Exodriver binaries and the MWorks LabJack plugin that I’ve worked on for Lindsey Glickfeld (which derives from the Maunsell lab version). I have the device plugged directly in to a USB port on my Mac (not through a hub).

I think at some point you guys were compiling and using a patched version of libusb with your LabJack plugin. If that’s still the case, you might try using the LabJack-provided binaries instead, which may be more up to date. (If you want, I can send you my updated version of the LabJack plugin, which is set up to use the precompiled libs.)

If that doesn’t help, then can you send me more details on your setup? In particular, are you using the LabJack through a USB hub? If so, what other USB devices are connected to the same hub?

Thanks,
Chris

Hi Chris,

Thanks for your quick reply.

We are using the latest LabJack-provided Exodriver binaries. Also, we indeed use the USB hub, but even without the hub the problem continues to exist. No other USB devices are connected to the hub.

We also noted that the Exodriver and the latest libusb release do not include the latest libusb updates for El Capitan (darwin: updates to support el capitan · libusb/libusb@b7526c1 · GitHub), but including these updates did not solve the problem.

If you could send us your updated version of the LabJack plugin, that would be very helpful.

Thanks a lot!
Bram

Hi Chris,

To add to what Bram said:

We thought it might be related to this issue with libusb:

We installed the latest libusb HEAD, built dynamic libraries, and recompiled the plugin against the new libraries. I think we did that right, but there’s a chance I made an error.
Even with the new libusb install, we still see the errors, which look like mangled (or maybe slow) responses from the ehFeedback command in u6.c when we try to initialize the U6.

Mark

If you could send us your updated version of the LabJack plugin, that would be very helpful.

OK, I’ve attached the source code. If you’ve already run the Exodriver installer, then the plugin should build without any changes. Let me know if you run in to any problems.

Chris

We installed the latest libusb HEAD, built dynamic libraries, and recompiled the plugin against the new libraries.

Did you also recompile liblabjackusb against the latest libusb? If not, then it may still be linked to the old version.

Chris

Hi Mark,

Thanks for sharing the links to potentially-related issues (which I’ve included below).

After some additional testing, I’m now seeing this problem sometimes, but not always. Also, when I do get a LabJack initialization failure, if I then quit and restart MWServer, without unplugging the LabJack, the device initializes successfully. To me, this suggests that some step in the initialization process is timing out prematurely. I’m going to dig in to this some more and see what I can figure out.

For future reference, here are the links that Mark shared:

Chris

Hi all,

I’ve discovered a strange workaround for this issue: In setupU6PortsAndRestartIfDead, if the first call to ljU6ConfigPorts fails, and I then immediately call it two more times, the third attempt reliably succeeds. Specifically, I’ve replaced this bit of code:

// Do physical port setup
if (!ljU6ConfigPorts(ljHandle)) {
    ...

with this:

// Do physical port setup
if (!ljU6ConfigPorts(ljHandle) && !ljU6ConfigPorts(ljHandle) && !ljU6ConfigPorts(ljHandle)) {
    ...

I’m still building against the LabJack-provided exodriver and libusb binaries. I’m testing on a 2013 Mac Pro running OS X 10.11.2.

It doesn’t seem to be a question of timing, as simply putting a delay (even a multi-second one) between the first and second calls to ljU6ConfigPorts has no effect. Somehow, the actual act of attempting configuration three times (with a corresponding USB bulk write and read for each attempt) resolves the issue.

This isn’t exactly an encouraging result, as it still suggests there are issues in El Capitan’s USB drivers. However, if this workaround works on your setup machines, too, then it could serve as a weird but functional stop-gap measure until Apple fixes the root problems. Maybe you guys can try it out?

Cheers,
Chris

Hi Chris,

I just build the Labjack plugin with your suggested change. I restarted 10 times without unplugging the Labjack (we are using the late 2015 IMac 4K model with OS X 10.11.1). Each restart, the ljU6ConfigPorts function erred the first two times, but succeeded the third times.
So this seems to be a good workaround. Third time’s a charm!

We’ll keep on trying this fix during the next days and keep you posted if things go wrong.

Thanks a lot for finding this.
Bram

Hi all,

As noted on GitHub, the USB problem that was affecting LabJack initialization appears to be fixed in OS X 10.11.4. After upgrading to 10.11.4, removing my previously-suggested workaround, and re-testing, I find that the U6 initializes on every attempt without issue.

Cheers,
Chris

Great. Will this go in the nightly soon?

Thanks,
Mark

Hi Mark,

Will this go in the nightly soon?

The OS update resolved the issue. No MWorks changes were required. The LabJack plugin itself has never been in the nightly build.

Cheers,
Chris

Got it. Thanks for proactively testing this, Chris.
Mark

Hi Chris,

Yes, everything seems to work fine with the new upgrade.

Thanks for letting us know!
Bram