Error: OBJ must be connected to the hardware with FOPEN
8 Ansichten (letzte 30 Tage)
Ältere Kommentare anzeigen
I want to turn on led and run a function within parfor loop. but it gives an error. Please help me.
delete(instrfind({'Port'},{'COM5'}))
a = arduino('COM5');
pinMode(a,2,'OUTPUT');
parfor i = 1:2
if i==1
digitalWrite(a,2,1);
else
c2(); % any function or another command
end
end
0 Kommentare
Antworten (1)
Walter Roberson
am 28 Sep. 2017
parfor sessions are different processes and do not have access to devices opened in the client, if I recall correctly. You need to connect to the arduino within the worker; parfevalOnAll() can be useful for that.
However, you are going to have problems with the resource being busy / resource contention if you attempt to talk to the device from more than one worker.
You should consider using parfeval instead of parfor to run your parallel tasks, communicating back to the client when you need to have something done on the device, perhaps by using a pollable queue (needs a fairly recent version of MATLAB.)
Alternately, use spmd and labSend / labReceive with only one of the workers talking to the device.
0 Kommentare
Siehe auch
Kategorien
Mehr zu Parallel for-Loops (parfor) finden Sie in Help Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!