Prashant Singh
Prashant Singh

Reputation: 3793

Virtual Com-Port communication through Matlab

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

Upvotes: 0

Views: 2183

Answers (1)

Dang Khoa
Dang Khoa

Reputation: 5823

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.

Upvotes: 2

Related Questions