response to 19610

Hi

I tested both a USB1208FS-Plus and a USB1608FS with better results for the latter. So it may well be that the 1208FS-Plus version is not compatible. 

So I continued testing with 1608FS
I did reboot my system before. For some reason the Matlab GUI and -nojvm still give different results. In the matlab GUI this is the output for both PsychHID('Devices') and PsychHIDDAQS (exactly the same): 

1x12 struct array with fields: 


    usagePageValue 

    usageValue 

    usageName 

    index 

    transport 

    vendorID 

    productID 

    version 

    manufacturer 

    product 

    serialNumber 

    locationID 

    interfaceID 

    totalElements 

    features 

    inputs 

    outputs 

    collections 

    axes 

    buttons 

    hats 

    sliders 

    dials 

    wheels 




If I run DaqTest in the matlab GUI this is what I get:

Yay. I found a USB-1608FS daq!  Serial number is: 01243F66

Direct your attention to the LED on the device and then click the "okay" button here:

Press any key to continue.

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:     SetReport

file name:            Common/PsychHID/PsychHIDHelpers.c

function name:        PsychHIDGetDeviceRecordPtrFromIndex

line number:          250

PTB-INFO: Display ':0' : X-Screen 0 : Assigning primary output as 0 with RandR-CRTC 0 and GPU-CRTC 0.

Error using PsychHID

See error message printed above.


Error in DaqBlinkLED (line 36)

err=PsychHID('SetReport',daq,2,reportId,TheReport); % Blink LED


Error in DaqTest (line 85)

      err=DaqBlinkLED(daq);



If I run DaqTest in ptb3-matlab -nojvm I get slightly further in the test procedure, but there is still a failure...

Yay. I found a USB-1608FS daq!  Serial number is: 01243F66 

Direct your attention to the LED on the device and then click the "okay" button here: 

Press any key to continue. 

Did the LED just blink for you? 

0 = No 

1 = Yes 

Choose your answer: 

Please click yes or no... do not close the window any other way! 

Press any key to continue. 

Did the LED blink for you earlier? 

0 = No 

1 = Yes 

Choose your answer: 1 


** If you want to run all the tests we have here, you should connect analog 

** port 0 (pin 1) to the first bit of the digital port (pin 21).  If you would 

** like to test your counter, you should also connect pin 21 to the counter 

** terminal (pin 38).  Measurement Computing recommends that you ground any 

** analog ports that you are not using.  To follow that advice, connect pin 3 

** to pin 4, pin 5 to pin 6, pin 7 to pin 8, pin 9 to pin 10, pin 11 to pin 12, 

** pin 13 to pin 14, and pin 15 to pin 16. 


A lot of information will be written to the Matlab command window.  You can ignore most of it, but you should look at the command window now. 

Press any key to continue. 



Moving on to test mode changes... 

Successfully toggled sync status bit.  Moving on... 

Successfully toggled trigger status bit.  Moving on... 

Successfully toggled program status bit.  Moving on... 



The following tests assess all the USB-1608FS commands, reporting any errors. 


** DIGITAL COMMANDS 

** DaqDConfigPort, DaqDIn, and DaqDOut. 


DaqDConfigPort: configuring digital port for output. 


DaqDOut: random test patterns on DIO port. This is a basic functionality 

test, showing that we can indeed read back what we wrote. 

DaqDOut: 208. 


DaqDIn: reading digital port. 

DaqDIn: 208. 

Data read matches data written.  Excellent! 


About to test ability to configure, read, and write individual bits...Error using bitcmp 

BITCMP(A,N) does not accept integer valued input N. Use BITCMP(A,ASSUMEDTYPE) 

instead. 


Error in DaqTest (line 563) 

  fprintf('\nTwo''s complement of randomly chosen value: %d\n',bitcmp(a,8));



XXX---In PSYCHTOOLBOX@yahoogroups.com, <freddeconinck@...> wrote :

Hi

I tested both a USB1208FS-Plus and a USB1608FS with better results for the latter. So it may well be that the 1208FS-Plus version is not compatible. 

So I continued testing with 1608FS
I did reboot my system before. For some reason the Matlab GUI and -nojvm still give different results. In the matlab GUI this is the output for both PsychHID('Devices') and PsychHIDDAQS (exactly the same): 

1x12 struct array with fields: 


    usagePageValue 

    usageValue 

    usageName 

    index 

    transport 

    vendorID 

    productID 

    version 

    manufacturer 

    product 

    serialNumber 

    locationID 

    interfaceID 

    totalElements 

    features 

    inputs 

    outputs 

    collections 

    axes 

    buttons 

    hats 

    sliders 

    dials 

    wheels 


-> Obviously i wanted you to report the content of the returned arrays, not the summary you posted here. e.g., devs = PsychHID('Devices'), then the printout of devs(1), devs(2), ... devs(12), for both Matlab -nojvm and Matlab with GUI, so i can compare the different cases.



If I run DaqTest in the matlab GUI this is what I get:

Yay. I found a USB-1608FS daq!  Serial number is: 01243F66

Direct your attention to the LED on the device and then click the "okay" button here:

Press any key to continue.

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:     SetReport

