Hey,
I am trying to read out the signal of a Forp response box (HH-2x2) via the serial port of the forp interface FIU-005, program 0, via serial port, on windows xp/ Matlab R2007b.
The problem is the following: If I use PsychSerial, I can read out the signal, but any flip command less than 200ms following the read out will be extremely inaccurate (in the extreme ca. 200ms). Example snippet:
serial_port = PsychSerial('Open','COM3','foobar',19200)
while true
trigger_on = PsychSerial('Read',serial_port);
if strcmp(trigger_on,'4')
disp('serial signal received');
break
end
end
If I use IOPort, then I cannot read out any signal at all, or sometimes I get a vector of numbers which have been pressed in the far past. Example snippet:
[handle, errmsg] = IOPort('OpenSerialPort', 'Com3' , 'BaudRate=19200');
IOPort('Purge', handle);
while true
[signal when, errmsg] = IOPort('Read', 0);
if signal ~= []
disp('serial signal received');
break
end
WaitSecs(0.004);
end
IOPort('Close',0)
In general i would like to use IOPort much more than PsychSerial, as with another Response Box on another Scanner IOPort worked well and I did not have any timing issues with Flips after it.
Any comments or ideas of how to solve that problem on Win XP are highly appreciated.
Best,
Radek