CMU box mex file

Rachel Insler wrote:

>>
>>
>> ... one of the grad students had a question about a Psychtoolbox
>> function. The same question had been posted to the forum several
>> months ago by someone else with no reply, so, knowing that I had
>> worked with you, the grad student asked me if I could forward the
>> question to you to see if you a) knew the answer or b) knew whom we
>> might be able to direct the question to.
>>
>> The relevant posting is below:
>>
>> --- In psychtoolbox@y..., "kmuess" <muesseler@m...> wrote:
>> Hello!
>> I failed to use a new CMUBbox with a new USB Mac (via Keyspan
>> adapter) and the Mex files by Brian J. Stankiewicz. The error
>> message is always
>>
>> ??? Error in bbox
>> On line 1 ==> CMUBbox('Init');
>>
>> Brian has started a new position at UT Austin and promised to
>> take care of the problem in future, but I wonder if anybody else
>> already observed this error messages and found already a
>> solution for it.
>> Thanks
>> Jochen Muesseler
>> Munich
>> --- End forwarded message ---
>>
>> Itamar (the grad student) has encountered the same problem, using
>> newer computers and button boxes, although the function has worked
>> with older equipment. We were wondering if a fix had been developed
>> by someone to use a USB CMU Button Box with the Psychtoolbox?
>>
>> Barring that, we were wondering if there was a function that reads
>> directly from the serial port with very accurate timing?
>>
>> Thanks in advance for any help, advice, or steering in the right
>> direction you may be able to offer us.
>>
>>

Hi Rachel,

I have not used Brian Stankiewicz's MEX file for controlling the CMU
box. I have used the Keyspan serial adapter with a CMU box and here is
one thing that can go wrong with that: Back in the days when Macs had
buit-in serial ports, they had two built-in serial ports and each port
always had the same name on all Macs. Because on any Mac a program
could reliably find serial ports with those names, some Mac software
which controls the CMU box assumes that two serial ports exist and that
they have the conventional names. Even though the Keyspan adapter adds
two serial ports, those added ports are not given the same names as
built-in ports. Consequently, when some CMU box programs try to use a
serial port, they can not find one; They use a name which labels a
non-existing port rather than discovering the names of existing ports
and choosing from among them.

So here are some things to try:

1- The KeySpan control panel has an option to emulate one of the two
conventional ports. I think the old built-in port names are "printer"
and "phone" and the Keyspan adapter will only emulate the printer
port. So if the CMU MEX file expects to find the CMU box on the
printer port, then you are in luck. Set a Keyspan serial port to
emulate the printer port, make sure that you have the serial cable
connected to that port on the Keyspan adapter, and go.

2- Maybe the CMU MEX file lets you select the port name. In which case,
just choose the name of a port on the Keyspan adapter.

3- If he CMU MEX will not let you select a port name, then at least the
documentation might tell you which serial port it does use. If so, then
you could with certainty either verify that a fixed port name within the
CMU MEX file is the problem or rule it out as a possible cause.

4- If the MEX file insists on using the phone port, and the Keyspan
adapter will only emulate the printer port, then what ? Someone has
to find the port name string in the C source for the CMU box MEX file,
change the name to something matching one of the ports on the Keyspan
adapter, then recompile. I think I recall that Brian Stankiewicz.
mentioned in February that the CMU MEX project was a Symantic C project,
which makes that change a bit harder for those of us using the
CodeWarrior compiler or any other. If you can determine that the
problem is port naming, then I suggest contacting Brian about that.

Best,

Allen



