Request help in implementing bulk transfer in PsychHID

Dear Mario,

I am writing to request help in implementing our toolbox called PsyCalibrator within Psychtoolbox. the toolbox takes advantage of consumer hardware (SpyderX, Spyder5) and makes luminance/color measurement and gamma calibration accessible and flexible. Links to GitHub and a preprint can be found here:

GitHub: https://github.com/yangzhangpsy/PsyCalibrator
Preprint: https://psyarxiv.com/kfnh2/

Currently, PsyCalibrator runs on MATLAB and uses Psychtoolbox, but is itself not part of Psychtoolbox. We feel that the implementation of PsyCalibrator within Psychtoolbox will facilitate its use, particularly for those who are already using Psychtoolbox.

To that end, I am tring to comunicate/control SypderX via PsychHID. But, looks like PsychHID can not write/read “bulk transfer” between the host and the SpyderX device. So I am writing this mail for help. Is it possible to use PsychHID or other functions in Psychtoolbox to write/read “bulk transfer” to/from SpyderX? If not, is it possible to add “bulk transfer” support in PsychHID?

Thank you very much for your kind help and any suggestions will be appreciated.

Best wishes!
Yang

1 Like

Have you tried PsychHID(‘SetReport’ and PsychHID(‘GetReport’ ?

Dear Diederick,
Thank you very much for your kind suggestion.

Unluckily, No, PsychHID setReport/getReport is not for bulk transfer.

To do USB bulk transfer, we need to specify the address of a valid endpoint to communicate with, and looks like there is no parameter in SetReport/GetReport corresponding to the endpoint.

Thanks again for your kind suggestion.

Best
-Yang

Cool project! Given that your toolbox provides a useful addition of general interest for Psychtoolbox users and their use cases, and critically is also released as open-source software, I decided to select it for “free support on resolving a non-trivial issue”, sponsored by Mathworks Neuroscience - MATLAB and Simulink Solutions - MATLAB & Simulink - You get advice/work from myself for free that would normally have cost your lab in excess of 1000 Euros. Mathworks provided us with 3 such “Jokers” for free support and you get to use the second out of three.

I looked at our code, and it should be doable to add support to PsychHID for synchronous USB bulk transfers and interrupt transfers. That should solve your issue. I’ll aim to add it for the upcoming Psychtoolbox 3.0.19.0 release, which has an ETA of sometimes in November 2022.

This will require transitioning the implementation of low-level USB control transfer access for macOS from an awful to maintain, poorly documented by Apple, macOS proprietary backend to our shared libusb-1 backend that we already use for Linux and Windows, to speed up development and reduce maintenance overhead. The downside for macOS users will be that USB control transfers will in the future only work if libusb-1.dylib is installed from a 3rd party on their machine, e.g., via the popular Homebrew package manager. Or you might have to bundle that LGPL-2 licensed library as part of your PsyCalibrator toolbox for your Apple users. Currently control transfers are only used by PTB for LED brightness control in the PsychPowerMate() driver for the powermate turn knob, and in the ColorCal2 driver for some rarely needed extra features, not for most basic operation.

-mario

Dear Mario,

Thank you very much for your generous and warm support.
So looking forward to the upcoming PTB.

Best
-Yang

Ok, I got a PsychHID for Matlab on macOS for you to test. Chose macOS for initial test, as that OS required the most work to get anything going, as usual. More than 10 hours of extra work to deal with Apples special snowflake…

Get it from here:
https://github.com/kleinerm/Psychtoolbox-3/raw/master/Psychtoolbox/PsychBasic/PsychHID.mexmaci64

Check out the new subfunction PsychHID USBBulkTransfer?. This is not really tested with hardware, as I don’t actually have any hardware or specific use case, but should work fine, as far as limited testing goes. You will need a libusb-1.0.dylib, e.g., from HomeBrew.

Work time spent: 16 hours, 42 minutes.

-mario

Dear Mario,

Thank you very much for your supports and I will try it as soon as possible.

Best
-Yang

Dear Mario,

I have tried to run the newly added USBbulkTransfer function with the below command:

PsychHID(‘USBBulkTransfer’, usbHandle, 1, 5, uint8([0xd9 0x42 0x33 0x00 0x00]));

it failed with the internal error info listed below:

PsychHID-ERROR: USB bulk transfer failed: LIBUSB_ERROR_NOT_FOUND - Entity not found.
INTERNAL PSYCHTOOLBOX ERROR
error: PsychError_system
general description: Error reported by a system call
specific description: The USB Bulk transfer failed.
module name: PsychHID
subfunction call: USBBulkTransfer
file name: /Users/kleinerm/projects/OpenGLPsychtoolbox/Psychtoolbox-3/PsychSourceGL/Source/Common/PsychHID/PsychHIDUSBControlTransfer.c
function name: PSYCHHIDUSBBulkTransfer
line number: 178

Attached is the USB transfer info captured by Wireshark when controlling spyderX via spotread:

Do you mind giving any suggestions?

Thank you very much for your kind and warm help!
Best
-Yang

Can you retry under Linux with the new PsychHID file from
https://github.com/kleinerm/Psychtoolbox-3/raw/master/Psychtoolbox/PsychBasic/PsychHID.mexa64
or for Octave
https://github.com/kleinerm/Psychtoolbox-3/raw/master/Psychtoolbox/PsychBasic/Octave5LinuxFiles64/PsychHID.mex

You may need to run with sudo unless/until you got a dedicated udev rules file to allow access to the Spyder without admin rights.
-mario

I have updated PsychHID again, also for macOS and Windows for testing, but I strongly recommend testing on Linux first, where all of this should be the most pain-free.

For Windows one also needs the latest libusb-1.0.dll of version 1.0.26, so I’ve updated the bundled DLL in my GitHub master branch from something from the year ~2011 to the most recent 1.0.26 from 2022. To be found in the Psychtoolbox/PsychContributed/x64/ folder on my GitHub repo.

Turns out that for performing interrupt- or bulk transfers, or any transfers on USB endpoints, one needs to claim the associated USB interface, which was missing. The latest PsychHID mex files will automatically claim interface zero of the USB device by default if one tries a interrupt/bulk transfer. If another interface is needed, PsychHID('USBClaimInterface', usbHandle, interfaceId); will allow to claim that interface interfaceId instead of the default interface 0. It also turns out that one needs to detach any kernel drivers which the OS may have attached for a given USB interface, so PsychHID will auto detach and reattach kernel drivers as needed if possible.

My testing with the latest PsychHID builds, executing control transfers and interrupt transfers to a little Griffing PowerMate USB dial button, and also with some USB camera and other gizmos, shows that PsychHID can now work in principle.

That said, not all is shiny and rosy:

  1. On Linux things are expected to work perfectly when properly setup: For non-root access, without launching octave or matlab with sudo, you do need a suitable udev rules file installed in the system. /etc/udev/rules.d/, similar to the psychtoolbox.rules file installed there already, to allow access to your USB colorimeter as a normal user. I’d assume you already have such a file installed from Argyll, but setup instructions can be found under: Argyll Installation on Linux
    On Ubuntu 20.04, my system already has a rules file (under /usr/lib/udev/rules.d/69-cd-sensors.rules) for the Spyder 1-5 and various other colorimeter/photometer devices, so it may just work, or may work after a …
    sudo usermod -a -G colord $USER + logout + disconnect your device + login again, to add your user account to the colord group. Otherwise the link above gives instructions for adding a suitable file.

  2. Under macOS, it should hopefully work if macOS does not attach a kernel driver to your device. If macOS or a 3rd party software installed and attached a kernel driver that claimed exclusive use of the drive, you will be in a world of misery, courtesy of Apple macOS idiotic security approach. See commit message under PsychHID mex for 64-Bit Matlab/Octave on macOS 12.6 rebuilt. · kleinerm/Psychtoolbox-3@9e8bd9d · GitHub for all the misery and what to do.

  3. Under Windows, this link will tell you what to do: FAQ · libusb/libusb Wiki · GitHub and Windows · libusb/libusb Wiki · GitHub
    If or how well things work out of the box depends on the specific type of USB device used, and what drivers are installed for it.

  • If it is a HID compliant device, it should “work”, but with many limitations: IN transfers may currently return one extra byte of extaneous data, depending if the HID device supports HID reportId’s or not. This is due to a bug in libusb 1.0.26. OUT transfers should theoretically, but didn’t properly, at least when I tested with the PowerMate device. Only 1 Byte could be transmitted, instead of the requested amount. Reason unknown. CONTROL transfers are unsupported.
  • If it is a device with already WinUSB compliant driver installed, e.g., from your device vendor, IN and OUT transfers seem to work fine, CONTROL transfers should, but didn’t in my testing, despite the library reporting success. There is a little GUI app called zadig (http://zadig.akeo.ie/) that simplifies installation of dedicated USB drivers for devices that need this. Downside is that installing such a driver for your device might make it inaccessible for other 3rd party apps.
  • There are more USB drivers to be had on Windows as explained in the Wiki link mentioned above, each with its own tradeoffs.

All in all, this whole low-level access stuff proves to be very easy and straightforward on Linux, and quite messy on other operating systems, where it is difficult to judge for each individual USB device if Window or macOS is a bigger pain in the ass, but probably macOS is the biggest nightmare, as usual.

The estimated work time for this Mathworks sponsered support request was 4-8 work hours, but so far we are at 30 work hours and counting, more than 3 times as much as what Mathworks actually sponsored, and this is another issue where we lose money instead of making a small profit. The 4-8 hours would have been correct if every OS would be as easy to deal with as Linux. About 6 hours of work for writing the code that was supposed to work cross-platform on all operating systems, and it worked nicely on Linux from the start, and that should have been a wrap! But unfortunately other OS’es provided many additional pitfalls. Most of the time was wasted - as usual - dealing with the special snowflake that is Apple macOS, over 14 hours of extra work, just for half-dealing with the iToy operating system. Another 10 hours of extra work for MS-Windows.

At this point, PsychHID should work in principle, and I consider this support request being done, unless you find a problem that is clearly due to a PsychHID bug, not a macOS or MS-Windows induced problem, in other words easily reproducible on Linux.

-mario

Dear Mario,

Great! Thank you very much for your prompt and warm support.

I took a brief try. It looks like PsychHID works well for spyderX under macOS (I have not tried it under Win /Linux). And I have updated “spyderXComProtocol.m” ( GitHub - yangzhangpsy/PsyCalibrator: PsyCalibrator) accordingly.

I will try PsychHID for spyderX under Win/Linux as soon as possible.

Thanks again for your kind and warm help.
-Yang

Great! So I guess macOS doesn’t have a system or 3rd party kernel driver blocking access to the SpyderX and you are lucky with that type of device.
-mario

Dear Mario,
Sorry for the delayed test feedback on PsychHID for Linux (Ubuntu 20.04.2 LTS) . I was injured in a small traffic accident, spent 2 weeks in the hospital, and just returned home.

I tried to run PsychHID under Linux via “spyderXComProtocol.m” [it works fine under macOS] ( GitHub - yangzhangpsy/PsyCalibrator: PsyCalibrator) in Matlab running the sudo mode and got the following error info:

[XYZ] = spyderXComProtocol(‘initial’)
PsychHID-ERROR: Claiming USB interface 0 failed: LIBUSB_ERROR_BUSY - Resource busy.
INTERNAL PSYCHTOOLBOX ERROR
error: PsychError_system
general description: Error reported by a system call
specific description: The USB Bulk transfer failed.
module name: PsychHID
subfunction call: USBBulkTransfer
file name: /home/kleinerm/projects/OpenGLPsychtoolbox/Psychtoolbox-3/PsychSourceGL/Source/Common/PsychHID/PsychHIDUSBControlTransfer.c
function name: PSYCHHIDUSBBulkTransfer
line number: 181
Error using PsychHID
See error message printed above.

Error in spyderXComProtocol>bulkTransfer (line 234)
PsychHID(‘USBBulkTransfer’, usbHandle, 1, numel(cmd), cmd);

Error in spyderXComProtocol (line 42)
out = bulkTransfer(usbHandle, uint8([0xd9 0x42 0x33 0x00 0x00]), 28);

The bulkTransfer is a sub function contained in spyderXComProtocol.m as listed below:

%%%%%%%%%%%%%%%%%%%%%%%%
% USB Bulk Transfer
%%%%%%%%%%%%%%%%%%%%%%%%
function out = bulkTransfer(usbHandle, cmd, outSize)
% cmd :[uint8]
% outSize : [double]
% 0x01 = 1
PsychHID(‘USBBulkTransfer’, usbHandle, 1, numel(cmd), cmd);

% 0x81 = 129
out = PsychHID(‘USBBulkTransfer’, usbHandle, 129, outSize);
end

Do you mind giving any suggestions?

Thank you very much for your kind and warm help!
Best
-Yang

Oh dear, sorry to hear that. Hope your recovery will be speedy and good.

A resource busy error means that some other application or a kernel driver is claiming the device already for its exclusive use. PsychHID on Linux should auto-detach kernel drivers to handle the kernel driver case, unless that somehow is not possible.

Can you retest with a new PsychHID.mexa64 that I just enhanced to try to diagnose if a kernel driver or userspace application is blocking access? Get it from here:
https://github.com/kleinerm/Psychtoolbox-3/raw/master/Psychtoolbox/PsychBasic/PsychHID.mexa64

PsychHID('Version') should report a build date of 3rd December 2022 if you got the right file.

I wonder if you have Argyll installed and that is claiming exclusive access?

-mario
[Time spent: 33 hours!]

Oh also additionally, what’s the terminal output of: lsusb -tvv

Dear Mario,

I have tried the latest version of PsychHID and got the error info listed below:

And I am sure that spyderXComProtocol can open/close the device successfully because when the device is in opening status by spyderXComProtocol, the spotread cannot run successfully. See the tested result list below:

And here below is the info returned by lsusb -tvv:
lsusb -tvv
/: Bus 04.Port 1: Dev 1, Class=root_hub, Driver=xhci_hcd/4p, 5000M
ID 1d6b:0003 Linux Foundation 3.0 root hub
/sys/bus/usb/devices/usb4 /dev/bus/usb/004/001
/: Bus 03.Port 1: Dev 1, Class=root_hub, Driver=xhci_hcd/4p, 480M
ID 1d6b:0002 Linux Foundation 2.0 root hub
/sys/bus/usb/devices/usb3 /dev/bus/usb/003/001
|__ Port 1: Dev 2, If 0, Class=Vendor Specific Class, Driver=, 12M
ID 085c:0a00 ColorVision, Inc.
/sys/bus/usb/devices/3-1 /dev/bus/usb/003/002
/: Bus 02.Port 1: Dev 1, Class=root_hub, Driver=ehci-pci/2p, 480M
ID 1d6b:0002 Linux Foundation 2.0 root hub
/sys/bus/usb/devices/usb2 /dev/bus/usb/002/001
|__ Port 1: Dev 2, If 0, Class=Hub, Driver=hub/8p, 480M
ID 8087:0024 Intel Corp. Integrated Rate Matching Hub
/sys/bus/usb/devices/2-1 /dev/bus/usb/002/002
|__ Port 8: Dev 3, If 0, Class=Hub, Driver=hub/2p, 480M
ID 0424:2512 Microchip Technology, Inc. (formerly SMSC) USB 2.0 Hub
/sys/bus/usb/devices/2-1.8 /dev/bus/usb/002/003
|__ Port 1: Dev 4, If 0, Class=Hub, Driver=hub/3p, 12M
ID 0a5c:4500 Broadcom Corp. BCM2046B1 USB 2.0 Hub (part of BCM2046 Bluetooth)
/sys/bus/usb/devices/2-1.8.1 /dev/bus/usb/002/004
|__ Port 3: Dev 8, If 1, Class=Wireless, Driver=btusb, 12M
ID 05ac:8286 Apple, Inc. Bluetooth Host Controller
/sys/bus/usb/devices/2-1.8.1.3 /dev/bus/usb/002/008
|__ Port 3: Dev 8, If 2, Class=Vendor Specific Class, Driver=btusb, 12M
ID 05ac:8286 Apple, Inc. Bluetooth Host Controller
/sys/bus/usb/devices/2-1.8.1.3 /dev/bus/usb/002/008
|__ Port 3: Dev 8, If 0, Class=Vendor Specific Class, Driver=btusb, 12M
ID 05ac:8286 Apple, Inc. Bluetooth Host Controller
/sys/bus/usb/devices/2-1.8.1.3 /dev/bus/usb/002/008
|__ Port 3: Dev 8, If 3, Class=Application Specific Interface, Driver=, 12M
ID 05ac:8286 Apple, Inc. Bluetooth Host Controller
/sys/bus/usb/devices/2-1.8.1.3 /dev/bus/usb/002/008
|__ Port 2: Dev 5, If 0, Class=Human Interface Device, Driver=usbhid, 12M
ID 05ac:0262 Apple, Inc.
/sys/bus/usb/devices/2-1.8.2 /dev/bus/usb/002/005
|__ Port 2: Dev 5, If 1, Class=Human Interface Device, Driver=usbhid, 12M
ID 05ac:0262 Apple, Inc.
/sys/bus/usb/devices/2-1.8.2 /dev/bus/usb/002/005
|__ Port 2: Dev 5, If 2, Class=Human Interface Device, Driver=bcm5974, 12M
ID 05ac:0262 Apple, Inc.
/sys/bus/usb/devices/2-1.8.2 /dev/bus/usb/002/005
/: Bus 01.Port 1: Dev 1, Class=root_hub, Driver=ehci-pci/2p, 480M
ID 1d6b:0002 Linux Foundation 2.0 root hub
/sys/bus/usb/devices/usb1 /dev/bus/usb/001/001
|__ Port 1: Dev 2, If 0, Class=Hub, Driver=hub/6p, 480M
ID 8087:0024 Intel Corp. Integrated Rate Matching Hub
/sys/bus/usb/devices/1-1 /dev/bus/usb/001/002
|__ Port 1: Dev 3, If 0, Class=Video, Driver=uvcvideo, 480M
ID 05ac:8510 Apple, Inc. FaceTime HD Camera (Built-in)
/sys/bus/usb/devices/1-1.1 /dev/bus/usb/001/003
|__ Port 1: Dev 3, If 1, Class=Video, Driver=uvcvideo, 480M
ID 05ac:8510 Apple, Inc. FaceTime HD Camera (Built-in)
/sys/bus/usb/devices/1-1.1 /dev/bus/usb/001/003
|__ Port 1: Dev 3, If 2, Class=Vendor Specific Class, Driver=, 480M
ID 05ac:8510 Apple, Inc. FaceTime HD Camera (Built-in)
/sys/bus/usb/devices/1-1.1 /dev/bus/usb/001/003

Thank you very much for your kind and warm help!
Best
-Yang

Ok, there ain’t no kernel driver blocking device access, so likely it must be some running userspace driver or application blocking the interface.

What is the output of lsof /dev/bus/usb/003/002? Replace that filename with whatever is mentioned below the line “ID 085c:0a00 ColorVision, Inc.” in the output of lsusb -tvv if you’ve unplugged the device meanwhile, or rebooted your machine etc.

Also, what is the output if you launch matlab from a terminal via:
LIBUSB_DEBUG=4 matlab -nodesktop?

Further, after the above: What is the output of lsusb -tvv after unplugging your SpyderX, waiting a few seconds and replugging? All without running any other color calibration utility beforehand. Does PsychHID behave differently if it is the first time you run it after unplugging, plugging in again, versus if you ran some other application like ./spotread beforehand?

-mario
[Time spent: 36 hours!]

Dear Mario,
Following your suggestions, I have done the following 4 steps of the test and got the info list below:

  1. :checkered_flag: lsof /dev/bus/usb/003/002 returned nothing
yang@yang-MacBookPro:~$ lsusb -tvv
/:  Bus 04.Port 1: Dev 1, Class=root_hub, Driver=xhci_hcd/4p, 5000M
    ID 1d6b:0003 Linux Foundation 3.0 root hub
    /sys/bus/usb/devices/usb4  /dev/bus/usb/004/001
/:  Bus 03.Port 1: Dev 1, Class=root_hub, Driver=xhci_hcd/4p, 480M
    ID 1d6b:0002 Linux Foundation 2.0 root hub
    /sys/bus/usb/devices/usb3  /dev/bus/usb/003/001
    |__ Port 1: Dev 2, If 0, Class=Vendor Specific Class, Driver=, 12M
        ID 085c:0a00 ColorVision, Inc. 
        /sys/bus/usb/devices/3-1  /dev/bus/usb/003/002
...



yang@yang-MacBookPro:~$ lsof /dev/bus/usb/003/002
yang@yang-MacBookPro:~$ sudo LIBUSB_DEBUG=4 matlab -nodesktop
[sudo] password for yang: 
MATLAB is selecting SOFTWARE OPENGL rendering.
  1. :checkered_flag: Running Matlab with LIBUSB_DEBUG=4 matlab -nodesktop:
yang@yang-MacBookPro:~$ sudo LIBUSB_DEBUG=4 matlab -nodesktop
[sudo] password for yang: 
MATLAB is selecting SOFTWARE OPENGL rendering.

                                                               < M A T L A B (R) >
                                                     Copyright 1984-2019 The MathWorks, Inc.
                                                     R2019b (9.7.0.1190202) 64-bit (glnxa64)
                                                                 August 21, 2019

 
To get started, type doc.
For product information, visit www.mathworks.com.
 
>> xyz = spyderXComProtocol('initial')               
[timestamp] [threadID] facility level [function call] <message>
--------------------------------------------------------------------------------
[ 0.000004] [00008b6b] libusb: debug [libusb_init] created default context
[ 0.000021] [00008b6b] libusb: debug [libusb_init] libusb v1.0.23.11397
[ 0.000039] [00008b6b] libusb: debug [find_usbfs_path] found usbfs at /dev/bus/usb
[ 0.000048] [00008b6b] libusb: debug [get_kernel_version] reported kernel version is 5.15.0-46-generic
[ 0.000052] [00008b6b] libusb: debug [op_init] bulk continuation flag supported
[ 0.000055] [00008b6b] libusb: debug [op_init] zero length packet flag supported
[ 0.000058] [00008b6b] libusb: debug [op_init] max iso packet length is (likely) 49152 bytes
[ 0.000066] [00008b6b] libusb: debug [op_init] sysfs can relate devices
[ 0.000069] [00008b6b] libusb: debug [op_init] sysfs has complete descriptors
[ 0.000338] [00008c12] libusb: debug [linux_udev_event_thread_main] udev event thread entering.
[ 0.003897] [00008b6b] libusb: debug [linux_get_device_address] getting address for device: usb3 detached: 0
[ 0.003906] [00008b6b] libusb: debug [linux_get_device_address] scan usb3
[ 0.003936] [00008b6b] libusb: debug [linux_get_device_address] bus=3 dev=1
[ 0.003941] [00008b6b] libusb: debug [linux_enumerate_device] busnum 3 devaddr 1 session_id 769
[ 0.003945] [00008b6b] libusb: debug [linux_enumerate_device] allocating new device for 3/1 (session 769)
[ 0.004027] [00008b6b] libusb: debug [linux_get_device_address] getting address for device: 3-1 detached: 0
[ 0.004033] [00008b6b] libusb: debug [linux_get_device_address] scan 3-1
[ 0.004059] [00008b6b] libusb: debug [linux_get_device_address] bus=3 dev=2
[ 0.004064] [00008b6b] libusb: debug [linux_enumerate_device] busnum 3 devaddr 2 session_id 770
[ 0.004069] [00008b6b] libusb: debug [linux_enumerate_device] allocating new device for 3/2 (session 770)
[ 0.004094] [00008b6b] libusb: debug [linux_get_parent_info] Dev 0x7f2f5cfaa7d0 (3-1) has parent 0x7f2f5cfaab20 (usb3) port 1
[ 0.004148] [00008b6b] libusb: debug [linux_get_device_address] getting address for device: usb4 detached: 0
[ 0.004153] [00008b6b] libusb: debug [linux_get_device_address] scan usb4
[ 0.004180] [00008b6b] libusb: debug [linux_get_device_address] bus=4 dev=1
[ 0.004185] [00008b6b] libusb: debug [linux_enumerate_device] busnum 4 devaddr 1 session_id 1025
[ 0.004189] [00008b6b] libusb: debug [linux_enumerate_device] allocating new device for 4/1 (session 1025)
[ 0.004261] [00008b6b] libusb: debug [linux_get_device_address] getting address for device: usb1 detached: 0
[ 0.004266] [00008b6b] libusb: debug [linux_get_device_address] scan usb1
[ 0.004293] [00008b6b] libusb: debug [linux_get_device_address] bus=1 dev=1
[ 0.004298] [00008b6b] libusb: debug [linux_enumerate_device] busnum 1 devaddr 1 session_id 257
[ 0.004302] [00008b6b] libusb: debug [linux_enumerate_device] allocating new device for 1/1 (session 257)
[ 0.004376] [00008b6b] libusb: debug [linux_get_device_address] getting address for device: 1-1 detached: 0
[ 0.004382] [00008b6b] libusb: debug [linux_get_device_address] scan 1-1
[ 0.004409] [00008b6b] libusb: debug [linux_get_device_address] bus=1 dev=2
[ 0.004414] [00008b6b] libusb: debug [linux_enumerate_device] busnum 1 devaddr 2 session_id 258
[ 0.004418] [00008b6b] libusb: debug [linux_enumerate_device] allocating new device for 1/2 (session 258)
[ 0.004444] [00008b6b] libusb: debug [linux_get_parent_info] Dev 0x7f2f5cfad6d0 (1-1) has parent 0x7f2f5cfabdb0 (usb1) port 1
[ 0.004503] [00008b6b] libusb: debug [linux_get_device_address] getting address for device: 1-1.1 detached: 0
[ 0.004509] [00008b6b] libusb: debug [linux_get_device_address] scan 1-1.1
[ 0.004537] [00008b6b] libusb: debug [linux_get_device_address] bus=1 dev=3
[ 0.004542] [00008b6b] libusb: debug [linux_enumerate_device] busnum 1 devaddr 3 session_id 259
[ 0.004546] [00008b6b] libusb: debug [linux_enumerate_device] allocating new device for 1/3 (session 259)
[ 0.004571] [00008b6b] libusb: debug [linux_get_parent_info] Dev 0x7f2f5cfaddf0 (1-1.1) has parent 0x7f2f5cfad6d0 (1-1) port 1
[ 0.004624] [00008b6b] libusb: debug [linux_get_device_address] getting address for device: usb2 detached: 0
[ 0.004630] [00008b6b] libusb: debug [linux_get_device_address] scan usb2
[ 0.004657] [00008b6b] libusb: debug [linux_get_device_address] bus=2 dev=1
[ 0.004662] [00008b6b] libusb: debug [linux_enumerate_device] busnum 2 devaddr 1 session_id 513
[ 0.004666] [00008b6b] libusb: debug [linux_enumerate_device] allocating new device for 2/1 (session 513)
[ 0.004742] [00008b6b] libusb: debug [linux_get_device_address] getting address for device: 2-1 detached: 0
[ 0.004748] [00008b6b] libusb: debug [linux_get_device_address] scan 2-1
[ 0.004776] [00008b6b] libusb: debug [linux_get_device_address] bus=2 dev=2
[ 0.004780] [00008b6b] libusb: debug [linux_enumerate_device] busnum 2 devaddr 2 session_id 514
[ 0.004785] [00008b6b] libusb: debug [linux_enumerate_device] allocating new device for 2/2 (session 514)
[ 0.004811] [00008b6b] libusb: debug [linux_get_parent_info] Dev 0x7f2f5cfae590 (2-1) has parent 0x7f2f5cfae4d0 (usb2) port 1
[ 0.004871] [00008b6b] libusb: debug [linux_get_device_address] getting address for device: 2-1.8 detached: 0
[ 0.004877] [00008b6b] libusb: debug [linux_get_device_address] scan 2-1.8
[ 0.004904] [00008b6b] libusb: debug [linux_get_device_address] bus=2 dev=3
[ 0.004909] [00008b6b] libusb: debug [linux_enumerate_device] busnum 2 devaddr 3 session_id 515
[ 0.004913] [00008b6b] libusb: debug [linux_enumerate_device] allocating new device for 2/3 (session 515)
[ 0.004942] [00008b6b] libusb: debug [linux_get_parent_info] Dev 0x7f2f5cfacae0 (2-1.8) has parent 0x7f2f5cfae590 (2-1) port 8
[ 0.005004] [00008b6b] libusb: debug [linux_get_device_address] getting address for device: 2-1.8.1 detached: 0
[ 0.005009] [00008b6b] libusb: debug [linux_get_device_address] scan 2-1.8.1
[ 0.005037] [00008b6b] libusb: debug [linux_get_device_address] bus=2 dev=4
[ 0.005042] [00008b6b] libusb: debug [linux_enumerate_device] busnum 2 devaddr 4 session_id 516
[ 0.005046] [00008b6b] libusb: debug [linux_enumerate_device] allocating new device for 2/4 (session 516)
[ 0.005072] [00008b6b] libusb: debug [linux_get_parent_info] Dev 0x7f2f5cface00 (2-1.8.1) has parent 0x7f2f5cfacae0 (2-1.8) port 1
[ 0.005137] [00008b6b] libusb: debug [linux_get_device_address] getting address for device: 2-1.8.1.3 detached: 0
[ 0.005143] [00008b6b] libusb: debug [linux_get_device_address] scan 2-1.8.1.3
[ 0.005171] [00008b6b] libusb: debug [linux_get_device_address] bus=2 dev=8
[ 0.005176] [00008b6b] libusb: debug [linux_enumerate_device] busnum 2 devaddr 8 session_id 520
[ 0.005180] [00008b6b] libusb: debug [linux_enumerate_device] allocating new device for 2/8 (session 520)
[ 0.005206] [00008b6b] libusb: debug [linux_get_parent_info] Dev 0x7f2f5cfad310 (2-1.8.1.3) has parent 0x7f2f5cface00 (2-1.8.1) port 3
[ 0.005271] [00008b6b] libusb: debug [linux_get_device_address] getting address for device: 2-1.8.2 detached: 0
[ 0.005276] [00008b6b] libusb: debug [linux_get_device_address] scan 2-1.8.2
[ 0.005304] [00008b6b] libusb: debug [linux_get_device_address] bus=2 dev=5
[ 0.005309] [00008b6b] libusb: debug [linux_enumerate_device] busnum 2 devaddr 5 session_id 517
[ 0.005313] [00008b6b] libusb: debug [linux_enumerate_device] allocating new device for 2/5 (session 517)
[ 0.005338] [00008b6b] libusb: debug [linux_get_parent_info] Dev 0x7f2f5cfad420 (2-1.8.2) has parent 0x7f2f5cfacae0 (2-1.8) port 2
[ 0.005402] [00008b6b] libusb: debug [usbi_add_pollfd] add fd 667 events 1
[ 0.005413] [00008b6b] libusb: debug [usbi_io_init] using timerfd for timeouts
[ 0.005417] [00008b6b] libusb: debug [usbi_add_pollfd] add fd 669 events 1
[ 0.005421] [00008b6b] libusb: debug [libusb_get_device_list] 
[ 0.005428] [00008b6b] libusb: debug [discovered_devs_append] need to increase capacity
[ 0.005433] [00008b6b] libusb: debug [libusb_get_device_descriptor] 
[ 0.005437] [00008b6b] libusb: debug [libusb_get_device_descriptor] 
[ 0.005441] [00008b6b] libusb: debug [libusb_get_device_descriptor] 
[ 0.005444] [00008b6b] libusb: debug [libusb_get_device_descriptor] 
[ 0.005447] [00008b6b] libusb: debug [libusb_get_device_descriptor] 
[ 0.005451] [00008b6b] libusb: debug [libusb_get_device_descriptor] 
[ 0.005455] [00008b6b] libusb: debug [libusb_get_device_descriptor] 
[ 0.005458] [00008b6b] libusb: debug [libusb_get_device_descriptor] 
[ 0.005461] [00008b6b] libusb: debug [libusb_get_device_descriptor] 
[ 0.005465] [00008b6b] libusb: debug [libusb_get_device_descriptor] 
[ 0.005468] [00008b6b] libusb: debug [libusb_get_device_descriptor] 
[ 0.005471] [00008b6b] libusb: debug [libusb_open] open 3.2
[ 0.267454] [00008b6b] libusb: debug [usbi_add_pollfd] add fd 670 events 4
[ 0.267509] [00008b6b] libusb: debug [libusb_get_device_descriptor] 
[ 0.267546] [00008b6b] libusb: debug [libusb_get_config_descriptor] index 0
[ 0.267566] [00008b6b] libusb: debug [libusb_get_configuration] 
[ 0.267661] [00008b6b] libusb: debug [libusb_get_configuration] active config 1
[ 0.268486] [00008b6b] libusb: debug [libusb_alloc_transfer] transfer 0x7f2f5cf674d0
[ 0.268525] [00008b6b] libusb: debug [libusb_submit_transfer] transfer 0x7f2f5cf674d0
[ 0.268535] [00008b6b] libusb: debug [add_to_flying_list] arm timerfd for timeout in 10000ms (first in line)
[ 0.268628] [00008b6b] libusb: debug [libusb_handle_events_timeout_completed] doing our own event handling
[ 0.268648] [00008b6b] libusb: debug [handle_events] poll fds modified, reallocating
[ 0.268671] [00008b6b] libusb: debug [handle_events] poll() 3 fds with timeout in 60000ms
[ 0.268692] [00008b6b] libusb: debug [handle_events] poll() returned 1
[ 0.268711] [00008b6b] libusb: debug [reap_for_handle] urb type=2 status=0 transferred=0
[ 0.268724] [00008b6b] libusb: debug [handle_control_completion] handling completion status 0
[ 0.268737] [00008b6b] libusb: debug [disarm_timerfd] 
[ 0.268751] [00008b6b] libusb: debug [usbi_handle_transfer_completion] transfer 0x7f2f5cf674d0 has callback 0x7f2fa355bfc0
[ 0.268766] [00008b6b] libusb: debug [sync_transfer_cb] actual_length=0
[ 0.268780] [00008b6b] libusb: debug [libusb_free_transfer] transfer 0x7f2f5cf674d0
[ 0.268970] [00008b6b] libusb: debug [libusb_alloc_transfer] transfer 0x7f2f5cfa5d50
[ 0.268994] [00008b6b] libusb: debug [libusb_submit_transfer] transfer 0x7f2f5cfa5d50
[ 0.269006] [00008b6b] libusb: debug [add_to_flying_list] arm timerfd for timeout in 10000ms (first in line)
[ 0.269037] [00008b6b] libusb: debug [libusb_handle_events_timeout_completed] doing our own event handling
[ 0.269048] [00008b6b] libusb: debug [handle_events] poll() 3 fds with timeout in 60000ms
[ 0.269095] [00008b6b] libusb: debug [handle_events] poll() returned 1
[ 0.269114] [00008b6b] libusb: debug [reap_for_handle] urb type=2 status=0 transferred=0
[ 0.269123] [00008b6b] libusb: debug [handle_control_completion] handling completion status 0
[ 0.269131] [00008b6b] libusb: debug [disarm_timerfd] 
[ 0.269140] [00008b6b] libusb: debug [usbi_handle_transfer_completion] transfer 0x7f2f5cfa5d50 has callback 0x7f2fa355bfc0
[ 0.269149] [00008b6b] libusb: debug [sync_transfer_cb] actual_length=0
[ 0.269161] [00008b6b] libusb: debug [libusb_free_transfer] transfer 0x7f2f5cfa5d50
[ 0.269291] [00008b6b] libusb: debug [libusb_alloc_transfer] transfer 0x7f2f5cfa8870
[ 0.269310] [00008b6b] libusb: debug [libusb_submit_transfer] transfer 0x7f2f5cfa8870
[ 0.269319] [00008b6b] libusb: debug [add_to_flying_list] arm timerfd for timeout in 10000ms (first in line)
[ 0.269343] [00008b6b] libusb: debug [libusb_handle_events_timeout_completed] doing our own event handling
[ 0.269355] [00008b6b] libusb: debug [handle_events] poll() 3 fds with timeout in 60000ms
[ 0.269460] [00008b6b] libusb: debug [handle_events] poll() returned 1
[ 0.269500] [00008b6b] libusb: debug [reap_for_handle] urb type=2 status=0 transferred=0
[ 0.269520] [00008b6b] libusb: debug [handle_control_completion] handling completion status 0
[ 0.269532] [00008b6b] libusb: debug [disarm_timerfd] 
[ 0.269546] [00008b6b] libusb: debug [usbi_handle_transfer_completion] transfer 0x7f2f5cfa8870 has callback 0x7f2fa355bfc0
[ 0.269557] [00008b6b] libusb: debug [sync_transfer_cb] actual_length=0
[ 0.269570] [00008b6b] libusb: debug [libusb_free_transfer] transfer 0x7f2f5cfa8870
[ 0.270710] [00008b6b] libusb: debug [libusb_claim_interface] interface 0
PsychHID-ERROR: Claiming USB interface 0 failed: LIBUSB_ERROR_BUSY - Resource busy.
[ 0.270775] [00008b6b] libusb: debug [libusb_kernel_driver_active] interface 0
PsychHID-ERROR: Interface 0 does not have any kernel drivers attached. Check if some other application is using the device already.
INTERNAL PSYCHTOOLBOX ERROR
	error:                PsychError_system
	general description:  Error reported by a system call
	specific description: The USB Bulk transfer failed.
	module name:          PsychHID
	subfunction call:     USBBulkTransfer
	file name:            /home/kleinerm/projects/OpenGLPsychtoolbox/Psychtoolbox-3/PsychSourceGL/Source/Common/PsychHID/PsychHIDUSBControlTransfer.c
	function name:        PSYCHHIDUSBBulkTransfer
	line number:          182
Error using PsychHID
See error message printed above.

Error in spyderXComProtocol>bulkTransfer (line 235)
PsychHID('USBBulkTransfer', usbHandle, 1, numel(cmd), cmd);

Error in spyderXComProtocol (line 42)
        out = bulkTransfer(usbHandle, uint8([0xd9 0x42 0x33 0x00 0x00]), 28);
  1. :checkered_flag: lsusb -tvv after unplugging spyderX, waiting a few seconds, and replugging without running any other color calibration utility beforehand.

yang@yang-MacBookPro:~$ lsusb -tvv
/:  Bus 04.Port 1: Dev 1, Class=root_hub, Driver=xhci_hcd/4p, 5000M
    ID 1d6b:0003 Linux Foundation 3.0 root hub
    /sys/bus/usb/devices/usb4  /dev/bus/usb/004/001
/:  Bus 03.Port 1: Dev 1, Class=root_hub, Driver=xhci_hcd/4p, 480M
    ID 1d6b:0002 Linux Foundation 2.0 root hub
    /sys/bus/usb/devices/usb3  /dev/bus/usb/003/001
    |__ Port 1: Dev 3, If 0, Class=Vendor Specific Class, Driver=, 12M
        ID 085c:0a00 ColorVision, Inc. 
        /sys/bus/usb/devices/3-1  /dev/bus/usb/003/003
...

  1. :checkered_flag: Running PsyHID in Matlab after carrying out the ./spotread beforehand
yang@yang-MacBookPro:~$ ./spotread

Spot read needs a calibration before continuing

Place cap on the instrument, or place on a dark surface,
or place on the calibration reference,
 and then hit any key to continue,
 or hit Esc or Q to abort: 

Spot read got abort or error from calibration
yang@yang-MacBookPro:~$ 
yang@yang-MacBookPro:~$ sudo LIBUSB_DEBUG=4 matlab -nodesktop
MATLAB is selecting SOFTWARE OPENGL rendering.

                                                               < M A T L A B (R) >
                                                     Copyright 1984-2019 The MathWorks, Inc.
                                                     R2019b (9.7.0.1190202) 64-bit (glnxa64)
                                                                 August 21, 2019

 
To get started, type doc.
For product information, visit www.mathworks.com.
 
xyz = spyderXComProtocol('initial')               
[timestamp] [threadID] facility level [function call] <message>
--------------------------------------------------------------------------------
[ 0.000004] [00009cdf] libusb: debug [libusb_init] created default context
[ 0.000031] [00009cdf] libusb: debug [libusb_init] libusb v1.0.23.11397
[ 0.000049] [00009cdf] libusb: debug [find_usbfs_path] found usbfs at /dev/bus/usb
[ 0.000058] [00009cdf] libusb: debug [get_kernel_version] reported kernel version is 5.15.0-46-generic
[ 0.000062] [00009cdf] libusb: debug [op_init] bulk continuation flag supported
[ 0.000065] [00009cdf] libusb: debug [op_init] zero length packet flag supported
[ 0.000068] [00009cdf] libusb: debug [op_init] max iso packet length is (likely) 49152 bytes
[ 0.000076] [00009cdf] libusb: debug [op_init] sysfs can relate devices
[ 0.000079] [00009cdf] libusb: debug [op_init] sysfs has complete descriptors
[ 0.000347] [00009d82] libusb: debug [linux_udev_event_thread_main] udev event thread entering.
[ 0.003895] [00009cdf] libusb: debug [linux_get_device_address] getting address for device: usb3 detached: 0
[ 0.003904] [00009cdf] libusb: debug [linux_get_device_address] scan usb3
[ 0.003934] [00009cdf] libusb: debug [linux_get_device_address] bus=3 dev=1
[ 0.003939] [00009cdf] libusb: debug [linux_enumerate_device] busnum 3 devaddr 1 session_id 769
[ 0.003944] [00009cdf] libusb: debug [linux_enumerate_device] allocating new device for 3/1 (session 769)
[ 0.004023] [00009cdf] libusb: debug [linux_get_device_address] getting address for device: 3-1 detached: 0
[ 0.004029] [00009cdf] libusb: debug [linux_get_device_address] scan 3-1
[ 0.004056] [00009cdf] libusb: debug [linux_get_device_address] bus=3 dev=3
[ 0.004061] [00009cdf] libusb: debug [linux_enumerate_device] busnum 3 devaddr 3 session_id 771
[ 0.004065] [00009cdf] libusb: debug [linux_enumerate_device] allocating new device for 3/3 (session 771)
[ 0.004092] [00009cdf] libusb: debug [linux_get_parent_info] Dev 0x7f30d51a3a60 (3-1) has parent 0x7f30d51a3b40 (usb3) port 1
[ 0.004146] [00009cdf] libusb: debug [linux_get_device_address] getting address for device: usb4 detached: 0
[ 0.004152] [00009cdf] libusb: debug [linux_get_device_address] scan usb4
[ 0.004177] [00009cdf] libusb: debug [linux_get_device_address] bus=4 dev=1
[ 0.004182] [00009cdf] libusb: debug [linux_enumerate_device] busnum 4 devaddr 1 session_id 1025
[ 0.004188] [00009cdf] libusb: debug [linux_enumerate_device] allocating new device for 4/1 (session 1025)
[ 0.004262] [00009cdf] libusb: debug [linux_get_device_address] getting address for device: usb1 detached: 0
[ 0.004268] [00009cdf] libusb: debug [linux_get_device_address] scan usb1
[ 0.004294] [00009cdf] libusb: debug [linux_get_device_address] bus=1 dev=1
[ 0.004298] [00009cdf] libusb: debug [linux_enumerate_device] busnum 1 devaddr 1 session_id 257
[ 0.004303] [00009cdf] libusb: debug [linux_enumerate_device] allocating new device for 1/1 (session 257)
[ 0.004385] [00009cdf] libusb: debug [linux_get_device_address] getting address for device: 1-1 detached: 0
[ 0.004391] [00009cdf] libusb: debug [linux_get_device_address] scan 1-1
[ 0.004427] [00009cdf] libusb: debug [linux_get_device_address] bus=1 dev=2
[ 0.004432] [00009cdf] libusb: debug [linux_enumerate_device] busnum 1 devaddr 2 session_id 258
[ 0.004436] [00009cdf] libusb: debug [linux_enumerate_device] allocating new device for 1/2 (session 258)
[ 0.004462] [00009cdf] libusb: debug [linux_get_parent_info] Dev 0x7f30d51a5820 (1-1) has parent 0x7f30d51a4900 (usb1) port 1
[ 0.004534] [00009cdf] libusb: debug [linux_get_device_address] getting address for device: 1-1.1 detached: 0
[ 0.004540] [00009cdf] libusb: debug [linux_get_device_address] scan 1-1.1
[ 0.004576] [00009cdf] libusb: debug [linux_get_device_address] bus=1 dev=3
[ 0.004581] [00009cdf] libusb: debug [linux_enumerate_device] busnum 1 devaddr 3 session_id 259
[ 0.004586] [00009cdf] libusb: debug [linux_enumerate_device] allocating new device for 1/3 (session 259)
[ 0.004610] [00009cdf] libusb: debug [linux_get_parent_info] Dev 0x7f30d51a5d30 (1-1.1) has parent 0x7f30d51a5820 (1-1) port 1
[ 0.004664] [00009cdf] libusb: debug [linux_get_device_address] getting address for device: usb2 detached: 0
[ 0.004670] [00009cdf] libusb: debug [linux_get_device_address] scan usb2
[ 0.004696] [00009cdf] libusb: debug [linux_get_device_address] bus=2 dev=1
[ 0.004701] [00009cdf] libusb: debug [linux_enumerate_device] busnum 2 devaddr 1 session_id 513
[ 0.004705] [00009cdf] libusb: debug [linux_enumerate_device] allocating new device for 2/1 (session 513)
[ 0.004779] [00009cdf] libusb: debug [linux_get_device_address] getting address for device: 2-1 detached: 0
[ 0.004785] [00009cdf] libusb: debug [linux_get_device_address] scan 2-1
[ 0.004811] [00009cdf] libusb: debug [linux_get_device_address] bus=2 dev=2
[ 0.004816] [00009cdf] libusb: debug [linux_enumerate_device] busnum 2 devaddr 2 session_id 514
[ 0.004820] [00009cdf] libusb: debug [linux_enumerate_device] allocating new device for 2/2 (session 514)
[ 0.004845] [00009cdf] libusb: debug [linux_get_parent_info] Dev 0x7f30d51a6750 (2-1) has parent 0x7f30d51a6240 (usb2) port 1
[ 0.004907] [00009cdf] libusb: debug [linux_get_device_address] getting address for device: 2-1.8 detached: 0
[ 0.004912] [00009cdf] libusb: debug [linux_get_device_address] scan 2-1.8
[ 0.004939] [00009cdf] libusb: debug [linux_get_device_address] bus=2 dev=3
[ 0.004944] [00009cdf] libusb: debug [linux_enumerate_device] busnum 2 devaddr 3 session_id 515
[ 0.004948] [00009cdf] libusb: debug [linux_enumerate_device] allocating new device for 2/3 (session 515)
[ 0.004973] [00009cdf] libusb: debug [linux_get_parent_info] Dev 0x7f30d51a6ca0 (2-1.8) has parent 0x7f30d51a6750 (2-1) port 8
[ 0.005035] [00009cdf] libusb: debug [linux_get_device_address] getting address for device: 2-1.8.1 detached: 0
[ 0.005041] [00009cdf] libusb: debug [linux_get_device_address] scan 2-1.8.1
[ 0.005068] [00009cdf] libusb: debug [linux_get_device_address] bus=2 dev=4
[ 0.005073] [00009cdf] libusb: debug [linux_enumerate_device] busnum 2 devaddr 4 session_id 516
[ 0.005077] [00009cdf] libusb: debug [linux_enumerate_device] allocating new device for 2/4 (session 516)
[ 0.005102] [00009cdf] libusb: debug [linux_get_parent_info] Dev 0x7f30d51a85d0 (2-1.8.1) has parent 0x7f30d51a6ca0 (2-1.8) port 1
[ 0.005172] [00009cdf] libusb: debug [linux_get_device_address] getting address for device: 2-1.8.1.3 detached: 0
[ 0.005178] [00009cdf] libusb: debug [linux_get_device_address] scan 2-1.8.1.3
[ 0.005206] [00009cdf] libusb: debug [linux_get_device_address] bus=2 dev=8
[ 0.005211] [00009cdf] libusb: debug [linux_enumerate_device] busnum 2 devaddr 8 session_id 520
[ 0.005215] [00009cdf] libusb: debug [linux_enumerate_device] allocating new device for 2/8 (session 520)
[ 0.005241] [00009cdf] libusb: debug [linux_get_parent_info] Dev 0x7f30d51a8a80 (2-1.8.1.3) has parent 0x7f30d51a85d0 (2-1.8.1) port 3
[ 0.005303] [00009cdf] libusb: debug [linux_get_device_address] getting address for device: 2-1.8.2 detached: 0
[ 0.005309] [00009cdf] libusb: debug [linux_get_device_address] scan 2-1.8.2
[ 0.005336] [00009cdf] libusb: debug [linux_get_device_address] bus=2 dev=5
[ 0.005341] [00009cdf] libusb: debug [linux_enumerate_device] busnum 2 devaddr 5 session_id 517
[ 0.005345] [00009cdf] libusb: debug [linux_enumerate_device] allocating new device for 2/5 (session 517)
[ 0.005370] [00009cdf] libusb: debug [linux_get_parent_info] Dev 0x7f30d51a8f50 (2-1.8.2) has parent 0x7f30d51a6ca0 (2-1.8) port 2
[ 0.005436] [00009cdf] libusb: debug [usbi_add_pollfd] add fd 664 events 1
[ 0.005446] [00009cdf] libusb: debug [usbi_io_init] using timerfd for timeouts
[ 0.005450] [00009cdf] libusb: debug [usbi_add_pollfd] add fd 666 events 1
[ 0.005455] [00009cdf] libusb: debug [libusb_get_device_list] 
[ 0.005461] [00009cdf] libusb: debug [discovered_devs_append] need to increase capacity
[ 0.005467] [00009cdf] libusb: debug [libusb_get_device_descriptor] 
[ 0.005470] [00009cdf] libusb: debug [libusb_get_device_descriptor] 
[ 0.005474] [00009cdf] libusb: debug [libusb_get_device_descriptor] 
[ 0.005477] [00009cdf] libusb: debug [libusb_get_device_descriptor] 
[ 0.005481] [00009cdf] libusb: debug [libusb_get_device_descriptor] 
[ 0.005484] [00009cdf] libusb: debug [libusb_get_device_descriptor] 
[ 0.005488] [00009cdf] libusb: debug [libusb_get_device_descriptor] 
[ 0.005491] [00009cdf] libusb: debug [libusb_get_device_descriptor] 
[ 0.005494] [00009cdf] libusb: debug [libusb_get_device_descriptor] 
[ 0.005498] [00009cdf] libusb: debug [libusb_get_device_descriptor] 
[ 0.005501] [00009cdf] libusb: debug [libusb_get_device_descriptor] 
[ 0.005504] [00009cdf] libusb: debug [libusb_open] open 3.3
[ 0.266124] [00009cdf] libusb: debug [usbi_add_pollfd] add fd 667 events 4
[ 0.266179] [00009cdf] libusb: debug [libusb_get_device_descriptor] 
[ 0.266198] [00009cdf] libusb: debug [libusb_get_config_descriptor] index 0
[ 0.266223] [00009cdf] libusb: debug [libusb_get_configuration] 
[ 0.266320] [00009cdf] libusb: debug [libusb_get_configuration] active config 1
[ 0.267084] [00009cdf] libusb: debug [libusb_alloc_transfer] transfer 0x7f30d5193360
[ 0.267123] [00009cdf] libusb: debug [libusb_submit_transfer] transfer 0x7f30d5193360
[ 0.267133] [00009cdf] libusb: debug [add_to_flying_list] arm timerfd for timeout in 10000ms (first in line)
[ 0.267223] [00009cdf] libusb: debug [libusb_handle_events_timeout_completed] doing our own event handling
[ 0.267243] [00009cdf] libusb: debug [handle_events] poll fds modified, reallocating
[ 0.267270] [00009cdf] libusb: debug [handle_events] poll() 3 fds with timeout in 60000ms
[ 0.267347] [00009cdf] libusb: debug [handle_events] poll() returned 1
[ 0.267378] [00009cdf] libusb: debug [reap_for_handle] urb type=2 status=0 transferred=0
[ 0.267394] [00009cdf] libusb: debug [handle_control_completion] handling completion status 0
[ 0.267407] [00009cdf] libusb: debug [disarm_timerfd] 
[ 0.267423] [00009cdf] libusb: debug [usbi_handle_transfer_completion] transfer 0x7f30d5193360 has callback 0x7f3121ea8fc0
[ 0.267438] [00009cdf] libusb: debug [sync_transfer_cb] actual_length=0
[ 0.267454] [00009cdf] libusb: debug [libusb_free_transfer] transfer 0x7f30d5193360
[ 0.267657] [00009cdf] libusb: debug [libusb_alloc_transfer] transfer 0x7f30d4b6e250
[ 0.267682] [00009cdf] libusb: debug [libusb_submit_transfer] transfer 0x7f30d4b6e250
[ 0.267692] [00009cdf] libusb: debug [add_to_flying_list] arm timerfd for timeout in 10000ms (first in line)
[ 0.267724] [00009cdf] libusb: debug [libusb_handle_events_timeout_completed] doing our own event handling
[ 0.267736] [00009cdf] libusb: debug [handle_events] poll() 3 fds with timeout in 60000ms
[ 0.267855] [00009cdf] libusb: debug [handle_events] poll() returned 1
[ 0.267894] [00009cdf] libusb: debug [reap_for_handle] urb type=2 status=0 transferred=0
[ 0.267911] [00009cdf] libusb: debug [handle_control_completion] handling completion status 0
[ 0.267923] [00009cdf] libusb: debug [disarm_timerfd] 
[ 0.267937] [00009cdf] libusb: debug [usbi_handle_transfer_completion] transfer 0x7f30d4b6e250 has callback 0x7f3121ea8fc0
[ 0.267949] [00009cdf] libusb: debug [sync_transfer_cb] actual_length=0
[ 0.267962] [00009cdf] libusb: debug [libusb_free_transfer] transfer 0x7f30d4b6e250
[ 0.268120] [00009cdf] libusb: debug [libusb_alloc_transfer] transfer 0x7f30d51a1f90
[ 0.268140] [00009cdf] libusb: debug [libusb_submit_transfer] transfer 0x7f30d51a1f90
[ 0.268151] [00009cdf] libusb: debug [add_to_flying_list] arm timerfd for timeout in 10000ms (first in line)
[ 0.268181] [00009cdf] libusb: debug [libusb_handle_events_timeout_completed] doing our own event handling
[ 0.268193] [00009cdf] libusb: debug [handle_events] poll() 3 fds with timeout in 60000ms
[ 0.268307] [00009cdf] libusb: debug [handle_events] poll() returned 1
[ 0.268346] [00009cdf] libusb: debug [reap_for_handle] urb type=2 status=0 transferred=0
[ 0.268361] [00009cdf] libusb: debug [handle_control_completion] handling completion status 0
[ 0.268373] [00009cdf] libusb: debug [disarm_timerfd] 
[ 0.268387] [00009cdf] libusb: debug [usbi_handle_transfer_completion] transfer 0x7f30d51a1f90 has callback 0x7f3121ea8fc0
[ 0.268399] [00009cdf] libusb: debug [sync_transfer_cb] actual_length=0
[ 0.268412] [00009cdf] libusb: debug [libusb_free_transfer] transfer 0x7f30d51a1f90
[ 0.269524] [00009cdf] libusb: debug [libusb_claim_interface] interface 0
PsychHID-ERROR: Claiming USB interface 0 failed: LIBUSB_ERROR_BUSY - Resource busy.
[ 0.269584] [00009cdf] libusb: debug [libusb_kernel_driver_active] interface 0
PsychHID-ERROR: Interface 0 does not have any kernel drivers attached. Check if some other application is using the device already.
INTERNAL PSYCHTOOLBOX ERROR
	error:                PsychError_system
	general description:  Error reported by a system call
	specific description: The USB Bulk transfer failed.
	module name:          PsychHID
	subfunction call:     USBBulkTransfer
	file name:            /home/kleinerm/projects/OpenGLPsychtoolbox/Psychtoolbox-3/PsychSourceGL/Source/Common/PsychHID/PsychHIDUSBControlTransfer.c
	function name:        PSYCHHIDUSBBulkTransfer
	line number:          182
Error using PsychHID
See error message printed above.

Error in spyderXComProtocol>bulkTransfer (line 235)
PsychHID('USBBulkTransfer', usbHandle, 1, numel(cmd), cmd);

Error in spyderXComProtocol (line 42)
        out = bulkTransfer(usbHandle, uint8([0xd9 0x42 0x33 0x00 0x00]), 28);

Best and thank you again for your warm help.
-Yang

Ok, that was helpful, and 8 work hours later we are ready for the next test.
Grab a new PsychHID.mexa64 from my GitHub:

https://github.com/kleinerm/Psychtoolbox-3/raw/master/Psychtoolbox/PsychBasic/PsychHID.mexa64

Retest again, after closing Matlab, unplugging and replugging your SpyderX and
restarting Matlab. PsychHID should try to fix the problem and present you with a
little essay about what went likely wrong, and how to fix it. If I am right, then this
is a bug in your spyderXComProtocol.m script. Let’s see how this goes…

[Time spent: 44 hours!!]

Dear Mario,

Great!!! it works!!

I will carefully check my spyderXComProtocol.m script to fix the possible bug caused by my script (I have not checked it yet), and will test PsychHID in Windows ASAP.

Thank you very very much for your warm and kind help!
Best
-Yang