LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

how to detect all COM & USB ports present in a system using labview?

I am developing a GUI using labview and want to give an option to user on menu bar for selecting desired COM or USB port for communication.Actually on clicking, it should display a list of all com ports and usb ports available on PC for communication.Since, I am new to labview,I dont know how to actually accomplish it.All suggestions are most welcome.Thanks in advance.

0 Kudos
Message 1 of 9
(8,848 Views)
You can simply use the VISA Find Resources function to list all com ports. If you have USB-RS232 converters, they simply show as a com port. You must have NI-VISA installed for this to work
0 Kudos
Message 2 of 9
(8,830 Views)

Hi Dennis,thank you for the response.I would highly appreciate if you can put up some example vi of this sort.

0 Kudos
Message 3 of 9
(8,814 Views)

Hi mnx,

 

in general, if you just want a list box to access available serial ports of you computer to access VISA functions, you can just use the VISA resource name Control available in the frontpanel.

Visa Resource Control.JPG

 

You can also right click the terminal of your VISA VIs and select Create Control in the context menu:

 

For example for VISA functions you have to right click the VISA resource name terminal:

 

VISA Open.JPG

 

 

Best Regards,

Lam

0 Kudos
Message 4 of 9
(8,797 Views)

Thank you Lam for your reply.I am now making use of VISA find resource and VISA configure serial port functions for getting a dropdown menu for all serial ports present in the system.Can I also do something similar for USB ports?

0 Kudos
Message 5 of 9
(8,744 Views)
As I already said, if you have a USB-RS232 adapter, you don't have to do anything else. Talking about listing all USB ports is silly unless you specify what type of USB device you want to detect. A mouse or keyboard is much different than a USBTMC device or a USB DAQ device from NI or any of the other multitude of USB devices. The communication protocols are all different and require different software. A USB port without anything plugged into it is not useable for anything.
0 Kudos
Message 6 of 9
(8,741 Views)
As I already said, if you have a USB-RS232 adapter, you don't have to do anything else. Talking about listing all USB ports is silly unless you specify what type of USB device you want to detect. A mouse or keyboard is much different than a USBTMC device or a USB DAQ device from NI or any of the other multitude of USB devices. The communication protocols are all different and require different software. A USB port without anything plugged into it is not useable for anything.
0 Kudos
Message 7 of 9
(8,741 Views)

As Dennis mentioned, using USB is more complex compared to the RS232, so it wouldn't make sense to make all usb ports available  in general

 

If you want to work with USB in LabVIEW you should check out this tutorial:

 

USB Instrument Control

 

Regards,

Lam

0 Kudos
Message 8 of 9
(8,704 Views)

Hello everyone..

 

I am now using VISA resource name to list all ports available in the system. I have also used I/O name filtering option and made interfaces types to support only serial instruments.I am getting the list as in the attached image. Is there anyway to display only "COM" ports and remove other encircled ports from list in the image?

0 Kudos
Message 9 of 9
(8,537 Views)