>>
>>
>> ... the impetus for my writing to you (though I did want to say hi :)
>> ) was that one of the grad students had a question about a
>> Psychtoolbox function. The same question had been posted to the forum
>> several months ago by someone else with no reply, so, knowing that I
>> had worked with you, the grad student asked me if I could forward the
>> question to you to see if you a) knew the answer or b) knew whom we
>> might be able to direct the question to.
>>
>> The relevant posting is below:
>>
>> --- In psychtoolbox@y..., "kmuess" <muesseler@m...> wrote:
>> Hello!
>> I failed to use a new CMUBbox with a new USB Mac (via Keyspan
>> adapter) and the Mex files by Brian J. Stankiewicz. The error
>> message is always
>>
>> ??? Error in bbox
>> On line 1 ==> CMUBbox('Init');
>>
>> Brian has started a new position at UT Austin and promised to
>> take care of the problem in future, but I wonder if anybody else
>> already observed this error messages and found already a
>> solution for it.
>> Thanks
>> Jochen Muesseler
>> Munich
>> --- End forwarded message ---
>>
>> Itamar (the grad student) has encountered the same problem, using
>> newer computers and button boxes, although the function has worked
>> with older equipment. We were wondering if a fix had been developed
>> by someone to use a USB CMU Button Box with the Psychtoolbox?
>>
>> Barring that, we were wondering if there was a function that reads
>> directly from the serial port with very accurate timing?
>>
>> Thanks in advance for any help, advice, or steering in the right
>> direction you may be able to offer us.
>>
>>
Hi Dennis,

It seems to me that serial should work just fine (I don't seem to have
PsychSerial in my psychtoolbox version). However, looking through the
BBoxLibrary.c, it looks like there is a lot of hacking that might need to
be done.

I have not dug around in the CMU Bbox code for a long time (4 years) so I
don't know everything that should be done. Someone who is motivated to
get this done should be able to dig around the BBoxLibrary.c and figure
out a handful of routines that can be incorporated with serial.mex (or
PsychSerial.mex) to get the job done.

-Brian


On Tuesday, July 30, 2002, at 12:51 AM, Denis Pelli wrote:

