How to use parallel computing for a BytesAvailableFnc of a serial object?
1 view (last 30 days)
Show older comments
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 Comments
Accepted Answer
Harald
on 30 Jun 2023
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 Comments
Harald
on 18 Jul 2023
Edited: Harald
on 18 Jul 2023
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
More Answers (0)
See Also
Categories
Find more on Startup and Shutdown in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!