A timeout occurred before the Terminator was reached

1 view (last 30 days)
How to avoid this kind of error.I got this when receiving some data from a robot.I managed to avoid this problem with pause(2) before receiving data but now my algorithm is too slow.(This is just a part of my program)
s=serial('com5');
set(s,'BaudRate',9600,'DataBits', 8, 'Parity', 'none','StopBits', 1, 'FlowControl', 'none','Terminator','CR','Timeout',10);
fopen(s);
while(1)
pause(2);
fprintf(s,'0');
data=fscanf(s);
data=str2num(data);
if(data<=10)
display(data)
end
end
fclose(s);
Without the pause(2) i sometimes get this error: A timeout occurred before the Terminator was reached but with pause(2) it never happens.So why is this and how to avoid it without using pause.
this is what im sending form the roboter:
PULSIN 12, 1, time
distance = time ** 2251
SEROUT 1, 84, [DEC distance, CR]
puslin activates the sonar and mesaures time. serout 1-pin number ,84-baudrate(9600).
  2 Comments
Walter Roberson
Walter Roberson on 7 Apr 2012
I _have_ been reading your message since you posted it, but I don't know the answer. It's a hardware issue. This is the sort of thing I would use our HP DataScope for.
samir
samir on 8 Apr 2012
well thx for commenting it . i alsoe found some similar thread but no soulution either
http://www.mathworks.com/matlabcentral/newsreader/view_thread/308157

Sign in to comment.

Answers (0)

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!