LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Assigning a fixed com number to a USB port on a computer


@Hooovahh wrote:

@paul_cardinale wrote:

Try this instead


Great solution Paul, kudo given.  That being said I am confused why the Clear Error VI is password protected, when I certainly hope it just clears an error.  And there are some interesting design choices with dialogs and silver controls.  But the parsing of the Name Caption and Description is very useful.


Just an oversight.  Pulled from our common library, where everything used to be PW protected.

Unprotected version attached.

"If you weren't supposed to push it, it wouldn't be a button."
0 Kudos
Message 21 of 33
(1,644 Views)

Thanks everyone for their answers.

 

@wrote:

Where are the COM ports in that image, you have been talking all the time about?

 

VISA is not coming into the picture at all here. But the principle of using IMAQdx functions to enumerate the camera and read any serial number would be similar.



constructionworker_0-1671138120268.png

It has device manager properties information as follows

When I test the serial number with NI-Max installed on different computers, the serial number given changes.


@wrote:

You will need some 1 time setup.  Let's use your screenshot.  And assign Alliases as:

  • Workbench
  • Laptop
  • Lobby
  • DogPark (so you can see who doesn't pick up poop)

Plug n pray will remember the UID of each device and reuse the Aliases whenever the same device is plugged into your exact machine even if the exact USB path swaps. But, if you need to replace the camera "DogPark" with a new one, (because, it was damaged by someone angry over the ticket, of course!) You need to reconfigure.  It's simple to use the System Configuration API to list all detected devices by serial number and Aliases and you could even assign a new Alias to any present device that has a default "camN" Alias.  Look in my tag cloud for a relevant tag.  I'm sure there is a rename Alias.vi example in there somewhere. 




Aliases may work if the same devices are used over and over, but it does not solve this problem on devices with different UIDs. In the application I want to create, the correct compport must be selected when devices with different UIDs are attached.

I want to find physical port and associated compport as physical port numbering doesn't seem to change.because I want to develop the application in a way that it can be distributed to multiple computers with the same version, not one time.

But still thanks for your suggestion.

 


@Hooovahh wrote:

@paul_cardinale wrote:

Try this instead


Great solution Paul, kudo given.  That being said I am confused why the Clear Error VI is password protected, when I certainly hope it just clears an error.  And there are some interesting design choices with dialogs and silver controls.  But the parsing of the Name Caption and Description is very useful.


By the way, getting video from the serial number camera does not solve the problem. Because after the application is created, a new converter installed instead of a burnt-out converter will have a different serial number, so the program will not recognize this serial number.

Does anyone know how to find out which compport is actually assigned to the physical port?

 

 

 

 

0 Kudos
Message 22 of 33
(1,643 Views)

@constructionworker wrote:

 

By the way, getting video from the serial number camera does not solve the problem. Because after the application is created, a new converter installed instead of a burnt-out converter will have a different serial number, so the program will not recognize this serial number.Does anyone know how to find out which compport is actually assigned to the physical port

There is no COM port! Just an USB one. And USB has no concept of distinguishable ports on a computer. The distinguishing happens through what device you connected, what make and model and if that is not enough, what serial number that device has. If it has no serial number, or you can switch serial numbers, for instance by replacing a defective device, your application needs a means to let the user select that this new device whose serial number it hasn't seen before, has this specific function and should be assigned to this application specific alias. Anything else is never gonna work.

Rolf Kalbermatter
My Blog
0 Kudos
Message 23 of 33
(1,632 Views)

@rolfk wrote:

@constructionworker wrote:

 

By the way, getting video from the serial number camera does not solve the problem. Because after the application is created, a new converter installed instead of a burnt-out converter will have a different serial number, so the program will not recognize this serial number.Does anyone know how to find out which compport is actually assigned to the physical port

There is no COM port! Just an USB one. And USB has no concept of distinguishable ports on a computer. The distinguishing happens through what device you connected, what make and model and if that is not enough, what serial number that device has. If it has no serial number, or you can switch serial numbers, for instance by replacing a defective device, your application needs a means to let the user select that this new device whose serial number it hasn't seen before, has this specific function and should be assigned to this application specific alias. Anything else is never gonna work.


Thanks for your answer.
I try to standardize it as much as I can. I guess there is no solution to this.
So, isn't there a possibility to create permanent comp port using a usb hub?

0 Kudos
Message 24 of 33
(1,623 Views)

Forget about the COM ports. Everyone is telling you this is a futile effort and you need to use device information for this. I am assuming the systems are relatively static bit at times may need to swap equipment due to a failure. Therefore as already suggested you need a basic configuration function that will allow the user on the initial install to specify which camera/converter is supporting which function. At this point you keep the device information which would include the serial number and then every time the system starts you query the bus and associate the correct device with the desired function based on the serial number. If you detect a different serial number and that was the only change then you could assume that hardware was replaced and you then reassign this new serial number to the previous function. If both serial numbers are new you would have to run through the initial configuration again. You are going to have minimal user interaction to configure the system for the first use and possibly when HW is swapped out. However if you have two cameras and you have their serial numbers and notice one of them has changed it is fairly safe to assume which camera was swapped out and then silently reconfigure the settings.



Mark Yedinak
Certified LabVIEW Architect
LabVIEW Champion

"Does anyone know where the love of God goes when the waves turn the minutes to hours?"
Wreck of the Edmund Fitzgerald - Gordon Lightfoot
0 Kudos
Message 25 of 33
(1,614 Views)

thanks for suggestion


@Mark_Yedinak wrote:

Forget about the COM ports. Everyone is telling you this is a futile effort and you need to use device information for this. I am assuming the systems are relatively static bit at times may need to swap equipment due to a failure. Therefore as already suggested you need a basic configuration function that will allow the user on the initial install to specify which camera/converter is supporting which function. At this point you keep the device information which would include the serial number and then every time the system starts you query the bus and associate the correct device with the desired function based on the serial number. If you detect a different serial number and that was the only change then you could assume that hardware was replaced and you then reassign this new serial number to the previous function. If both serial numbers are new you would have to run through the initial configuration again. You are going to have minimal user interaction to configure the system for the first use and possibly when HW is swapped out. However if you have two cameras and you have their serial numbers and notice one of them has changed it is fairly safe to assume which camera was swapped out and then silently reconfigure the settings.


After a long research, I decided to use the following application method, taking into account the last suggestion you shared;
when the application is installed and run for the first time
-There will be instructions telling the user to install the camera step by step according to the specified camera number. For example, if there are 10 devices to be installed, it will connect the devices to the computer one by one in the order specified earlier. For each new device added, the ID and camera name will be saved in the ini file and set to be used by the specified function. It will do this in a specific order.
Then the application will always poll for the id change on the devices that were initially plugged in, if the device ids have changed, it will give an error and say that it needs to be reinstalled.

 

Actually, I decided that this is the most suitable method for all usb devices because multiple cameras and serial converters with the same version will also be used.Of course, I do not know exactly how to create it for now, I continue to research.

Message 26 of 33
(1,557 Views)

@rolfk wrote:

@constructionworker wrote:

 

Does anyone know how to find out which compport is actually assigned to the physical port

There is no COM port! Just an USB one. And USB has no concept of distinguishable ports on a computer. The distinguishing happens through what device you connected, what make and model and if that is not enough, what serial number that device has. If it has no serial number, or you can switch serial numbers, for instance by replacing a defective device, your application needs a means to let the user select that this new device whose serial number it hasn't seen before, has this specific function and should be assigned to this application specific alias. Anything else is never gonna work.


At the risk of derailing this post, there are methods of obtaining what is connected to the physical USB ports... and I have done it in LV a long time ago, before realizing there are better ways. Trust me, you do not want to go down that path.

Frozen_0-1671208226484.png

 

---------------------------------------------
Certified LabVIEW Developer (CLD)
0 Kudos
Message 27 of 33
(1,549 Views)

@Frozen wrote:

@rolfk wrote:

@constructionworker wrote:

 

Does anyone know how to find out which compport is actually assigned to the physical port

There is no COM port! Just an USB one. And USB has no concept of distinguishable ports on a computer. The distinguishing happens through what device you connected, what make and model and if that is not enough, what serial number that device has. If it has no serial number, or you can switch serial numbers, for instance by replacing a defective device, your application needs a means to let the user select that this new device whose serial number it hasn't seen before, has this specific function and should be assigned to this application specific alias. Anything else is never gonna work.


At the risk of derailing this post, there are methods of obtaining what is connected to the physical USB ports... and I have done it in LV a long time ago, before realizing there are better ways. Trust me, you do not want to go down that path.

Frozen_0-1671208226484.png

 


I'm actually curious about this method. So how can I find the interface name so that it can be used in NI-Vision based on the physical port number?

----------------------

Does anyone know of a way to programmatically change the name of the assigned camera interface?

0 Kudos
Message 28 of 33
(1,528 Views)

@constructionworker wrote:

@Frozen wrote:

@rolfk wrote:

@constructionworker wrote:

 

Does anyone know how to find out which compport is actually assigned to the physical port

There is no COM port! Just an USB one. And USB has no concept of distinguishable ports on a computer. The distinguishing happens through what device you connected, what make and model and if that is not enough, what serial number that device has. If it has no serial number, or you can switch serial numbers, for instance by replacing a defective device, your application needs a means to let the user select that this new device whose serial number it hasn't seen before, has this specific function and should be assigned to this application specific alias. Anything else is never gonna work.


At the risk of derailing this post, there are methods of obtaining what is connected to the physical USB ports... and I have done it in LV a long time ago, before realizing there are better ways. Trust me, you do not want to go down that path.

Frozen_0-1671208226484.png

 


I'm actually curious about this method. So how can I find the interface name so that it can be used in NI-Vision based on the physical port number?

----------------------

Does anyone know of a way to programmatically change the name of the assigned camera interface?


Yes, use the System Configuration API. 

 

Read the help file... we don't have YourSystem! 


"Should be" isn't "Is" -Jay
0 Kudos
Message 29 of 33
(1,521 Views)

In the example below, what I was trying to do was add the serial numbers to the array in order of the first device plugged into the computer and the next device plugged into the computer, and that way I would use it to display the interface names with matching serial numbers.
An output like the following would occur.
index 0 camera 1
index 1, camera 2

So to summarize briefly, the serial number in index 0 will be camera 1, the serial number in index 1 will be camera 2 (serial number in index 0 or 1 should change according to the installation order). ) But the problem is that it always uses the same order (index 1 and index4) so it becomes unclear which is pluged first and which is pluged later. Because serial numbers are not unique. when I plug in the same com port,it gets the same serial number on both devices.

 

Is there a solution to this?

0 Kudos
Message 30 of 33
(1,502 Views)