LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Save Com-Port in xml File

Hi all

I use xml-files to store settings in a project I'm working on. One of these settings is a VISA-Resource (in fact it's a serial port).
The settings are collected in a cluster including this VISA-Resource control, which is flattened to an xml-string and then stored as xml-data.

The problem I have no is, that fot this visa-resource a refnum is stored (e.g. 0x0671B9D8) which changes everytime I start the LV again. Is there a way to store the port information so that it remains the same or do I really have to code a fixed constant (which would be very bad >:().

Thanks in advance.

Thomas
Using LV8.0
--------------------------------------------------------------------
Don't be afraid to rate a good answer... 😉
--------------------------------------------------------------------
0 Kudos
Message 1 of 18
(4,458 Views)
I believe if you take the port data from a constant or a control (as opposed to from a VISA function) you will the name instead of the session refnum.
If this isn't possible, you could try wiring the refnum into a property node and extracting the resource name (that would be the ASRL...) I think if you type cast this into a VISA I/O type, you will get the right result.
A quick test suggests you may not even need to type cast it, but you can use the string itself.

___________________
Try to take over the world!
0 Kudos
Message 2 of 18
(4,448 Views)
Hi tst

As mentioned I use a cluster (as you can see in the attached pictures) which I directly process and write.
If it is possible I would keep this method. Just if there is no other way than take the control out of the cluster I'll change it, but I hope I don't have to.

Thomas
Using LV8.0
--------------------------------------------------------------------
Don't be afraid to rate a good answer... 😉
--------------------------------------------------------------------
0 Kudos
Message 3 of 18
(4,445 Views)
It's interesting - the reason I thought you were using something coming out of a VISA VI, and the reason I suggested you use a control, is because I use this exact method for saving the settings myself (except I flatten to string and save to a binary file) and it works perfectly for me - I get the port back OK.
As far as I can tell, You only get a reference out of the VISA VIs, not out of I/O controls\constants. Are you changing the settings control elsewhere (local, another VI)?
You can still try using the other method I suggested (Resource Name property) to get the name, and flatten the name into the XML instead of the reference.

___________________
Try to take over the world!
0 Kudos
Message 4 of 18
(4,445 Views)
I don't know any place in my program, where I change something which could influence the loading-/storing-process.

Definitly I could make some kind of workaround, which I think is very annoying, due to reason that it was a very nice way to just flatten a cluster to an xml-string and write it.

Well I could also use your technology, but I'd prefer a file which I can read easily.
Using LV8.0
--------------------------------------------------------------------
Don't be afraid to rate a good answer... 😉
--------------------------------------------------------------------
0 Kudos
Message 5 of 18
(4,441 Views)
I'm still not sure why you're getting this - I built a small cluster, flattened and unflattened it (no saving) using XML and it came out fine - COM1. Then, I ran it through a VISA config VI before flattening and it still came out fine. I'm not sure why this isn't working for you.

___________________
Try to take over the world!
0 Kudos
Message 6 of 18
(4,439 Views)
The Problem is, that each time I restart LV (I don't know if this happens in the compiled exe too) the reference-values change.

So one time I get for example 0x0671B9D8 and if I restart, the value should be 0x01985018 (Both values I got for the same COM-port). I saw this values when I wrote the file new.
Using LV8.0
--------------------------------------------------------------------
Don't be afraid to rate a good answer... 😉
--------------------------------------------------------------------
0 Kudos
Message 7 of 18
(4,436 Views)
I think the refnum is the session refnum (like any other refnum), so it's opened the first time you use one of the functions (or maybe automatically when LV opens, but I think it's the former) and remains open until you close LV (it seems unaffected by VISA close). If it changes between runs, it would explain why when you restart LV it would no longer be valid. It would explain why my earlier test worked (I didn't close LV) and it would also mean that it will cause problems in the EXE as well.

In that case, I don't understand why flattening to XML saves the refnum and not the resource name. I only know that saving it to a regular file works fine. Sorry.

___________________
Try to take over the world!
0 Kudos
Message 8 of 18
(4,429 Views)
Hi Thomas,

You're right about the fact that the "Flatten to XML" actually grabs the VISA reference (e.g. "0x073115C8") and not the name of the resource (e.g. "COM1"). Good catch! The workaround for this would be to capture the resource name (e.g. "COM1") first and then flatten this to XML. When reading this XML data later, you can convert it back to a VISA Resource Name data type that includes the new VISA reference to the resource. Please see the attached image for the solution.

Notice that in case you are using VISA aliases (like "COM1" instead of "ASRL1::INSTR"), these aliases have to be present on the machine that you resolve the XML file on. Otherwise it will not know what physical resource e.g. "COM1" refers to.

Have fun!
- Philip Courtois, Thinkbot Solutions

Thinkbot Solutions
0 Kudos
Message 9 of 18
(4,423 Views)
Hi Philip

Is there a reason for this? Due to the fact that this reference changes each time I restart LV, it is useless to store it - or am I wrong?

Thomas
Using LV8.0
--------------------------------------------------------------------
Don't be afraid to rate a good answer... 😉
--------------------------------------------------------------------
0 Kudos
Message 10 of 18
(4,420 Views)