No BSD License  

Highlights from
Get Available COM PORT

4.33333

4.3 | 3 ratings Rate this file 19 Downloads (last 30 days) File Size: 1.05 KB File ID: #9251

Get Available COM PORT

by Daniel Lavoie

 

05 Dec 2005 (Updated 06 Dec 2005)

Get available COM port on your PC

| Watch this File

File Information
Description

This function output a cell array with string name of each COM port available on your PC.

Example:
 COM_Port = getAvailableComPort();

Enjoy.

Acknowledgements
This submission has inspired the following:
CO2gui - lab control and automation
MATLAB release MATLAB 7.0.1 (R14SP1)
Tags for This File  
Everyone's Tags
Tags I've Applied
Add New Tags Please login to tag files.
Comments and Ratings (3)
04 Jan 2006 anders granstroem

Shows available COM ports. When terminating a matlab program with CTRL-C. Windows 2000 thinks that the com port is occupied. Nice to se this in matlab. Can be seen by doing "mode" command at the command promt in windows as well.

23 Jan 2009 Marko Antila

Nice work Daniel - clever to catch the error message. I was thinking this myself but did not have time to work it out.

I think, however that the code could be further improved by inserting these two lines after the first "end":
fclose(s);
delete(s);

This removes the unnecessary handle and does not confuse the future operations with the serial port.

10 May 2009 Geoffrey Akien

Very handy utility, but unfortunately the way MATLAB finds these serial ports does not take into account if other programs are using them - although fopen will of course prevent you from using that port. Also, when I incorporated it into a GUI, it did not stand up to being run a second time - it could not access the error message which instead replies with a 0x1 structure.

Please login to add a comment or rating.
Tag Activity for this File
Tag Applied By Date/Time
com port Daniel Lavoie 22 Oct 2008 08:08:45
rs232 Daniel Lavoie 22 Oct 2008 08:08:45
available Daniel Lavoie 22 Oct 2008 08:08:45
db9 Daniel Lavoie 22 Oct 2008 08:08:45
com to usb abdoul 16 May 2009 07:15:17
enter comm port Steven 07 Jun 2011 11:22:02
com port Javier 18 Oct 2011 06:23:23

Contact us at files@mathworks.com