Unable to read UDP data with parfeval
2 ビュー (過去 30 日間)
古いコメントを表示
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
採用された回答
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 件のコメント
その他の回答 (0 件)
参考
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!