02-13-2009 01:54 PM
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?
Solved! Go to Solution.
02-13-2009 02:05 PM
02-13-2009 02:12 PM
02-13-2009 02:19 PM
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.
02-13-2009 02:21 PM
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.
02-13-2009 02:28 PM - edited 02-13-2009 02:35 PM
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...
02-13-2009 02:32 PM - edited 02-13-2009 02:32 PM
04-19-2010 12:56 PM
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
04-19-2010 03:40 PM
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.
04-19-2010 05:46 PM