file name:            Common/PsychHID/PsychHIDHelpers.c

function name:        PsychHIDGetDeviceRecordPtrFromIndex

line number:          250

PTB-INFO: Display ':0' : X-Screen 0 : Assigning primary output as 0 with RandR-CRTC 0 and GPU-CRTC 0.

Error using PsychHID

See error message printed above.


Error in DaqBlinkLED (line 36)

err=PsychHID('SetReport',daq,2,reportId,TheReport); % Blink LED


Error in DaqTest (line 85)

      err=DaqBlinkLED(daq);


-> That's weird. But difficult to test for me. I don't have access to any USB-DAQ device anymore to test the DAQ toolbox. Donations of equipment welcome...




If I run DaqTest in ptb3-matlab -nojvm I get slightly further in the test procedure, but there is still a failure...

Yay. I found a USB-1608FS daq!  Serial number is: 01243F66 

Direct your attention to the LED on the device and then click the "okay" button here: 

Press any key to continue. 

Did the LED just blink for you? 

0 = No 

1 = Yes 

Choose your answer: 

Please click yes or no... do not close the window any other way! 

Press any key to continue. 

Did the LED blink for you earlier? 

0 = No 

1 = Yes 

Choose your answer: 1 


** If you want to run all the tests we have here, you should connect analog 

** port 0 (pin 1) to the first bit of the digital port (pin 21).  If you would 

** like to test your counter, you should also connect pin 21 to the counter 

** terminal (pin 38).  Measurement Computing recommends that you ground any 

** analog ports that you are not using.  To follow that advice, connect pin 3 

** to pin 4, pin 5 to pin 6, pin 7 to pin 8, pin 9 to pin 10, pin 11 to pin 12, 

** pin 13 to pin 14, and pin 15 to pin 16. 


A lot of information will be written to the Matlab command window.  You can ignore most of it, but you should look at the command window now. 

Press any key to continue. 



Moving on to test mode changes... 

Successfully toggled sync status bit.  Moving on... 

Successfully toggled trigger status bit.  Moving on... 

Successfully toggled program status bit.  Moving on... 



The following tests assess all the USB-1608FS commands, reporting any errors. 


** DIGITAL COMMANDS 

** DaqDConfigPort, DaqDIn, and DaqDOut. 


DaqDConfigPort: configuring digital port for output. 


DaqDOut: random test patterns on DIO port. This is a basic functionality 

test, showing that we can indeed read back what we wrote. 

DaqDOut: 208. 


DaqDIn: reading digital port. 

DaqDIn: 208. 

Data read matches data written.  Excellent! 


About to test ability to configure, read, and write individual bits...Error using bitcmp 

BITCMP(A,N) does not accept integer valued input N. Use BITCMP(A,ASSUMEDTYPE) 

instead. 


Error in DaqTest (line 563) 

  fprintf('\nTwo''s complement of randomly chosen value: %d\n',bitcmp(a,8));


-> The answer to that seems to be that there are idiots at work at Mathworks:


How do I use the previous syntax of BITCMP to specify the number of returned in MATLAB (R2013b)? - MATLAB Answers - MATLAB Central


I really wonder how bad of a job at software engineering and basic backwards compatibility one can do as a commercial software company, selling a very expensive product, and still have paying customers?


So they changed the behaviour of bitcmp() somewhere around R2013b, without any concern for backwards compatibility, so our code only works with older Matlab versions or Octave, but not more recent ones.


I'd recommend you simply "sudo apt-get install octave-psychtoolbox-3" and use Octave to perform your remaining tests. Or hack yourself through DaqTest.m to do the job Mathworks should be doing.


-mario


Btw. additionally wrt. the thing not working under Matlab with GUI enabled.

Start Matlab from a terminal window.

in Matlab:

clear all;
PsychTweak('LibUSBDebug', 4)
DaqTest;

After the failure, what's the output in *the terminal window* from which you started matlab? There should be lots of debug output from libusb.

One cause of failure could be if DaqTest tries to execute PsychHID('SetReport') on a device whose interface has been already claimed by some running process - There can only be one. I'm not sure why Matlab would try to do that on your DAQ device when running in GUI mode, but who knows? Maybe some kind of toolbox you have installed tries to access the device, or maybe some of Matlab's Java component tries to do that when the Java based GUI is active?

-mario


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

XXX---In PSYCHTOOLBOX@yahoogroups.com, <freddeconinck@...> wrote :

Hi

I tested both a USB1208FS-Plus and a USB1608FS with better results for the latter. So it may well be that the 1208FS-Plus version is not compatible. 

So I continued testing with 1608FS
I did reboot my system before. For some reason the Matlab GUI and -nojvm still give different results. In the matlab GUI this is the output for both PsychHID('Devices') and PsychHIDDAQS (exactly the same): 

1x12 struct array with fields: 


    usagePageValue 

    usageValue 

    usageName 

    index 

    transport 

    vendorID 

    productID 

    version 

    manufacturer 

    product 

    serialNumber 

    locationID 

    interfaceID 

    totalElements 

    features 

    inputs 

    outputs 

    collections 

    axes 

    buttons 

    hats 

    sliders 

    dials 

    wheels 


