PsychHID- Error running PsychHIDTest

Hi,

I recently downloaded the PsychToolBox following the instruction found at 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')  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
    error:                PsychError_system
    general description:  Error reported by a system call
    specific description: HIDLIB Failed to open USB device!
    module name:          PsychHID
    subfunction call:     GetReport
    file name:            Common\PsychHID\PsychHIDHelpers.c
    function name:        PsychHIDGetDeviceRecordPtrFromIndex
    line number:          252
Error using PsychHID
See error message printed above.

Error in PsychHIDTest (line 125)
        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!!!

  Maaike



Did you look at the following page.


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
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!
Thank you. Ill look over the documentation.
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

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
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
Hi Natasa,

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

-mario
XX---In PSYCHTOOLBOX@yahoogroups.com, <n_k_rush@...> wrote :

Hi Mario, 

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. 

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'. The script works fine on my Mac, but not on my PC. :( 

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