Serial Communication Code Error
1 visualización (últimos 30 días)
Mostrar comentarios más antiguos
h=instrfindall;
for i= 1:length(h)
fopen('COM'+string(i))
end
h=instrfindall;
str=string(h.name(find(cell2mat(h.BytesAvailable))));
fclose('all');
fopen(str);
I developed this code on friday for finding out on which Port my Arduino is plugged in and it actually worked. Today I tried to implement the code into my GUI and an error is appearing.
Error: Struct contents reference from a non-struct array object.
What do I have to do, so that the error won't appear anymore?
Thank you for your help
0 comentarios
Respuestas (2)
Nate
el 26 de Oct. de 2017
Hi Tobias,
Could you please provide more information?
1) Does the code still work correctly when it is not in a GUI? 2) Could you please provide the full error? I am interested in knowing which line causes the error.
Thanks, Nate
1 comentario
Walter Roberson
el 27 de Oct. de 2017
You would get that error if instrfindall returns empty.
8 comentarios
Walter Roberson
el 3 de Nov. de 2017
Hmmm, instrreset has been around in Instrument Control Toolbox since before R2006a; https://www.mathworks.com/help/instrument/instrreset.html
Anyhow, I do not know why your devices cannot be seen, unless perhaps the system considers them to already be in use for something else. Perhaps this link will help: http://www.intech.co.nz/downloads/help/mscanv5/faq_84.htm
Ver también
Categorías
Más información sobre Logical en Help Center y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!