How can I identify COM port devices on Windows

I am working on several projects that involve using Arduinos and other serial connected devices with a MATLAB GUI. I have a solution for identifying the devices that opens all the COM ports one at a time and queries them. By checking the responses I can identify which devices are connected to which COM ports. This only works if the devices have unique responses to the query sent. I am currently using *IDN? as my query because it seems to be fairly standard. Of course, to interact with the Arduinos, I have to make sure they respond to this query in a predictable way.

My problem is that this process is fairly slow and a little error prone. In Windows Device Manager, each Port is identified by name and COM number. Is there any way to get these names inside of MATLAB? I want to be able to ID the ports without having to open connections to them all.

NOTE:-

Matlabsolutions.com provide latest MatLab Homework Help,MatLab Assignment Help for students, engineers and researchers in Multiple Branches like ECE, EEE, CSE, Mechanical, Civil with 100% output.Matlab Code for B.E, B.Tech,M.E,M.Tech, Ph.D. Scholars with 100% privacy guaranteed. Get MATLAB projects with source code for your learning and research.

It will only work on Windows (7 for sure but maybe not others). I use DOS commands to query the registry in two places to identify which COM ports are connected and then check the USB section of the CurrentContrlSet to match up friendly names.

My code my not be completely optimized but it runs in about .1 seconds so it suits my purposes.

The result is a cell array with friendly names and COM number pairs for each connected USB-serial device that has a friendly name.

Code posted below:

Skey = 'HKEY_LOCAL_MACHINE\HARDWARE\DEVICEMAP\SERIALCOMM';
% Find connected serial devices and clean up the output
[~, list] = dos(['REG QUERY ' Skey]);
list = strread(list,'%s','delimiter',' ');
coms = 0;
for i = 1:numel(list)
if strcmp(list{i}(1:3),'COM')
if ~iscell(coms)
coms = list(i);
else
coms{end+1} = list{i};
end
end
end

SEE COMPLETE ANSWER CLICK THE LINK

--

--

--

Simple! That is me, a simple person. I am passionate about knowledge and reading. That’s why I have decided to write and share a bit of my life and thoughts to.

Love podcasts or audiobooks? Learn on the go with our new app.

Recommended from Medium

CS373 Fall 2021 Week 9: Francis Tran

Realtek Driver Windows 7 64 Bit Free Download

Fundamental Software Architectural Patterns

Numpy in Machine Learning for Beginners

💐LET’S LEARN SOME SPECIAL FEATURES IN METADOGEBATTLE💐

Google Tag Manager Basics — Part 9 Review

Cake v1.0.0 RC1 released

Percona Series / Revolutionise ALTER TABLE

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store
Technical Source

Technical Source

Simple! That is me, a simple person. I am passionate about knowledge and reading. That’s why I have decided to write and share a bit of my life and thoughts to.

More from Medium

Image Acquisition Toolbox — imaqtool gets only black images

Introduction To Virgo

Convert any text to audio in 20 lines of python code.

How to Predict Ethereum Price using Python and General Brownian Motion