通过Matlab进行虚拟Com-Port通信 [英] Virtual Com-Port communication through Matlab

查看:96
本文介绍了通过Matlab进行虚拟Com-Port通信的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

多次使用matlab连接Com-port时(5之4),出现错误

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.

??? 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?

顺便说一下,我正在使用此代码段通过USB将我的微控制器连接到PC

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);

推荐答案

我之前遇到过这个问题.事实证明,如以下线程所示,MATLAB不能很好地处理即插即用:

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

长话短说:如果要让MATLAB检测硬件更改,则需要重新启动它. MATLAB似乎仅在启动时寻找设备.

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.

这篇关于通过Matlab进行虚拟Com-Port通信的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