> dear brian
>
> thanks for the donation.
>
> you might be able to save everyone a lot of trouble by answering a high
> level question. is there any reason to think that our general-purpose
> serial mex, PsychSerial.mex, would not be a perfectly good
> general-purpose solution to communicating with the CMU box?
>
> We just dropped CMETER.mex in favor of PsychSerial.mex. It's not trivial
> to implement good serial communications (e.g. CMUBbox hard coded the port
> instead of allowing the user to specify it), and it seems very
> inefficient to reinvent that wheel for each serial device.
>
> best
>
> denis
>
>
>
>> Hi All,
>>
>> I am making my CMUBbox mex file code available for anyone who might be
>> willing or able to port it over.
>>
>> The main problem is that the code currently looks for the CMUBbox for the
>> CMUbbox on the printer port. However, the Keyspan adaptor only simulates
>> the serial port. On line 79 of the code the statement is:
>>
>> bbox.port = bbox_PRINTER_PORT;
>>
>> I believe if you change this to:
>> bbox.port = bbox_MODEM_PORT
>>
>> it should work. You might have to do some digging in the CMUBBox
>> documentation to see what the appropriate constant name is for the serial
>> port. Allen, if you would like you are welcome to incorporat this into
>> the Psychtoolbox routines if you think it might help.
>>
>> Here is what I have. Please feel free to update it and complete the
>> port:
>>
>>
>>
>> http://psychtoolbox.org
>> POST a message to: psychtoolbox@yahoogroups.com
>> UNSUBSCRIBE by sending a blank message to:
>> psychtoolbox-unsubscribe@yahoogroups.com
>>
>> Your use of Yahoo! Groups is subject to http://docs.yahoo.com/info/terms/
>>
>>
>> Attachment converted: Wittgenstein:main.c (TEXT/SPM ) (000AA987)
>> Attachment converted: Wittgenstein:CMUBbox.m (TEXT/ALFA) (000AA988)
>> Attachment converted: Wittgenstein:BBoxLibrary.c (TEXT/SPM ) (000AA989)
>> Attachment converted: Wittgenstein:BBoxLibrary.h (TEXT/SPM ) (000AA98A)
>>
>>
>>
>> If you need anything else, let me know.
>>
>> -Brian
>>
>> On Monday, July 29, 2002, at 07:49 PM, Allen W. Ingling wrote:
>>
>>>
>>> Rachel Insler wrote:
>>>
>>>>>
>>>>>
>>>>> ... one of the grad students had a question about a Psychtoolbox
>>>>> function. The same question had been posted to the forum several
>>>>> months ago by someone else with no reply, so, knowing that I had
>>>>> worked with you, the grad student asked me if I could forward the
>>>>> question to you to see if you a) knew the answer or b) knew whom we
>>>>> might be able to direct the question to.
>>>>>
>>>>> The relevant posting is below:
>>>>>
>>>>> --- In psychtoolbox@y..., "kmuess" <muesseler@m...> wrote:
>>>>> Hello!
>>>>> I failed to use a new CMUBbox with a new USB Mac (via Keyspan
>>>>> adapter) and the Mex files by Brian J. Stankiewicz. The error
>>>>> message is always
>>>>>
>>>>> ??? Error in bbox
>>>>> On line 1 ==> CMUBbox('Init');
>>>>>
>>>>> Brian has started a new position at UT Austin and promised to
>>>>> take care of the problem in future, but I wonder if anybody else
>>>>> already observed this error messages and found already a
>>>>> solution for it.
>>>>> Thanks
>>>>> Jochen Muesseler
>>>>> Munich
>>>>> --- End forwarded message ---
>>>>>
>>>>> Itamar (the grad student) has encountered the same problem, using
>>>>> newer computers and button boxes, although the function has worked
>>>>> with older equipment. We were wondering if a fix had been developed
>>>>> by someone to use a USB CMU Button Box with the Psychtoolbox?
>>>>>
>>>>> Barring that, we were wondering if there was a function that reads
>>>>> directly from the serial port with very accurate timing?
>>>>>
>>>>> Thanks in advance for any help, advice, or steering in the right
>>>>> direction you may be able to offer us.
>>>>>
>>>
>>> Hi Rachel,
>>>
>>> I have not used Brian Stankiewicz's MEX file for controlling the CMU
>>> box. I have used the Keyspan serial adapter with a CMU box and here is
>>> one thing that can go wrong with that: Back in the days when Macs had
>>> buit-in serial ports, they had two built-in serial ports and each port
>>> always had the same name on all Macs. Because on any Mac a program
>>> could reliably find serial ports with those names, some Mac software
>>> which controls the CMU box assumes that two serial ports exist and that
>>> they have the conventional names. Even though the Keyspan adapter adds
>>> two serial ports, those added ports are not given the same names as
>>> built-in ports. Consequently, when some CMU box programs try to use a
>>> serial port, they can not find one; They use a name which labels a
>>> non-existing port rather than discovering the names of existing ports
>>> and choosing from among them.
>>>
>>> So here are some things to try:
>>>
>>> 1- The KeySpan control panel has an option to emulate one of the two
>>> conventional ports. I think the old built-in port names are "printer"
>>> and "phone" and the Keyspan adapter will only emulate the printer
>>> port. So if the CMU MEX file expects to find the CMU box on the
>>> printer port, then you are in luck. Set a Keyspan serial port to
>>> emulate the printer port, make sure that you have the serial cable
>>> connected to that port on the Keyspan adapter, and go.
>>>
>>> 2- Maybe the CMU MEX file lets you select the port name. In which case,
>>> just choose the name of a port on the Keyspan adapter.
>>>
>>> 3- If he CMU MEX will not let you select a port name, then at least the
>>> documentation might tell you which serial port it does use. If so, then
>>> you could with certainty either verify that a fixed port name within the
>>> CMU MEX file is the problem or rule it out as a possible cause.
>>>
>>> 4- If the MEX file insists on using the phone port, and the Keyspan
>>> adapter will only emulate the printer port, then what ? Someone has
>>> to find the port name string in the C source for the CMU box MEX file,
>>> change the name to something matching one of the ports on the Keyspan
>>> adapter, then recompile. I think I recall that Brian Stankiewicz.
>>> mentioned in February that the CMU MEX project was a Symantic C project,
>>> which makes that change a bit harder for those of us using the
>>> CodeWarrior compiler or any other. If you can determine that the
>>> problem is port naming, then I suggest contacting Brian about that.
>>>
>>> Best,
>>>
>>> Allen
>>>
>>>
>>>>>
>>>>>
>>>>> ... the impetus for my writing to you (though I did want to say hi :)
>>>>> ) was that one of the grad students had a question about a
>>>>> Psychtoolbox function. The same question had been posted to the forum
>>>>> several months ago by someone else with no reply, so, knowing that I
>>>>> had worked with you, the grad student asked me if I could forward the
>>>>> question to you to see if you a) knew the answer or b) knew whom we
>>>>> might be able to direct the question to.
>>>>>
>>>>> The relevant posting is below:
>>>>>
>>>>> --- In psychtoolbox@y..., "kmuess" <muesseler@m...> wrote:
>>>>> Hello!
>>>>> I failed to use a new CMUBbox with a new USB Mac (via Keyspan
>>>>> adapter) and the Mex files by Brian J. Stankiewicz. The error
>>>>> message is always
>>>>>
>>>>> ??? Error in bbox
>>>>> On line 1 ==> CMUBbox('Init');
>>>>>
>>>>> Brian has started a new position at UT Austin and promised to
>>>>> take care of the problem in future, but I wonder if anybody else
>>>>> already observed this error messages and found already a
>>>>> solution for it.
>>>>> Thanks
>>>>> Jochen Muesseler
>>>>> Munich
>>>>> --- End forwarded message ---
>>>>>
>>>>> Itamar (the grad student) has encountered the same problem, using
>>>>> newer computers and button boxes, although the function has worked
>>>>> with older equipment. We were wondering if a fix had been developed
>>>>> by someone to use a USB CMU Button Box with the Psychtoolbox?
>>>>>
>>>>> Barring that, we were wondering if there was a function that reads
>>>>> directly from the serial port with very accurate timing?
>>>>>
>>>>> Thanks in advance for any help, advice, or steering in the right
>>>>> direction you may be able to offer us.
>>>>>
>>>
>>>
>>>
>>>
>>> http://psychtoolbox.org
>>> POST a message to: psychtoolbox@yahoogroups.com
>>> UNSUBSCRIBE by sending a blank message to:
>>> psychtoolbox-unsubscribe@yahoogroups.com
>>>
>>> Your use of Yahoo! Groups is subject to
>>> http://docs.yahoo.com/info/terms/
>>>
>>>
>> --
>> Brian J. Stankiewicz, Ph.D. 512/232-9373 (Off)
>> Department of Psychology 512/475-7983 (Lab)
>> Seay 5.216 Center for Perceptual Systems
>> University of Texas www.psy.utexas.edu/StankiewiczLab
>> Austin, TX 78712
>
>
--
Brian J. Stankiewicz, Ph.D. 512/232-9373 (Off)
Department of Psychology 512/475-7983 (Lab)
Seay 5.216 Center for Perceptual Systems
University of Texas www.psy.utexas.edu/StankiewiczLab
Austin, TX 78712
>Hi Dennis,
>
>It seems to me that serial should work just fine (I don't seem to have
>PsychSerial in my psychtoolbox version). However, looking through the
>BBoxLibrary.c, it looks like there is a lot of hacking that might need to
>be done.
>
>I have not dug around in the CMU Bbox code for a long time (4 years) so I
>don't know everything that should be done. Someone who is motivated to
>get this done should be able to dig around the BBoxLibrary.c and figure
>out a handful of routines that can be incorporated with serial.mex (or
>PsychSerial.mex) to get the job done.
>
>-Brian
>

