Virtual Com-Port communication through Matlab

限于喜欢 提交于 2019-12-24 21:27:02

问题


While connecting my Com-port using matlab, many a times(4 out of 5) I get an error

??? Error using ==> serial.fopen at 72 Port: COM21 is not available. Available ports: COM3, COM10, COM17, COM18.

However , sometimes it gets connected and responds as expected. Can anyone tell me whats the problem with this?

By the way , I am using this snippet to connect my microcontroller to PC through USB

s = serial('COM21');        //  code to initialize the req COM i.e. COM21 for me

fopen(s);

回答1:


I ran into this issue before. It turns out MATLAB doesn't really handle plug-and-play very well, as evidenced by this thread:

http://www.mathworks.com/matlabcentral/newsreader/view_thread/311133

Long story short: if you want MATLAB to detect a hardware change, you need to restart it. MATLAB seems to only look for devices when it starts up.



来源:https://stackoverflow.com/questions/6321349/virtual-com-port-communication-through-matlab

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!