LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Converting VISA Alias to COM Port breaks the COM port's ability to function after device power cycle

That's a great point. The main reason why that approach won't work is because we're trying to reliably cache one VISA resource, look it up through the registry, and find it even when the COM port itself changes (through some registry magic called the ContainerID). The way we initially convert VISA Alias -> Container ID (which is unique to a given device, even when multiple devices have the same Vendor and Product IDs) is by:

 

1. Convert Alias to COM Port (the piece of code in the conditional disable which breaks this)

2. Look in the registry, find the device with a specific Vendor ID, product ID, and a matching COM Port

3. Note down the ContainerID found with that COM Port

4. Future lookups will use the Container ID, vendor ID, and product ID to get the COM Port, so even if the port changes or the original alias is swapped, we can still be assured that we're talking to the same device.

 

The approach you mention is limited in that you still can have the COM Port change (for example, you plug in a new device with the same vendor and product ID), so if you're polling COM ports that way, you may end up switching devices.

 

We really want to immediately go from Alias -> ContainerID, then base all future interactions on the ContainerID. That way hardware changes do not fool the software into interacting with the wrong device.

 

 

---

 

All this to say, why is the COM port behaving differently than the Alias? The code works as desired when that conditional disable is on the "Disable" case, but as soon as you convert to a COM port, it no longer works. The two seem like they should be interchangeable.

0 Kudos
Message 11 of 13
(332 Views)

@ijustlovemath wrote:

That's a great point. The main reason why that approach won't work is because we're trying to reliably cache one VISA resource, look it up through the registry, and find it even when the COM port itself changes (through some registry magic called the ContainerID). The way we initially convert VISA Alias -> Container ID (which is unique to a given device, even when multiple devices have the same Vendor and Product IDs) is by:

 

1. Convert Alias to COM Port (the piece of code in the conditional disable which breaks this)

2. Look in the registry, find the device with a specific Vendor ID, product ID, and a matching COM Port

3. Note down the ContainerID found with that COM Port

4. Future lookups will use the Container ID, vendor ID, and product ID to get the COM Port, so even if the port changes or the original alias is swapped, we can still be assured that we're talking to the same device.

 

The approach you mention is limited in that you still can have the COM Port change (for example, you plug in a new device with the same vendor and product ID), so if you're polling COM ports that way, you may end up switching devices.

 

We really want to immediately go from Alias -> ContainerID, then base all future interactions on the ContainerID. That way hardware changes do not fool the software into interacting with the wrong device.

 

 

---

 

All this to say, why is the COM port behaving differently than the Alias? The code works as desired when that conditional disable is on the "Disable" case, but as soon as you convert to a COM port, it no longer works. The two seem like they should be interchangeable.


Is there another way to get the ContainerID without the registry? Like a query? Can you query the Serial Number instead and relate it to ContainerID?

 

Sorry,

mcduff

0 Kudos
Message 12 of 13
(320 Views)

That could be a fallback strategy! The main issue is when your device doesn't have a mechanism for reporting its serial number, and by relying on individual serial command grammars to properly cache, you lose the generalizability of the code (you need to implement a VI for each new type of device to do this mapping).

 

Here's where the "ContainerID" comes from, it's not something from the grammar, but within the registry itself. This is how you can uniquely identify a serial device (even within a group of devices with the same vendor and product IDs)

 

ijustlovemath_0-1613500822406.png

 

0 Kudos
Message 13 of 13
(313 Views)