| os09626 2005-04-21, 9:00 pm |
| i have been encoutered with freezing matlab during read operation
from a serial port problem. i wonder if you can help me, i will show
you the code i wrote to send & receive a string. i tried to retrace
the program, but matlab in the receiving computer keeps freezing , i
don'y know why!
im using matlab 6.5 R13. your help will be appreciable. thanx in
advance.
Remark:
i have two computers , one as transmitter while the other is the
receiver. i used 'pause' just to determine the instant at which the
recieving computer freezes & i found that it happens when matlab
executes 'fscanf (s2)' where s2 is the serial port of receiving
computer.
%this code run on the sending computer
warning off
s1=serial('COM1');
fopen(s1);
s1
pause;
stringin = input('Hello','s');
disp(' ')
fprintf(s1, '%s\n', stringin);
s1
pause;
fclose(s1)
delete(s1)
clear s1
% & this code run on the receiving computer
warning off
s2=serial('COM2');
s2
pause;
fopen(s2);
s2
pause;
output=fscanf(s2);
disp(output)
fclose(s2)
delete(s2)
clear s2
|