필터 지우기
필터 지우기

How to use the createTask to capture the hardware data

조회 수: 7 (최근 30일)
edeson
edeson 2024년 2월 1일
답변: Damian Pietrus 2024년 2월 6일
Hi,
I learning the createtask demo, for example
c = parcluster(); % Use default profile
j = createJob(c);
createTask(j, @rand, 1, {10,10});
createTask(j, @rand, 1, {2,10});
createTask(j, @rand, 1, {10,3});
submit(j);
wait(j);
taskoutput = fetchOutputs(j);
disp(taskoutput{1});
disp(taskoutput{2});
disp(taskoutput{3});
the step is
use the parcluster() function to set the profile
add job to cluster by createJob() function
and add the task to job by createTask() function
sumbit the job
and wait all worker to finish all task
the last, get the all task output by fetchOutputs()
in the application, if I create 2 Task,
the first, createTask(j, @getUartInterfaceData, ... .... ....);
the second, createTask(j, @ProcessUartInterfaceData, ... .... ....);
if i want read the UART Hardware to matlab using the first task, and process the Receive Data using the second task at the same time in real time, the answer:
how the share the data between two task ?
how the run the two task in loop ?

채택된 답변

Damian Pietrus
Damian Pietrus 2024년 2월 6일
When using createJob/createTask, each task is completely independent. This means that you wouldn't be able to interactively take information from one task and send it to another while they are running.
I think you have two options you could try. If "real time" communication is not required and you don't mind a delay, you could run the first task to get the interface data, fetch the output, and then use that as an input to the process data task after. Another option might be to use an spmd block, since you can use spmdSend / spmdReceive to share data between workers.
If you share more information about your workflow there might be some other options as well

추가 답변 (0개)

태그

제품


릴리스

R2022a

Community Treasure Hunt

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

Start Hunting!

Translated by