# PsychHID- Error running PsychHIDTest

**URL:** <https://psychtoolbox.discourse.group/t/psychhid-error-running-psychhidtest/482>\
**Category:** Uncategorized\
**Created:** [June 30, 2014, 9:55pm UTC](https://psychtoolbox.discourse.group/t/psychhid-error-running-psychhidtest/482 "2014-06-30T21:55:36Z")\
**Posts on this page:** 9\
**Page:** 1

<div class="post-metadata">

**Author:** ![Allen\_Ingling](https://avatars.discourse-cdn.com/v4/letter/a/a183cd/32.png) [@Allen\_Ingling](https://psychtoolbox.discourse.group/u/Allen_Ingling)\
**Post date:** [June 30, 2014, 9:55pm UTC](https://psychtoolbox.discourse.group/t/psychhid-error-running-psychhidtest/482/1 "2014-06-30T21:55:36Z")

</div>

Hi,  
  
I recently downloaded the PsychToolBox following the instruction found at [http://psychtoolbox.org/PsychtoolboxDownload](http://psychtoolbox.org/PsychtoolboxDownload). I am looking to use PsychHID to control a filter wheel which is a HID compliant device. However, I am having problems getting PsychHID to run properly.  
  
I can use PsychHID('Devices')&nbsp; and PsychHID('NumDevices') with no problem. Running PsychHIDTest I get the following error:  
TestPsychHID  
Making a list of all your HID-compliant devices. ...  
  
You have 3 HID-compliant devices:  
device 1: TBD, DELL, DELL USB Keyboard, 0 inputs, 0 outputs, serialNumber ?  
device 2: TBD, S, , 0 inputs, 0 outputs, serialNumber ?  
device 3: TBD, DELL, DELL USB Laser Mouse, 0 inputs, 0 outputs, serialNumber ?  
  
  
Test 2 mice.  
INTERNAL PSYCHTOOLBOX ERROR  
&nbsp;&nbsp;&nbsp; error:&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; PsychError\_system  
&nbsp;&nbsp;&nbsp; general description:&nbsp; Error reported by a system call  
&nbsp;&nbsp;&nbsp; specific description: HIDLIB Failed to open USB device!  
&nbsp;&nbsp;&nbsp; module name:&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; PsychHID  
&nbsp;&nbsp;&nbsp; subfunction call:&nbsp;&nbsp;&nbsp;&nbsp; GetReport  
&nbsp;&nbsp;&nbsp; file name:&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Common\PsychHID\PsychHIDHelpers.c  
&nbsp;&nbsp;&nbsp; function name:&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; PsychHIDGetDeviceRecordPtrFromIndex  
&nbsp;&nbsp;&nbsp; line number:&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 252  
Error using PsychHID  
See error message printed above.  
  
Error in PsychHIDTest (line 125)  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; r = PsychHID('GetReport',di,1,0,8);  
  
Could anyone explain what is happening and how to fix it?  
  
I also cannot run usbHandle = PsychHID('OpenUSBDevice', vendorID, productID); and I get: 'Failed to open the specified type of generic USB device. Make sure it is plugged in or not already open." My device is plugged in but how do I check if it is already open and then close it?  
  
I am running MATLAB R2014a version 8.3.0 64 bit on Windows 7.  
  
Please let me know if I am missing information  
  
Thank you!!!  
  

&nbsp; Maaike

---

<div class="post-metadata">

**Author:** ![peter.scarfe](https://avatars.discourse-cdn.com/v4/letter/p/e9a140/32.png) [@peter.scarfe](https://psychtoolbox.discourse.group/u/peter.scarfe)\
**Post date:** [July 1, 2014, 8:44am UTC](https://psychtoolbox.discourse.group/t/psychhid-error-running-psychhidtest/482/2 "2014-07-01T08:44:27Z")

</div>

Did you look at the following page.
  

[http://docs.psychtoolbox.org/PsychHID](http://docs.psychtoolbox.org/PsychHID)

&nbsp;

---

<div class="post-metadata">

**Author:** ![mariokleiner](https://avatars.discourse-cdn.com/v4/letter/m/13edae/32.png) [@mariokleiner](https://psychtoolbox.discourse.group/u/mariokleiner)\
**Post date:** [July 2, 2014, 12:51am UTC](https://psychtoolbox.discourse.group/t/psychhid-error-running-psychhidtest/482/3 "2014-07-02T00:51:50Z")

</div>

The failure of PsychHidTest on Windows is expected, although this might be unexpected. MS-Windows doesn't allow direct low level HID access to keyboards or mice, so PsychHID fails as soon as it tries to access a keyboard or mouse directly. I'll modify PsychHIDTest to skip to those tests in the future and avoid the confusion.  
  
So essentially what you can do is enumerate devices via PsychHID('Devices') and find the deviceIndex of your device - probably device 2 from that output you posted - the only one not a mouse or keyboard. I don't know what a filter wheel is, but its docu should then explain what kind of hid reports with which exact parameters you can send or receive via PsychHID('SetReport/GetReport').  
  
Another problem, if you'd get some "failed to open device" error with known valid requests, could be that some other hid driver on your system would claim exclusive ownership of the device.  
  
-mario

---

<div class="post-metadata">

**Author:** ![maaike.vankooten](https://avatars.discourse-cdn.com/v4/letter/m/2acd7d/32.png) [@maaike.vankooten](https://psychtoolbox.discourse.group/u/maaike.vankooten)\
**Post date:** [July 2, 2014, 4:07pm UTC](https://psychtoolbox.discourse.group/t/psychhid-error-running-psychhidtest/482/4 "2014-07-02T16:07:19Z")

</div>

Hi Mario,  
  
Thanks for the reply.   
  
Is this the correct sytax: usbHandle = PsychHID('OpenUSBDevice', vendorID, productID)? I am correct in assuming that deviceID=productID? If so I think the problem might be, as you stated, another hid driver is claiming exclusive ownership of the device. Is there anyway of pinpointing which one and preventing this from happening?  
  
Thank you!

---

<div class="post-metadata">

**Author:** ![maaike.vankooten](https://avatars.discourse-cdn.com/v4/letter/m/2acd7d/32.png) [@maaike.vankooten](https://psychtoolbox.discourse.group/u/maaike.vankooten)\
**Post date:** [July 2, 2014, 4:07pm UTC](https://psychtoolbox.discourse.group/t/psychhid-error-running-psychhidtest/482/5 "2014-07-02T16:07:38Z")

</div>

Thank you. Ill look over the documentation.

---

<div class="post-metadata">

**Author:** ![mariokleiner](https://avatars.discourse-cdn.com/v4/letter/m/13edae/32.png) [@mariokleiner](https://psychtoolbox.discourse.group/u/mariokleiner)\
**Post date:** [July 3, 2014, 1:17am UTC](https://psychtoolbox.discourse.group/t/psychhid-error-running-psychhidtest/482/6 "2014-07-03T01:17:54Z")

</div>

Assuming this is the Starlight Express "Universal Filter Wheel" - the first Google hit for "filter wheel", referring t o page 4 of this manual:  
  
[http://www.sxccd.com/handbooks/The%20Universal%20Filter%20Wheel.pdf](http://www.sxccd.com/handbooks/The%20Universal%20Filter%20Wheel.pdf)  
  
I'd try this to see if it gets the wheel moving:  
  
With filterNumber being the filter number, and filterWheel being the index of your device in the output of PsychHID('Devices'):  
  
err = PsychHID('SetReport', filterWheel, 2, 0, uint8([filterNumber 0]));  
  
or  
  
err = PsychHID('SetReport', filterWheel, 2, filterNumber, uint8([0 0]));  
  
Calls of the form:  
  
[rep, err] = PsychHID('GetReport', filterWheel, 1, 0, 2);  
  
or maybe:  
  
[rep, err] = PsychHID('GetReport', filterWheel, 1, 0, 3);  
  
Should give you the selected filterNumber and total number of filters from the device in the 1st and 2nd element of rep(), or maybe the 2nd and 3rd element of it.  
  
Maybe.  
-mario

---

<div class="post-metadata">

**Author:** ![mariokleiner](https://avatars.discourse-cdn.com/v4/letter/m/13edae/32.png) [@mariokleiner](https://psychtoolbox.discourse.group/u/mariokleiner)\
**Post date:** [July 4, 2014, 5:18pm UTC](https://psychtoolbox.discourse.group/t/psychhid-error-running-psychhidtest/482/7 "2014-07-04T17:18:56Z")

</div>

Good. Can you post the commands - or an M-File of yours - which make it work. I'd like to know which of the commands posted above (or all of them?) work, and also good to have this in case anybody else ever needs to get this working.  
  
thanks,  
-mario

---

<div class="post-metadata">

**Author:** ![mariokleiner](https://avatars.discourse-cdn.com/v4/letter/m/13edae/32.png) [@mariokleiner](https://psychtoolbox.discourse.group/u/mariokleiner)\
**Post date:** [July 5, 2017, 11:44pm UTC](https://psychtoolbox.discourse.group/t/psychhid-error-running-psychhidtest/482/8 "2017-07-05T23:44:52Z")

</div>

Hi Natasa,  
  
what are you trying to achieve? That list contains two devices, just not any useful info about them.  
  
-mario

---

<div class="post-metadata">

**Author:** ![mariokleiner](https://avatars.discourse-cdn.com/v4/letter/m/13edae/32.png) [@mariokleiner](https://psychtoolbox.discourse.group/u/mariokleiner)\
**Post date:** [July 6, 2017, 9:09pm UTC](https://psychtoolbox.discourse.group/t/psychhid-error-running-psychhidtest/482/9 "2017-07-06T21:09:32Z")

</div>

XX---In PSYCHTOOLBOX@yahoogroups.com, \<n\_k\_rush@...\> wrote :  

  

Hi Mario,&nbsp;
  

I wanted my script to find the number of keyboards attached to my PC (for this I use the GetKeyboardIndices function), and to identify the 'Experimenter keyboard' if 2 or more keyboards are attached.&nbsp;

  

The script checks for keyboard presses on each keyboard for intervals of 30 ms. When it finds a key press on one of the keyboards, it sets that keyboard as the 'Experimenter keyboard'.&nbsp;The script works fine on my Mac, but not on my PC. :(&nbsp;

  

Does this have to do with the fact that Windows does not allow full access to the HID device info, hence GetKeyboardIndices on PC returns for both keyboards only one keyboard index, i.e. kb = 0? Whereas the same function on Mac returns two keyboard indices, i.e. kb = 3, 4?

  
-\> Yes. MS-Windows doesn't support handling of individual keyboards or mice via our low-level functions. If you can upgrade or dual-boot to Linux then your approach would work.  
  
-mario  
  
  

Thank you

Natasa

&nbsp;
