LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Read out COM port number of device in LabView

Solved!
Go to solution

Hi,

 

Is there a way to read out the COM port number of a device in LabView? I would like to make an initializing program that tracks the right COM port of a device, for example a USB device reading temperature, and set this COM port as the correct port when the main LabView program starts. I want to do this, because a USB device usually gets different COM port dedication on different computers. Our application is running on 80 different computers. A program like that would be very pleasant.

 

Can anyone help me?

 

Paal

0 Kudos
Message 1 of 7
(4,086 Views)
You first get a list of the ports and for each one, try to communicate. Listing the ports is easy. Have you ever looked at the VISA palette?
0 Kudos
Message 2 of 7
(4,080 Views)
There are system calls that can tell you what ports are present in a system, however there is no reliable way to tell what is connected to those ports. Sometimes you will encounter instruments that are SCPI compliant that support the IDN command, but they are rare.

This is why com port settings should always be read from the INI file, or a configuration database.

Mike...

PS: one thing that can help is that many USB/serial dongles will remember the last port they were configured to be, even if they are removed and plugged back in.

Certified Professional Instructor
Certified LabVIEW Architect
LabVIEW Champion

"... after all, He's not a tame lion..."

For help with grief and grieving.
0 Kudos
Message 3 of 7
(4,076 Views)
Solution
Accepted by paalbrok
Another thought. This also a place where some standardization can save you a lot of time.

Say you have 3 dongles per machine. When setting up a computer ensure that those three dongles are **always** assigned to, for example, com 3, com 4 and com 5.

Likewise, always verify that device 1 is always on com 3, device 2 is always on com 4, and device 3 is always on com 5.

This convention will also simplify debugging...

Mike...

Certified Professional Instructor
Certified LabVIEW Architect
LabVIEW Champion

"... after all, He's not a tame lion..."

For help with grief and grieving.
0 Kudos
Message 4 of 7
(4,068 Views)

Thank you.

 

br,

Paal

0 Kudos
Message 5 of 7
(4,036 Views)
Solution
Accepted by paalbrok

Back in the '80s, I thought, "It sure will be nice in the future when Serial Communication is replaced with something modern". I underestimated the fact that it was is the cheapest solution and (in the end), it works. At least things have improved. It's been a while since we've had to move jumpers and modify cables. But we still can't escape the occasional "paper clip loopback".Smiley Happy

 

As Dennis suggested, get an array of the COM ports.

Reverse the array to save time, since COM 1 and COM 2 are usually reserved for the motherboard or addin card.

Reducing the default 10 second timeout also saves time.

 

Then iterate through the array of COM ports, testing for your device.

In your case, you could try to take a reading and see if it's valid and no errors occurred.

Once you find your device, use that reference for your program.

 

To let the user know what's going on, you can display messages: "Testing COMX", "Found Thermometer on COM3". etc

 

steve

 

 

----------------------------------------------------------------------------------------------------------------
Founding (and only) member of AUITA - the Anti UI Thread Association.
----------------------------------------------------------------------------------------------------------------
0 Kudos
Message 6 of 7
(4,025 Views)

Great tips 🙂

 

br,

Paal

0 Kudos
Message 7 of 7
(4,019 Views)