LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Save and Open Serial port setting (VISA name)

I have a program where the user can select the serial port to be used. COM1, COM2, etc. from a VISA resource selector. I also have a button that will save all settings to a configuration file. All settings are grouped into a cluster. Then I use Flattened to XML and Write to XML FIle. I do the reverse when loading a configuration file.

Everything works great except for the COM port selection. The serial port gets saved as a Ref #, which cannot be loaded back when opening the configuration file.

I've searched and found mentioning of RefNum to Session and Session to RefNum. I've tried that but the Session to RefNum also requires a Class Type and I can't get that to work. A "temp 0" appears in the VISA resource selector dropdown box.

All I would like to do is save whether the user picked COM1 or COM2 so they don't have to pick it every time they start the program. Does anyone have an example VI that does this?

Thanks
-Ryan
0 Kudos
Message 1 of 5
(2,992 Views)
RyanRaytheon,

This VI shows a method of accomplishing this. It extracts the resource string (which you can easily save to file), then shows how to convert the string back to a VISA resource when you load it back from file. Enjoy!

<-*DrkOvrlord*->
Message 2 of 5
(2,983 Views)
This works also without a typecast back to the resource.
The conversion although canges com1 into asrl1::instr
on my machine. could be confusing to the user.
greetings from the Netherlands
0 Kudos
Message 3 of 5
(2,976 Views)
Thanks for the quick responses. This is what i was looking for.
-Ryan
0 Kudos
Message 4 of 5
(2,938 Views)
It is a good news for me.
0 Kudos
Message 5 of 5
(2,354 Views)