XML_TO_VARIABLE has a BUG!
Spire_Jeff
Formerly Caffeinated Programmer
Just a heads up. I have stumbled across an error in xml_to_variable. I am using NS 2.6 and the problem presents itself when dealing with a structure. I have not narrowed it down completely, but I was using the same code set to encode/decode 4 different structures and I was having a problem with only one structure. I have spent plenty of time verifying that I did not make a stupid little typo somewhere and I have even sent the code into tech support. The problem presents as an error code 1 = structure too small, more members in XML decode string. Switching to string_to_variable and variable_to_string makes the problem go away.
If I ever have the time, I will start to pull elements out of the structure until I figure out which one is causing the problem, but I figured I would post this and hopefully save someone a few hours of debugging.
Jeff
If I ever have the time, I will start to pull elements out of the structure until I figure out which one is causing the problem, but I figured I would post this and hopefully save someone a few hours of debugging.
Jeff
Comments
-
I can verify this and have reported it to AMX. The issue occured for me when decoding previously encoded dev variables. I've not had any problems where dev's aren't used.
Edit: Third time lucky. It was a long time ago that I flagged the problem so my memory's a bit hazy, but just to clarify: the dev variables were elements of the structure I was encoding / decoding. Removing the dev elements from the structure resolved the problem. Perhaps it's an issue with decoding previously encoded structures which have one or more elements which are also structures? -
Curious if your just running out of space in your char array in the orginal encode? Do a LENGTH_VARIABLE_TO_XML prior to encoding to see if your char array was big enough... Just a thought...
-
I know that in my case, there is plenty of room. The encoded variable length was around 1800 (I did use LENGTH_VARIABLE_TO_XML to determine this), and the variable to hold this was set at 50,000 (I started at 10,000 and moved to 20k, then 40k and finally 50k before I found LENGTH_VARIABLE_TO_XML
).
The structure that I am encoding does contain a device, however I thought I removed that and still had the problem... but in the multitasking world I have to live in (read as interruptions) I may have missed the write a new file step
I had my suspicions that it was the DEV tho. If you look at the XML, my guess is that the decode routine is not accounting properly for the <STRUCTURE> </STRUCTURE> tags.
Now, if we can get a tech note regarding this, the next time I'm too lazy too look through tech notes and decide to call tech support, they can laugh at me and tell me to RTFM before calling them
Jeff -
Does anyone know if this bug is fixed?
--John -
O.K., it's looking to me like it's still not fixed unless someone has different info.
--John -
nope, not fixed.John Gonzales wrote: »O.K., it's looking to me like it's still not fixed unless someone has different info.
--John -
Thanks for the confirmation Eric. I had switched my functions to use variable_to_string prior to my previous post and it started working which led me to believe the bug still wasn't fixed. But in the back of my head I was still wondering if it was a code error on my part. Now I feel better!
--John -
I gave up on AMX fixing it a long time ago. Based on a conversation I had with someone, fixing the functions would require more work than meets the eye and most people don't use the functions. It is a low priority from what I understand. In the end, I decided that I really didn't matter anyway as the XML file produced did not seem to work with most XML viewers/editors. I decided to write my own encoding/decoding functions. Unfortunately, I need to write a new one for every structure I want to save/read, but I can edit the data in the files a lot easier.
Also, be cautious of the variable_to_string function as there are problems with that as well. I created a thread a while back that discussed the problems with both. Altho, at this point, I don't remember if string_to_variable had a real problem with the implementation, or just wasn't doing what I needed.
Jeff -
"Using xml_to_variable does not work when the target structure contains a device definition."
Am I stating the problem correctly? I want to make sure I understand.
I use xml_to_variable every time I need to save data to disk. I do this quite often. I have never had a problem, but I don't think any of my structures (that I write out) contain device definitions.
Does variable_to_xml work with a dev?
Does using string_to_variable work with a dev? Sounds like it might, but would like confirmation. -
This has been fixed and is available in the latest firmware (3.41.422). It just didn't make it into the release notes. Sorry.
-
This has been fixed and is available in the latest firmware (3.41.422). It just didn't make it into the release notes. Sorry.
I'm sorry. to which this are you referring? There are several issues addressed in this thread. -
Does variable_to_xml work with a dev?
In my experience, variable_to_xml does not return an error when encoding devs, but xml_to_variable will fail to deserialise the encoded variable. As indicated in my post above, when I ran into this, the dev in question was an element of a structure which was being serialised/deserialised, so it may be an issue with encoding/decoding structures which are an element of another structure. -
Sorry, I wasn't specific enough. xml_to_variable and variable_to_xml had bugs when encoding/decoding dev variables. This has been fixed in build x.x.422 of firmware available on the website for the NI masters.
Categories
- All Categories
- 2.5K AMX General Discussion
- 922 AMX Technical Discussion
- 514 AMX Hardware
- 502 AMX Control Products
- 3 AMX Video Distribution Products
- 9 AMX Networked AV (SVSI) Products
- AMX Workspace & Collaboration Products
- 3.4K AMX Software
- 151 AMX Resource Management Suite Software
- 386 AMX Design Tools
- 2.4K NetLinx Studio
- 135 Duet/Cafe Duet
- 248 NetLinx Modules & Duet Modules
- 57 AMX RPM Forum
- 228 MODPEDIA - The Public Repository of Modules for Everyone
- 943 AMX Specialty Forums
- 2.6K AMXForums Archive
- 2.6K AMXForums Archive Threads
- 1.5K AMX Hardware
- 432 AMX Applications and Solutions
- 249 Residential Forum
- 182 Tips and Tricks
- 146 AMX Website/Forums