LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

COM ports

Solved!
Go to solution

I know that when a device (serial or USB) is plugged into a computer, the computer automatically assigns a COM port.

Does that assigned COM port ever change?
If so, when?
For instance, is it the same port when you

- restart the computer?

- unplug then replug in the device

- change which USB port you plug the device into

- etc

 

Is there a way to check what devices are in what COM ports programmatically?
I can manually look through Task Manager or MAX, but could I make LabVIEW check where the device is? 

Cory K
0 Kudos
Message 1 of 10
(4,396 Views)
Yes the comport will change if you swap USB port using a USB to RS232 converter. At least on XP. Has this changed in Vista? I am not using Vista 😉 


Besides which, my opinion is that Express VIs Carthage must be destroyed deleted
(Sorry no Labview "brag list" so far)
0 Kudos
Message 2 of 10
(4,390 Views)
If you are using an NI device you can use a DAQmx property to list the serial numbers of the devices on each port, and you can chose the port based on the serial number.
0 Kudos
Message 3 of 10
(4,386 Views)
Solution
Accepted by topic author Cory_K

Doing USB/RS-232 converters, it seems that when you plug in the device, the next available com port is assigned.  As long as you continue to plug the device in the same USB port it keeps the same com number.  If you plug it into a different USB port, it knows it and gives it the next highest COM number.  So what I do is set up the drivers and plug the device in one by one in each USB port in a logical order.  That way the com port makes sense relative to position rather than having COM3 in the from com 4 in the back upper right,  com 5 in the front, com 6 in the back lower left because that happened to be the order I plugged it into different ports at random times.

 

So restart, unplug replug, you get the same COM port.  Change USB port, you get a different COM port.

 

I'm not sure of ways to check programatically, and I think you might find ways by searching the forums.

Message 4 of 10
(4,381 Views)

If you use LV Visa, a VI in the Instument I/O pallette finds coms. I believe you enter "com?" or something like that for the expression input terminal

 

VISA Find Resource

Queries the system to locate the devices associated with a specified interface.

0 Kudos
Message 5 of 10
(4,380 Views)

I would think that a work around this is to give your ports an Alias name in using NI MAX. Whatever port you plug your devices into the Alias is used for the connection instead fix port number...

 

After some reading...the port number persist with the Alias name... A name is useful on the block diagram or FP versus a com port number...

Message Edited by richjoh on 02-13-2009 02:35 PM
0 Kudos
Message 6 of 10
(4,371 Views)

This will work for NI devices:

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

Message Edited by jmcbee on 02-13-2009 01:32 PM
Message 7 of 10
(4,369 Views)
Has anyone tried this method?

richjoh wrote:

I would think that a work around this is to give your ports an Alias name in using NI MAX. Whatever port you plug your devices into the Alias is used for the connection instead fix port number...

 

After some reading...the port number persist with the Alias name... A name is useful on the block diagram or FP versus a com port number...

Message Edited by richjoh on 02-13-2009 02:35 PM

 

CLD Certified 2014
0 Kudos
Message 8 of 10
(3,962 Views)

As mentioned in my comments to you in your other USB - serial adapter thread, unless the usb device has a serial number scheme that Windows can read it will generate a new com port number each time it is plugged into an diffrent usb port. My experience has been that an Alias will be assigned to that com port, not the unit, unless it has a serial number. What was happening in my instance I was having glitches on the computer's usb bus, which made Windows think the adapter had be unplugged and plugged back in. And in fact it apparently sort of thought that the original unit was still plugged, since it would give me a new port address.

 

 

It is a good idea to keep your questions in the original thread. Putting them in one that has "Solved" applied to it will definitely reduce the number of folks that look at it.

 

 

 

Putnam
Certified LabVIEW Developer

Senior Test Engineer North Shore Technology, Inc.
Currently using LV 2012-LabVIEW 2018, RT8.5


LabVIEW Champion



0 Kudos
Message 9 of 10
(3,928 Views)
I was just seeing if anyone tried his idea. Thank you.
CLD Certified 2014
0 Kudos
Message 10 of 10
(3,906 Views)