LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

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


@constructionworker wrote:


Thanks for your answer.
Actually, I didn't think much of sticking to com port numbers.

I actually did a little test. I tried the devices I have on computers of the same version and I got an output like the one below with the same port location numbers.

constructionworker_1-1671101973201.png

The port number changes according to the port the device is plugged into. They show the same number on computers of the same version.

Can something be done with the location information here? So it's like reading the compport number in location.


And what would that help. You may maybe know in which physical port the device is plugged in but still not if it is camera XYZ pointing at your front door or camera ZYP pointing at your backyard. And anyone going to do a "quick" test by swapping the connectors will mess up your assumptions.

 

So the question is, what do you really want to standardize on? A port somewhere on your computer that has practically no meaning unless you have exactly the same hardware (and then say in your manual "plugin camera XYZ in the second USB port from the left on the back side") or something that is more meaningful to users and less hardware specific.

Rolf Kalbermatter
My Blog
0 Kudos
Message 11 of 33
(2,030 Views)

I would not worry at all about the Serial Device Enumerator.  Plug n play uses the Serenum HKEYS to pseudo assign a COM Port enumerator to each device.  It is possible to hack into the HKEY registry entries using the Windows Registry API but this is potentially dangerous if you don't know everything about every target machine and someone will plug in a strange USB device somewhere and start questioning the developer's mother's fidelity, species and state of grace while filling the nearest "Swear Jar."  Better; use the System Configuration API to programmaticly assign Aliases to your devices by serial number and use a Configuration file to hold key information. 


"Should be" isn't "Is" -Jay
0 Kudos
Message 12 of 33
(2,024 Views)

If the cameras have readable serial numbers, you may be able to use this:

sh.png

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

@constructionworker wrote:

There may be serial numbers that can change. Devices with different serial numbers can be installed from the same product.

I think I've explained the problem a little bit.


If the serial numbers change then they are not serial numbers. Not in any traditional sense wherein serial numbers provide a unique identifier to a piece of hardware.

 

If what you mean to say is that the serial numbers will not be the same across different systems or that converters may get swapped out, then you will need to provide a method to configure the identity of each camera. There is no way around that.

 

Assuming hardware is not constantly swapped out, this should be a one time setup task.

 

 


@constructionworker wrote:

Thanks for your answer. I've seen the example you have before. This example doesn't work very well in this regard.

I guess I can't explain the problem fully.
Let me try to explain in more detail.I have AHD converters and I want to connect them to a usb input that I specified.
For example:
usb port 1
usb port 2
usb port 3
When a video converter is plugged into either of these ports, it should get a fixed com port number. Because I am trying to create an application that works without user intervention.

How do you define USB1, USB2, etc? And if this needs to be distributed on multiple systems, I doubt there is any guarantee the USB ports will enumerate in the same order.


0 Kudos
Message 14 of 33
(2,002 Views)

 

 @ wrote:

And what would that help. You may maybe know in which physical port the device is plugged in but still not if it is camera XYZ pointing at your front door or camera ZYP pointing at your backyard. And anyone going to do a "quick" test by swapping the connectors will mess up your assumptions.

 

So the question is, what do you really want to standardize on? A port somewhere on your computer that has practically no meaning unless you have exactly the same hardware (and then say in your manual "plugin camera XYZ in the second USB port from the left on the back side") or something that is more meaningful to users and less hardware specific.

 


The products to be used will always be the same products. For the sake of understanding, hypothetically, maybe 100 work systems are used with the same materials. exactly the same company products.


@  wrote:

I would not worry at all about the Serial Device Enumerator.  Plug n play uses the Serenum HKEYS to pseudo assign a COM Port enumerator to each device.  It is possible to hack into the HKEY registry entries using the Windows Registry API but this is potentially dangerous if you don't know everything about every target machine and someone will plug in a strange USB device somewhere and start questioning the developer's mother's fidelity, species and state of grace while filling the nearest "Swear Jar."  Better; use the System Configuration API to programmaticly assign Aliases to your devices by serial number and use a Configuration file to hold key information. 


Can you give an example of how this can be done?


@paul_cardinale wrote:

If the cameras have readable serial numbers, you may be able to use this:

sh.png

 



@ Jim B wrote:
@constructionworker wrote:

There may be serial numbers that can change. Devices with different serial numbers can be installed from the same product.

I think I've explained the problem a little bit.

