Re-enable a callback function

2 ビュー (過去 30 日間)
Aon
Aon 2019 年 5 月 19 日
コメント済み: Aon 2019 年 5 月 19 日
Hi!
I use the imaq toolbox and the FramesAcquiredFcn to process a frame with a hardware trigger sensor.
If an error in the processing occurs for some reason I stop getting frames and the following message shows:
Warning: The FramesAcquiredFcn callback is being disabled.
To enable the callback, set the FramesAcquiredFcn property.
I want the callback to become re-enabled as soon as its been disabled so it waits for the next trigger again.
If the solution is to "set the FramesAcquiredFcn property" as the errormessage say, how do I do that?
Thanks in advance!

採用された回答

Guillaume
Guillaume 2019 年 5 月 19 日
Probably, the simplest thing would be to prevent the error being detected and hence the callback from being disabled. For that I'd wrap your callback in a try ... catch block:
try
% your normal callback code
catch ME
warning('The error "%s" occured during frame processing', ME.message);
end
The above issues a warning with the error message instead. You may want to make that the callback function which in turn calls your processing function.
  1 件のコメント
Aon
Aon 2019 年 5 月 19 日
Works perfect thanks!

サインインしてコメントする。

その他の回答 (0 件)

Community Treasure Hunt

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

Start Hunting!

Translated by