Serial port on Windows

Hello,

For checking gamma calibration, I'd like to display stimuli in PTB and
then read back the measurements of a photometer (Minolta LS-100).
Matlab's serial command only works in Java Virtual Machine mode, and of
course for PTB you need the -nojvm switch. I've searched the message
boards, and found that there is a function psychserial, which I assume
is designed to get round this. However, I'm not sure how to use it, and
I gather there is/was some problem with it on Windows.

Typing "psychserial", I get the following advice

> Usage:
> % Open and close serial ports:
> port=SERIAL('Open',inputDriverName,outputDriverName,baudRate)
> SERIAL('Close',port)
> SERIAL('Write',port,string)
> string = SERIAL('Read',port)

What should I put for inputDriverName and outputDriverName? In Matlab, I
just provided information about the data from the photometer

> port = serial('COM1', 'BaudRate',
> 4800,'databits',7,'parity','even','stopbits',2,'terminator','CR/LF','FlowControl','hardware');

but I don't know what psychserial is looking for here. I tried

> port=psychserial('Open','COM1','',4800)
> psychserial('Write',port,'MES'); % you have to write MES before taking
> a reading on my photometer, for some reason
> strg = psychserial('Read',port)
> psychserial('Close',port)

and this didn't give me any errors, but unfortunately strg was either
nonsense or an empty string; it did not contain the photometer reading.

If anyone is using psychserial successfully under Windows, I'd be
grateful if you could show me how it's done!

Thanks in advance,

Jenny

(using revision 363, beta version 1.0.6 on Windows XP).

--
Jenny Read Office: +44 191 222 7559
Royal Society University Research Fellow Mobile: +44 794 401 5796
Henry Wellcome Building for Neuroecology, Fax: +44 191 222 5622
University of Newcastle, Framlington Place mailto:J.C.A.Read@...
Newcastle upon Tyne, NE2 4HH, UK. http://www.staff.ncl.ac.uk/j.c.a.read
In a previous message, Jenny Read wrote.

On Tue, 13 Jun 2006, Jenny Read wrote:

> Matlab's serial command only works in Java Virtual Machine mode, and of
> course for PTB you need the -nojvm switch.

My experience is that with a litte care in coding I have had not problem
using PTB in the Java Virtual Machine mode. I find this so much more
convenient for debugging, that the coding work arounds seem well worth
while. So far I have continued using the -nojvm switch when collecting data,
but lately I have been wondering if even that is necessary. Does anyone
know what performance penalties are associated with continuing to use the
Java Virtual Machine mode, given that code works under it?

Ted Wright
You can try these:
1. Specify the outputDriverName as 'COM1' too. We did it this way.
Don't know whether you can omit it.
2. psychserial('Read') returns after about 100 ms, even nothing is
received. You can use a while to loop to read the port for a specifed
time or till it reads a certain character. We identify the end of
received string by a special character, such as a carriage return.
-Xiangrui

--- In psychtoolbox@yahoogroups.com, Jenny Read <J.C.A.Read@...>
wrote:
>
> Hello,
>
> For checking gamma calibration, I'd like to display stimuli in PTB
and
> then read back the measurements of a photometer (Minolta LS-100).
> Matlab's serial command only works in Java Virtual Machine mode,
and of
> course for PTB you need the -nojvm switch. I've searched the
message
> boards, and found that there is a function psychserial, which I
assume
> is designed to get round this. However, I'm not sure how to use it,
and
> I gather there is/was some problem with it on Windows.
>
> Typing "psychserial", I get the following advice
>
> > Usage:
> > % Open and close serial ports:
> > port=SERIAL('Open',inputDriverName,outputDriverName,baudRate)
> > SERIAL('Close',port)
> > SERIAL('Write',port,string)
> > string = SERIAL('Read',port)
>
> What should I put for inputDriverName and outputDriverName? In
Matlab, I
> just provided information about the data from the photometer
>
> > port = serial('COM1', 'BaudRate',
> >
4800,'databits',7,'parity','even','stopbits',2,'terminator','CR/LF','F
lowControl','hardware');
>
> but I don't know what psychserial is looking for here. I tried
>
> > port=psychserial('Open','COM1','',4800)
> > psychserial('Write',port,'MES'); % you have to write MES before
taking
> > a reading on my photometer, for some reason
> > strg = psychserial('Read',port)
> > psychserial('Close',port)
>
> and this didn't give me any errors, but unfortunately strg was
either
> nonsense or an empty string; it did not contain the photometer
reading.
>
> If anyone is using psychserial successfully under Windows, I'd be
> grateful if you could show me how it's done!
>
> Thanks in advance,
>
> Jenny
>
> (using revision 363, beta version 1.0.6 on Windows XP).
>
> --
> Jenny Read Office: +44 191 222 7559
> Royal Society University Research Fellow Mobile: +44 794 401 5796
> Henry Wellcome Building for Neuroecology, Fax: +44 191 222 5622
> University of Newcastle, Framlington Place mailto:J.C.A.Read@...
> Newcastle upon Tyne, NE2 4HH, UK.
http://www.staff.ncl.ac.uk/j.c.a.read
>