05-18-2015 05:22 AM - edited 05-18-2015 05:24 AM
Hello guys,
I am trying to create one config ini file to save the serial port VISA selected.
I will fit if the file ini doesnt exist then search the serial ports in pc and choose one of them. If the file exist read the value to use when I use the acquisition data.
In example attached. I have a event structure (like my app), where I have one bottom to open the setting window 'options'. If you open the main vi and pass the error, open the options subvi and choose comport, if you click 'ok' it save the ini file, if you click 'cancel' it close and show in indicator the value of comport in ini file. The subvi works ok.
The problem is when I try to read the value of comport a the begining of application. I have put the code but it is wrong.
I used the 'easy saving and loading of control values' from tst ( https://decibel.ni.com/content/docs/DOC-15349 ) and it works ok for control the subvi.
Why I got error and I can not read the value of ini?.... section and key is correct. I dont find the problem.
Regards
Fred.
Solved! Go to Solution.
05-18-2015 06:42 AM
Your INI file contains a line like "COM port = "\13\00€\00\00\00\00\02\00\1E\007ÿÿÿÿ\00\04\13\00€\00\00\00\00\01\00\04\00\00\00\01\00\00\00\00\00\00\00.@p\00\0E\05Instr\00\01\00\00\13\00€\00\00\00\00\01\00\04\00\00\00\01\00\00\00\00\00\00\08COM port\00\00\01\00\01\00\00\00\04COM3\00\00\00\00" I would prefer ASCII text in my ini files.
there is also a typo of the File constant "options.vi.ni" instead of "options.vi.ini"
try using a constant path instead of the Application directory path, as for me, it resulted in <Not A Path>
I would advice to use the OpenG variant config files. Those are at least 'readable'.
Good luck! 🙂
05-18-2015 07:24 AM
I would also use the OpenG code for this. Flattening and Unflattening of VISA resources could be doing some weird things that might not work the way you want. Since you are filling in the drop down, you chould change it be a combo box instead of the VISA control.
05-18-2015 11:36 AM
Thanks guys,
Can you show me any link or example using OpenG for this?.
I already change it with file text. It is easier to build. But I am interested in check openG.
Regards, Fred.
05-18-2015 11:51 AM
I usually save serial com port numbers as a simple string to external config files. WHen I need to open the port I simply typecast the string to the VISA reference then send that to the open port function.
This makes LabVIEW handle all the 'gory stuff' instead of the external config file having to contain more information than might be needed.
It simplifies (for me) keeping info in external ini files.
I realize that perhaps this is not terribly robust but it has served me rather well for my 'in-house' applications.
05-18-2015 12:34 PM
05-19-2015 01:32 AM
07-19-2024 11:59 AM
Hi,
Kindly explain the flow of execution once it starts. Thanks
07-22-2024 05:01 AM
The VI takes an array of references to controls, uses the first one to get the name of the owning VI, generates an INI file with the name of that VI and saves or loads the values of those controls to or from the file. If you still don't understand it, it might help to run in highlight execution.
It's also explained in the link in the original post.
By the way, there's a reference leak in that code, because the OwningVI property creates a new reference to the VI every time it's called. That VI reference should be closed after being used.