A timeout occurred before the Terminator was reached

2 次查看(过去 30 天)
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 个评论
Walter Roberson
Walter Roberson 2012-4-7
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 2012-4-8
well thx for commenting it . i alsoe found some similar thread but no soulution either
http://www.mathworks.com/matlabcentral/newsreader/view_thread/308157

请先登录,再进行评论。

回答(0 个)

Community Treasure Hunt

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

Start Hunting!

Translated by