If the serial numbers change then they are not serial numbers. Not in any traditional sense wherein serial numbers provide a unique identifier to a piece of hardware.

 

If what you mean to say is that the serial numbers will not be the same across different systems or that converters may get swapped out, then you will need to provide a method to configure the identity of each camera. There is no way around that.

 

Assuming hardware is not constantly swapped out, this should be a one time setup task.

 

 

@constructionworker wrote:

Thanks for your answer. I've seen the example you have before. This example doesn't work very well in this regard.

I guess I can't explain the problem fully.
Let me try to explain in more detail.I have AHD converters and I want to connect them to a usb input that I specified.
For example:
usb port 1
usb port 2
usb port 3
When a video converter is plugged into either of these ports, it should get a fixed com port number. Because I am trying to create an application that works without user intervention.

How do you define USB1, USB2, etc? And if this needs to be distributed on multiple systems, I doubt there is any guarantee the USB ports will enumerate in the same order.

 


The project I want to create will always use the same computer version and the same converter version. But they probably may not have the same serial numbers. In this case, there is a possibility that the com port will change, so finding the com port assigned to the physical port seems like the most logical method for now, but I have no idea how to do it.
If I can find the compport assigned to the physical port;

plug camera -1 into a physical port-1
I say plug camera 2 into port-2.
and this way I would have solved my problem as I knew which camera was plugged into which physical port.

Any ideas on this?

0 Kudos
Message 15 of 33
(1,995 Views)

I'm a little confused.  When I open MAX, it tells me what devices are plugged into my computer (camera, DAQmx device, printer, communication device, etc.).  Can you post a screen-shot of your PC, running MAX, and showing Devices and Interfaces?  I'm assuming (??) that your Com Ports will show up as "something".  Here's an example:

MAX Devices and Interfaces.png

If you can "see" your Com Ports, you should (I hope) be able to "interrogate" them to discover what is attached, and if a Camera, what is its Serial Number.  Once you do that, you know (from the Serial Number) which Com Port has Camera 1 and which Com Port has Camera 2, and don't care into which USB connection on your PC is being used.

 

Bob Schor 

0 Kudos
Message 16 of 33
(1,984 Views)

@Bob_Schor wrote:

I'm a little confused.  When I open MAX, it tells me what devices are plugged into my computer (camera, DAQmx device, printer, communication device, etc.).  Can you post a screen-shot of your PC, running MAX, and showing Devices and Interfaces?  I'm assuming (??) that your Com Ports will show up as "something".  Here's an example:

MAX Devices and Interfaces.png

If you can "see" your Com Ports, you should (I hope) be able to "interrogate" them to discover what is attached, and if a Camera, what is its Serial Number.  Once you do that, you know (from the Serial Number) which Com Port has Camera 1 and which Com Port has Camera 2, and don't care into which USB connection on your PC is being used.

 

Bob Schor 


constructionworker_0-1671116476204.png

 

Yes, I can see the serial numbers, both are different.
Well, let's say we found the comport assignment according to the serial number of the 2 converters I have now, but what will happen if converters with different serial numbers are used in the application after creating and distributing the application?

0 Kudos
Message 17 of 33
(1,976 Views)

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.

Rolf Kalbermatter
My Blog
0 Kudos
Message 18 of 33
(1,934 Views)

@constructionworker wrote:

@Bob_Schor wrote:

I'm a little confused.  When I open MAX, it tells me what devices are plugged into my computer (camera, DAQmx device, printer, communication device, etc.).  Can you post a screen-shot of your PC, running MAX, and showing Devices and Interfaces?  I'm assuming (??) that your Com Ports will show up as "something".  Here's an example:

MAX Devices and Interfaces.png

If you can "see" your Com Ports, you should (I hope) be able to "interrogate" them to discover what is attached, and if a Camera, what is its Serial Number.  Once you do that, you know (from the Serial Number) which Com Port has Camera 1 and which Com Port has Camera 2, and don't care into which USB connection on your PC is being used.

 

Bob Schor 


constructionworker_0-1671116476204.png

 

Yes, I can see the serial numbers, both are different.
Well, let's say we found the comport assignment according to the serial number of the 2 converters I have now, but what will happen if converters with different serial numbers are used in the application after creating and distributing the application?


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. 


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

@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.

0 Kudos
Message 20 of 33
(1,915 Views)