-> Obviously i wanted you to report the content of the returned arrays, not the summary you posted here. e.g., devs = PsychHID('Devices'), then the printout of devs(1), devs(2), ... devs(12), for both Matlab -nojvm and Matlab with GUI, so i can compare the different cases.



If I run DaqTest in the matlab GUI this is what I get:

Yay. I found a USB-1608FS daq!  Serial number is: 01243F66

Direct your attention to the LED on the device and then click the "okay" button here:

Press any key to continue.

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:     SetReport

file name:            Common/PsychHID/PsychHIDHelpers.c

function name:        PsychHIDGetDeviceRecordPtrFromIndex

line number:          250

PTB-INFO: Display ':0' : X-Screen 0 : Assigning primary output as 0 with RandR-CRTC 0 and GPU-CRTC 0.

Error using PsychHID

See error message printed above.


Error in DaqBlinkLED (line 36)

err=PsychHID('SetReport',daq,2,reportId,TheReport); % Blink LED


Error in DaqTest (line 85)

      err=DaqBlinkLED(daq);


-> That's weird. But difficult to test for me. I don't have access to any USB-DAQ device anymore to test the DAQ toolbox. Donations of equipment welcome...




If I run DaqTest in ptb3-matlab -nojvm I get slightly further in the test procedure, but there is still a failure...

Yay. I found a USB-1608FS daq!  Serial number is: 01243F66 

Direct your attention to the LED on the device and then click the "okay" button here: 

Press any key to continue. 

Did the LED just blink for you? 

0 = No 

1 = Yes 

Choose your answer: 

Please click yes or no... do not close the window any other way! 

Press any key to continue. 

Did the LED blink for you earlier? 

0 = No 

1 = Yes 

Choose your answer: 1 


** If you want to run all the tests we have here, you should connect analog 

** port 0 (pin 1) to the first bit of the digital port (pin 21).  If you would 

** like to test your counter, you should also connect pin 21 to the counter 

** terminal (pin 38).  Measurement Computing recommends that you ground any 

** analog ports that you are not using.  To follow that advice, connect pin 3 

** to pin 4, pin 5 to pin 6, pin 7 to pin 8, pin 9 to pin 10, pin 11 to pin 12, 

** pin 13 to pin 14, and pin 15 to pin 16. 


A lot of information will be written to the Matlab command window.  You can ignore most of it, but you should look at the command window now. 

Press any key to continue. 



Moving on to test mode changes... 

Successfully toggled sync status bit.  Moving on... 

Successfully toggled trigger status bit.  Moving on... 

Successfully toggled program status bit.  Moving on... 



The following tests assess all the USB-1608FS commands, reporting any errors. 


** DIGITAL COMMANDS 

** DaqDConfigPort, DaqDIn, and DaqDOut. 


DaqDConfigPort: configuring digital port for output. 


DaqDOut: random test patterns on DIO port. This is a basic functionality 

test, showing that we can indeed read back what we wrote. 

DaqDOut: 208. 


DaqDIn: reading digital port. 

DaqDIn: 208. 

Data read matches data written.  Excellent! 


About to test ability to configure, read, and write individual bits...Error using bitcmp 

BITCMP(A,N) does not accept integer valued input N. Use BITCMP(A,ASSUMEDTYPE) 

instead. 


Error in DaqTest (line 563) 

  fprintf('\nTwo''s complement of randomly chosen value: %d\n',bitcmp(a,8));


-> The answer to that seems to be that there are idiots at work at Mathworks:


How do I use the previous syntax of BITCMP to specify the number of returned in MATLAB (R2013b)? - MATLAB Answers - MATLAB Central


I really wonder how bad of a job at software engineering and basic backwards compatibility one can do as a commercial software company, selling a very expensive product, and still have paying customers?


So they changed the behaviour of bitcmp() somewhere around R2013b, without any concern for backwards compatibility, so our code only works with older Matlab versions or Octave, but not more recent ones.


I'd recommend you simply "sudo apt-get install octave-psychtoolbox-3" and use Octave to perform your remaining tests. Or hack yourself through DaqTest.m to do the job Mathworks should be doing.


-mario


Hello,

I'd like to add a comment about the workaround. MatlabCentral suggests the use of eval(), which is very slow. Another workaround, I believe, is to take the full bitwise complement and then apply a mask using bitwise-AND. Therefore, line 893 of DaqAInScan.m would go from:

data(ix) = -bitcmp(data(ix),12)-1;

to

data( ix ) = -bitand ( bitcmp ( data( ix ) , 'uint64' ) , 2 ^ 12 - 1 , 'uint64' )  -  1 ;

The effect of each operation can be observed using bitget.

Cheers,
Jackson



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

ps - It turns out that it matters what kind of integer you specify. 'uint16' should be used instead:

data( ix ) = -bitand ( bitcmp ( data( ix ) , 'uint16' ) , 2 ^ 12 - 1 , 'uint16' )  -  1 ;

-> Is this something you're guessing or did you actually test it? If you can guarantee that it will work, i will incorporate that change into Daq toolbox.

thanks,
-mario