MATLAB serial timeout handling.
이전 댓글 표시
A have a "default"-configured serial port. How do I implement timeout error handling?
If I do something like this:
try
fread(SerialObject, 1, 'uint8');
catch err
myError(err)
end
it does not read that as an error (never executes catch block).
What is the proper way to handle it in this situation?
답변 (2개)
Chirag Gupta
2011년 7월 22일
The Timeout is a warning and hence you are unable to catch it. Searching a little, I found a couple of references that might be helpful:
http://www.mathworks.com/matlabcentral/newsreader/view_thread/158768 http://blogs.mathworks.com/loren/2006/10/18/controlling-warning-messages-and-state/
May be something like this:
lastwarn('');
try
fread(s)
if(~isempty(lastwarn))
error(lastwarn)
end
catch err
err
end
Chirag Gupta
2011년 7월 22일
0 개 추천
Use the ErrorFcn callback http://www.mathworks.com/help/releases/R2011a/techdoc/matlab_external/timeout.html
댓글 수: 3
Adam
2011년 7월 22일
Chirag Gupta
2011년 7월 22일
Note this will only work for async operations
Adam
2011년 7월 22일
카테고리
도움말 센터 및 File Exchange에서 Event Functions에 대해 자세히 알아보기
제품
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!