Matlab blocks arduino comport

3 次查看(过去 30 天)
Hi all,
I am using matlab (Matlab App Designer to be precise) to communicate with my arduino via serial communication. My code works fine the first time I start the app. If I restart the app, Matlab gives me the following error code:
if true
Error using serial/fopen (line 72)
Open failed: Port: COM4 is not available. No ports are available.
Use INSTRFIND to determine if other instrument objects are connected to the requested
device.
end
If have already tried 'clear all' afterwards, but my COMPORT still seems to be busy. I have to restart matlab to get the app running again.
Do you have any idea how this can be solved?

采纳的回答

Madhu Govindarajan
Madhu Govindarajan 2017-12-11
I would recommend something along the lines of cleanup that happens when someone closes the App where you can use this - https://www.mathworks.com/help/matlab/ref/serial.delete.html
The other thing I think might help is this function here - https://www.mathworks.com/help/instrument/instrreset.html
which should delete all open instrument objects as per the doc.
HTH

更多回答(0 个)

类别

Help CenterFile Exchange 中查找有关 MATLAB Support Package for Arduino Hardware 的更多信息

Community Treasure Hunt

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

Start Hunting!

Translated by