Jump to content

Serial GUI difficulties


JPrevost

Recommended Posts

Maybe I'm missing something easy but how does one go about displaying only found and avail serial ports to the user in a nice "user friendly" name like COM1 instead of ASRL1::INSTR.

Thanks in advance.

I did user the;

[ALIASES]

Alias0 = "'LPT1','ASRL10::INSTR'"

Alias1 = "'COM1','ASRL1::INSTR'"

Alias2 = "'COM2','ASRL2::INSTR'"

Alias3 = "'COM3','ASRL3::INSTR'"

Alias4 = "'COM4','ASRL4::INSTR'"

Alias5 = "'COM5','ASRL5::INSTR'"

Alias6 = "'COM6','ASRL6::INSTR'"

Alias7 = "'COM7','ASRL7::INSTR'"

Alias8 = "'COM8','ASRL8::INSTR'"

NumAliases = 9

to get those friendly names but now they're ALL listed to the user when only a couple are really there. My other alternative is to do a polling of the serial ports to see which one is most likely the port with the hardware connected... totally removing the user from the picture :D

Link to post
Maybe I'm missing something easy but how does one go about displaying only found and avail serial ports to the user in a nice "user friendly" name like COM1 instead of ASRL1::INSTR.

Thanks in advance.

I did user the;

[ALIASES]

Alias0 = "'LPT1','ASRL10::INSTR'"

Alias1 = "'COM1','ASRL1::INSTR'"

Alias2 = "'COM2','ASRL2::INSTR'"

Alias3 = "'COM3','ASRL3::INSTR'"

Alias4 = "'COM4','ASRL4::INSTR'"

Alias5 = "'COM5','ASRL5::INSTR'"

Alias6 = "'COM6','ASRL6::INSTR'"

Alias7 = "'COM7','ASRL7::INSTR'"

Alias8 = "'COM8','ASRL8::INSTR'"

NumAliases = 9

to get those friendly names but now they're ALL listed to the user when only a couple are really there. My other alternative is to do a polling of the serial ports to see which one is most likely the port with the hardware connected... totally removing the user from the picture :D

The VISA resource name (taken off of the reference output of an Visa Open primative) can be wired to a Instrument property node that gives you all kinds of information about the devices. One of these properties is the Interface Information:Interface Description property which will spit out things like "ASRL1 (COM1 - Communications Port)" or "ASRL10 (LPT1 - ECP Printer Port)" which can be parsed easily for COM1 or LPT1.

If you wire a "VISA Find Resource" with a search query like "ASRL?*INSTR" and wire the output array to a FOR loop, you can iterate through them getting those human read-able names.

Of course, that may not be the easiest way, but it seems to be the least dependant on machine specific things such as aliases.

YMMV,

Joe (orko)

Link to post
The VISA resource name (taken off of the reference output of an Visa Open primative) can be wired to a Instrument property node that gives you all kinds of information about the devices. One of these properties is the Interface Information:Interface Description property which will spit out things like "ASRL1 (COM1 - Communications Port)" or "ASRL10 (LPT1 - ECP Printer Port)" which can be parsed easily for COM1 or LPT1.

If you wire a "VISA Find Resource" with a search query like "ASRL?*INSTR" and wire the output array to a FOR loop, you can iterate through them getting those human read-able names.

Of course, that may not be the easiest way, but it seems to be the least dependant on machine specific things such as aliases.

YMMV,

Joe (orko)

Okay, I understand how to do that but I'm still left with trying to display to the user the friendly names as a control for the config serial. Sure I can get the names but how to list them and open the serial port is where I'm stuck.

Link to post
Attached is one way to do it with the method I described. It should get you on the right track, but let me know if I missed the mark here.

Download File:post-3266-1140498851.vi

Cheers!

Joe (orko)

:oops: . I didn't know you could wire a string to the resource name terminal of the serial open subvi. :worship:

Can't you use the Measurement & Automation Explorer to set these?

post-2800-1140521614.png?width=400

That's the set up MY system, not the system the compiled program is running on! I have no trouble with the alias names... it's the end users that get confused.

Link to post
:oops: . I didn't know you could wire a string to the resource name terminal of the serial open subvi. :worship:

That's the set up MY system, not the system the compiled program is running on! I have no trouble with the alias names... it's the end users that get confused.

What I did once in an application was using the enclosed VI. Use the alias array to initialize the strings of a Ring Control. Then use the selection of the Ring Control to index into the adress string array and pass this to the VISA Open.

Rolf Kalbermatter

Download File:post-349-1140556159.vi

Link to post
What I did once in an application was using the enclosed VI. Use the alias array to initialize the strings of a Ring Control. Then use the selection of the Ring Control to index into the adress string array and pass this to the VISA Open.

Rolf Kalbermatter

Thanks Rolf! I didn't think to use both the canonical and the alias names in the indexed array. :D

Nicely simplified example!

Joe (orko)

Link to post
Here it is, no guarantee that it works the same in LabVIEW 7.0 though.

Rolf Kalbermatter

It worked just fine on my system under v7.0 when I tried it showing COM1 & COM2.

It show address ASRL1::INSTR for COM1 and a blank for COM2 but that's because my COM2 is tied to a status port on a UPS and was unavailable to respond to the port query.

Link to post
  • 3 months later...

I think that the attached VI is still a better implementation, getting the name as the port is known in the OS using the Interface Description property. The property node reports strings like "ASRL19 (COM17 - EdgePort [i40300200-0] Serial Port - 1)" (from a USB serial device) where one can scan for the real port name COM17 instead of COM19. It also lists the ports shared by other computers using VISA Server.

Edit: I disconnected typedefs and included Convert to VISA Rsrc.vi

Download File:post-447-1148580610.vi

Download File:post-447-1148580635.vi

Link to post

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use.