Unable to read UDP data with parfeval

조회 수: 2 (최근 30일)
Srinivasan B
Srinivasan B 2021년 9월 27일
댓글: Srinivasan B 2021년 9월 28일
Hi,
I am unable to call the read function inside a parfeval thread. I have attached the error for reference.
--------------------------------------------------
Here is the snippet of the code:
f = parfeval(p,@algorithmPipeline,0,app,adcBuffer,printBuffer);
-----------------------------
function algorithmPipeline(app,adcBuffer,printBuffer)
data = read(app.udpSock,1466,"uint8");
end
------------------------------------
The UDP is initialised and the values of app.udpSock are as follows.
UDPPort with properties:
IPAddressVersion: "IPV4"
LocalHost: "192.168.33.30"
LocalPort: 4098
NumBytesAvailable: 226771142
NOTE: When the algorithmPipeline is called normally without using parfeval it is working properly(There are no errors)
Thanks and Regards,
Srinivasan
  댓글 수: 1
Srinivasan B
Srinivasan B 2021년 9월 28일
Thank you. This resolved my problem.

댓글을 달려면 로그인하십시오.

채택된 답변

Walter Roberson
Walter Roberson 2021년 9월 27일
When you use parpool (at least if you do not use the "threads" option, not sure about threads), then the workers are in a separate process. To send data to the process, MATLAB does the equivalent of save() in the controlling process, and load() in the worker process. However, that only works with some kinds of objects -- serializable objects. updport() objects are not serializable. (Generally speaking, device objects are not serializable.)
You will need to create the udpport object on the worker that you are going to run the parfeval() on.
... However, if your parpool has more than one member, then you could run into the problem that the worker you create the object on is not the one that runs your function. So you might have to create it on all workers, https://www.mathworks.com/help/parallel-computing/parfevalonall.html .. but which one will receive the data that is send to it ?

추가 답변 (0개)

Community Treasure Hunt

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

Start Hunting!

Translated by