How to use parallel computing for a BytesAvailableFnc of a serial object?
1 回表示 (過去 30 日間)
古いコメントを表示
Hi,
I am using BytesAvailableFcn to read a specific number of bytes from a serial input. On the same time I am using videoinput to record a video and also evaluate the values of the serial input. Because there is so much happening at the same time, the serial bytes are not always read in when they hit the specific number of bytes, so there is a delay.
I want to use the Parallel Computing Toolbox to make the BytesAvailableFcn a background function, which reads the bytes without waiting for other task to finish. How or where can I specify the function as parfeval? Or can I just use parfeval somewhere at the beginning and the function will be compute in the background?
Thank you
0 件のコメント
採用された回答
Harald
2023 年 6 月 30 日
Hi Oliver,
you could use the backgroundPool function. This even works without Parallel Computing Toolbox. As soon as you run the parfeval command (you can do so "somewhere at the beginning"), the evaluation of that command starts, and further commands will be run at the same time.
Best wishes,
Harald
2 件のコメント
Harald
2023 年 7 月 18 日
編集済み: Harald
2023 年 7 月 18 日
Hi Oliver,
let's put it that way: if you have something that does not work, then please share a code example for it and the problematic behavior (e.g., the full error message). At least for me, that is easier to follow than a lot of words.
In general I would say that the safest way of making sure that the serial input object is available in the function you pass to parfeval is to create it inside that function.
Best wishes,
Harald
その他の回答 (0 件)
参考
カテゴリ
Help Center および File Exchange で Startup and Shutdown についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!