dear brian

thanks

denis
Brian Stankiewicz wrote:

>Hello,
>One suggestion. Because it might take a while to hack the
psychserial to
>work with the CMUBbox, it might be worth while for Allen to take my
code
>and see if it can easily be compiled into a .mex file. This might
serve
>as a temporary fix until someone is ambitious enough to hack through
the
>CMUbbox libraries.
>
>

Dear Brian,

I agree and thanks for the source. With some modification it compiles
into a .mex file under CodeWarrior 6 now. I don't have CMU box, so
there is not much I can do to test it. I have attached the newly
compiled .mex file for those who want to try it out.

Rachel and Itamar: I suggest testing the new .mex file this way:

1- Use the PsychToolbox's PsychSerial 'Ports' command to get a list of
the serial ports on your computer. Look at the port.inputDriverName
and port.outputDriverName fields of the returned ports structure. The
CMUBox mex file will look for port drivers named ".BIn" and ".BOut". If
those are not among the port driver names listed, then this probably
won't work. If you tell me what port drivers are listed, I could
recompile the CMUBox file for those port names.

2- If you get past step 1, then test out the recompiled function, it's
named CMUBox.mex.

I took a guess that the driver name in the bbox function, ".Bin" was
wrong becasue MacOS does a case senstitive match on the driver name,
which is listed both in the Keyspan control panel and by PsychSerial
'Ports' as ".BIn". I could be wrong about that and perhaps there is
some other cause of failure. My Keyspan USA-28X B adapter control panel
settings by deafault provide drivers named ".BIn" and ".BOut", so the
existing statment

