Instrument Control (GPIB, Serial, VISA, IVI)

cancel
Showing results for 
Search instead for 
Did you mean: 

VISA Find resource function regular expression

Hi guys,

 

I've been trying to get which Serial port is a GPS receiver connected to using the VISA Find Resource Function with no luck. The idea is to use a regular expression similar to

 

ASRL?*INSTR{VI_ATTR_ASRL_BAUD == 9600}

 

but instead of looking for baud rate, I want to search the value

 

ASRL3 (COM3 - GNSS Receiver)

 

as seen in MAX/VISA Test Panel. The attribute name is VI_ATTR_INTF_INST_NAME.

 

Something like ASRL?*INSTR{VI_ATTR_INTF_INST_NAME == ASRL? (COM? - GNSS Receiver)} should work, but it's not.

 

How should I write the expression?

 

Thanks! 🙂

Best regards,
Néstor

LabVIEW 2017 + Windows 10
0 Kudos
Message 1 of 11
(6,940 Views)
How are you assigning the instrument name? MAX doesn't do it automatically. Typically, you would get a list of all serial ports and send a query to each one, look for s specific response, and determine which instrument is connected to which port.
0 Kudos
Message 2 of 11
(6,937 Views)

Hi Dennis,

 

thanks for answering.

 

I haven't assigned the name, MAX did it. I just opened MAX and there it was, COM3 (In Devices and interfaces/ASRL3/settings/name). I suppose it gets directly the Windows serial port name, what name do you mean exactly?

 

Anyway, what I'm interested in getting is the Port description, that would tell me the connected device in that port. I could build a small loop and look for the interface description of each serial device, but I found the VISA Find Resourde function and it seems a more simple and direct way to get what I want.

 

If I can list all serial devices with 9600 baud rate as in the previous example, why not do the same with the instrument name? I clearly see it when I open the VISA Test Panel. I am maybe missing something?

Best regards,
Néstor

LabVIEW 2017 + Windows 10
0 Kudos
Message 3 of 11
(6,926 Views)
You said you were looking for GNSS Receiver and now you say you did not assign this to anything in MAX. Where would you think this name comes from? MAX won't list anything except the com port.
0 Kudos
Message 4 of 11
(6,923 Views)
Meant to add that you either get the canonical name (ASRLx) or the alias. The alias Comx or an alias you change to.
0 Kudos
Message 5 of 11
(6,922 Views)

No, I didn't assign it to anything in MAX, but it's there. I can communicate with the GPS, it's in the COM3 port. And in MAX I can see the GNSS Receiver description in "Port description":

COM3-GNSS.PNG

 

So I think the function should be capable of reading this, am I right? Maybe we are not understanding each other Smiley LOL

Best regards,
Néstor

LabVIEW 2017 + Windows 10
0 Kudos
Message 6 of 11
(6,917 Views)
Yes, I misunderstood. The device name must be coming from the Windows device driver. I've never had such a thing since I've always used generic USB-RS232 converters to connect to serial devices.

Try doing a search where name == GNSS Receiver. Since it seems you want to determine the com port alias, I don't understand why you are specifically just looking for com 3.
0 Kudos
Message 7 of 11
(6,913 Views)

Sure, well, COM3 was an example, the idea is to get "COM?".

 

How would you do the search exactly? I'm kind of lost with the particularities of regular expressions.

Best regards,
Néstor

LabVIEW 2017 + Windows 10
0 Kudos
Message 8 of 11
(6,888 Views)

I have this already:

GNSS-in-what-COM.PNG

 

But it would be much cleaner and efficient just with the proper regular expression in the VISA Find... Smiley Tongue

Best regards,
Néstor

LabVIEW 2017 + Windows 10
0 Kudos
Message 9 of 11
(6,882 Views)
The regular expression is pretty new to me as well and I have no way to test it right now. How much time does your existing code take?
0 Kudos
Message 10 of 11
(6,875 Views)