LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

read com ports with command line through labview?

Solved!
Go to solution

I am trying to find a way to search for a specific com port through the command prompt using system exec in labview. Is it possible to get a list of com port connections much like the one you see in device manager where it will list the name of the device connected to a certain com port? I want to be able to automatically find the com port for a specific device.

0 Kudos
Message 1 of 6
(4,345 Views)

Why are you using the System Exec?  Why not just use VISA?

 

As far as I am aware, it is not possible to get the information about what the serial port is connected to without trying to actually communicate with it.  What I did was make a routine that get the list of available COM ports and then used a FOR loop to try to write/read to/from the instrument until I got the response I wanted.


GCentral
There are only two ways to tell somebody thanks: Kudos and Marked Solutions
Unofficial Forum Rules and Guidelines
"Not that we are sufficient in ourselves to claim anything as coming from us, but our sufficiency is from God" - 2 Corinthians 3:5
0 Kudos
Message 2 of 6
(4,340 Views)
Solution
Accepted by topic author KovAcevich7

because it is a virtual com port that gets set up and i have tried the VISA Find Resource vi and it did not work. However, funny enough, right after i submitted this post, i found the solution to my problem. If you use system exec and type this command into the standard input:

 

wmic path Win32_SerialPort

 

This will bring up a list of all connected com ports and very quickly also. From there i can parse out the info that i don't want and widdle it down to the com port of the desired usb device.

 

Maybe this can help someone down the road.

0 Kudos
Message 3 of 6
(4,329 Views)

Here's a vi I wrote a long time ago  that shows how to find all Com ports and select one using VISA.

 

ComSelect.png

I have had no issues finding virtual com ports using this.

========================
=== Engineer Ambiguously ===
========================
Message 4 of 6
(4,326 Views)

As I am new to this software, am facing it difficult to create the vi of the attached image. Can you please send the vi of the image you have attached?

 

Thanks 

Kaustav Sen

0 Kudos
Message 5 of 6
(2,469 Views)

It’s not jhst an image but a LabVIEW snippet. Click on it to open it in a sort of pop over view, then look for the download button and save it to your hard disk. Then drag it from there into an empty VI diagram.

 

But it’s very basic LabVIEW programming so if this code is a.challenge to recreate, you may want to take a look at the training resources offered at the top of the LabVIEW forum.

Rolf Kalbermatter
My Blog
Message 6 of 6
(2,465 Views)