How to use the createTask to capture the hardware data
조회 수: 7 (최근 30일)
이전 댓글 표시
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 ?
댓글 수: 0
채택된 답변
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
추가 답변 (0개)
참고 항목
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!