LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

How to scan COM ports and get their information such as location using Labview?

Solved!
Go to solution

Hi all,

 

I have an application where I have 4 serial adapters being read using Labview. My application is autonomous and runs twice a day. The problem I am having is that when the computer RESETS for any reason all or some of the COM ports change their number (whatever was connected to COM9 is now COM8 and so on...). So the Labview is reading the wrong COMs or not reading them at all. 

 

I know the physical location of my serial adapters, for example: Port_#0003.Hub_#0006. That won't change even if the computer resets. (Or will it?)

 

Is there any way I can scan all the COM ports that are available at the start of my application and then select which ones I want to use based on their physical location?

 

Any help will be much appreciated.

 

Cheers,

David 

0 Kudos
Message 1 of 34
(6,356 Views)

If they are IEEE 488.2 compliant and return model number and serial number as part of the response to a *IDN? command.

 

You can always use "Find VISA Resources" to determine what com ports are available.

 

Then issue a *IDN? command on each port to determine what instrument is on what com port.

========================
=== Engineer Ambiguously ===
========================
Message 2 of 34
(6,342 Views)

Hi RTSLVU,

 

to avoid confusion: you are talking about the "*IDN?" command, do you?

Best regards,
GerdW


using LV2016/2019/2021 on Win10/11+cRIO, TestStand2016/2019
Message 3 of 34
(6,337 Views)

@GerdW wrote:

Hi RTSLVU,

 

to avoid confusion: you are talking about the "*IDN?" command, do you?


Oops, yeah thanks you caught it soon enough that I could fix it

========================
=== Engineer Ambiguously ===
========================
0 Kudos
Message 4 of 34
(6,327 Views)

@dadest100 wrote:

I have an application where I have 4 serial adapters being read using Labview. 


A simple solution might be to go with something like this guy: StarTech ICUSB2324I.  It is a 4-port USB Serial hub.  So a single USB port will control all of your serial ports and this *should* reduce issues with ports getting reallocated.


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 5 of 34
(6,309 Views)

In the past I've tried many many things to try to correlate physical location to COM port number.  I was never successful.  Ideally, the devices connected to COM ports should have readable serial numbers.

"If you weren't supposed to push it, it wouldn't be a button."
0 Kudos
Message 6 of 34
(6,268 Views)

@paul_cardinale wrote:

In the past I've tried many many things to try to correlate physical location to COM port number.  I was never successful.  Ideally, the devices connected to COM ports should have readable serial numbers.


Right, without some kind of unique identifier you are kind of screwed. I ran into this same thing with a bunch of Sorensen electronic loads. They did not put their individual serial numbers in the *IDN? response. So if I had more than one of these in a test system I had to rely on the user manually confirming the instrument locations with a separate program that would write a configuration file the main test program would use.

 

Also I have found that Windows 7 and newer tends to "remember" what USB-serial adapter was given what port number and always gives it the same one regardless of what USB port it's plugged into.

========================
=== Engineer Ambiguously ===
========================
0 Kudos
Message 7 of 34
(6,263 Views)

Thanks for your answer.

 

I am using the BLE dongles BLED112 from Bluegiga. I believe they don't support the *IDN? command because I haven't been successful getting an answer from them. This is he error i get. (Image attached) 

 

 

0 Kudos
Message 8 of 34
(6,261 Views)

While *IDN? is the default query in MAX, not many things you connect to in the real world will respond to it.  It is a carry over from the "instrument" class of devices like oscilloscopes and multi-meters, and analyzers.

 

You need to figure out if there is a particular command that the devices on the other end of your serial/BLE dongles will respond to and give back information that is unique to them, such as a serial number, or perhaps some memory location you can put an identifying code into.

0 Kudos
Message 9 of 34
(6,256 Views)

@dadest100 wrote:

Thanks for your answer.

 

I am using the BLE dongles BLED112 from Bluegiga.

 

 


Yeah that's not an IEEE 488.2 compliant instrument, so 488.2 common commands are not going to work.

 

But a BT dongle should have some sort of unique identifier. In my limited experience working with HC-05 and HC-06 BT modules I recall there was a command that would give you the MAC address of the BT device. 

 

Maybe yours has a similar command you can use in place of *IDN?

========================
=== Engineer Ambiguously ===
========================
0 Kudos
Message 10 of 34
(6,254 Views)