bbox.port = bbox_PRINTER_PORT;

I left in place instead of changing it to

bbox.port = bbox_MODEM_PORT

which would use the ".AIn" and "AOut" drivers.



Best,

Allen
dear keith

oh dear. thanks for the bug report. i think it's just a question of
how to classify an an unexpected error code returned by NewGWorld. I
think i've fixed it.

could you try ScreenTest again, using the new Screen.mex, enclosed?

best

denis

>Hi, I just installed 2.52 on my Mac (with OS X) and got an error in
>ScreenTest, perhaps related to the new memory functions that were mentioned.
>
>keith
>
>»screentest
>ScreenTest
>*** Keith's Classic Mac OS Compatibility/866, Mac OS 9.2 *******
>G4, 867 MHz, memory bus 133 MHz, 100.951 Mflop/s
>Psychtoolbox 2.52, 12 August 2002, Matlab 5.2.1.1421
>*** Screen 0 *************************************************************
>"" (.Display_Video_Apple_BB200 version 1)
>8 bit dacs. 1152x870 60 Hz. (60,65,67,70,72,75,76,80,85,100,120 Hz avail)
>Prefs: SetClutDriverWaitsForBlanking 0.
> - - - - - - - - - - - - - - - - - - - - - - - - -
>??? ScreenOpenOffscreenWindow.c: not enough Matlab (62 MB) or Temp (499
>MB) memory for new 575 x 434 x 32 bit offscreen window.
>(You can use BYTES to check.)
>
>
>Error in ==> Cajal:Applications (Mac OS 9):MATLAB
>5:Toolbox:PsychToolbox:PsychBasic:SCREEN.mex
>Error in ==> Cajal:Applications (Mac OS 9):MATLAB
>5:Toolbox:PsychToolbox:PsychTests:ScreenTest.m (CopyBitsDataRate)
>On line 648 ==>
>oo=Screen(w,'OpenOffscreenWindow',[],[],[],storage,'noNewDevice');
>
>Error in ==> Cajal:Applications (Mac OS 9):MATLAB
>5:Toolbox:PsychToolbox:PsychTests:ScreenTest.m
>On line 535 ==>
> vTemp.copyWindowAGP=CopyBitsDataRate(screenNumber,'AGP');
>
>Error in ==> Cajal:Applications (Mac OS 9):MATLAB
>5:Toolbox:PsychToolbox:PsychTests:ScreenTest.m
>On line 434 ==> ScreenTest(screenNumber);
>
>»bytes
>
>ans =
>
> 65665552
>
>
>
>http://psychtoolbox.org
>POST a message to: psychtoolbox@yahoogroups.com
>UNSUBSCRIBE by sending a blank message to:
>psychtoolbox-unsubscribe@yahoogroups.com
>
>Your use of Yahoo! Groups is subject to http://docs.yahoo.com/info/terms/
> oh dear. thanks for the bug report. i think it's just a question of
> how to classify an an unexpected error code returned by NewGWorld. I
> think i've fixed it.
>
> could you try ScreenTest again, using the new Screen.mex, enclosed?

It works! No error this time.

keith