For Programmers: Free Programming Magazines  


Home > Archive > Matlab > April 2005 > matlab freezing while reading from serial port









You are viewing an archived Text-only version of the thread. To view this thread in it's original format and/or if you want to reply to this thread please [click here]

 

Author matlab freezing while reading from serial port
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
rashi tiwari

2005-04-25, 8:59 pm

hi there

y are u using pause with no time to it...are u sure that when u write the data it goes to the port of the first PC.

also check the communication ports. the matlab in second comp might be freezing because it never received the data.

whats the terminator u are using and also how long is the time out...

rashi
Sponsored Links







Also available: Server administration forum archive | Web Design forum archive | Software forum archive | Hardware reviews archive

Copyright 2008 codecomments.com