-
Notifications
You must be signed in to change notification settings - Fork 4
XML string handling is broken #9
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
The code quality of the python code in objdictgen has been (and still is) not great. The .od XML format is actually just a memdump of python objects and is the reason the format changes significantly between saves. This was not a particular wise design decision back in the days. This is why this tool now advocates using .json for storing the object dictionaries, and it has been designed to be stable & diffable. What do you mean by "old canfestival GUI"? Can you be a bit more specific, please? There exists many different variants and forks of canfestival and I believe upstream has disappeared. I think we need to agree on what should be the supported variants of canfestival. My take would be to support the https://github.com/Laerdal/canfestival-3-asc repo, and I had (initially) no intent to support older versions. What is your use case? What strings are this? Where is it used? Not all string types of canopen permits In general, we can decide how we want to interpret strings. I suggest start making a pytest test function that test this string and asserts the expected behavior. |
I am quite sure @aduskett is referring to the "legacy" file generation as referred in my issue #8 comment, when talking about "old canfestival GUI", and in general to file generation using objdictgen under Python 2. I totally agree with you that the .od format should be obsoleted in favour of .json. I also agree that https://github.com/Laerdal/canfestival-3-asc should be treated as the "official" one, and it is reasonable to not support older version too. I think that, in case someone needs to use the "legacy" file generation, a reasonable solution could be to go for a specific venv, or a Docker container, using Python 2 and wxPython 2.7. In relation to the current objdictgen/objdictedit version, I think the problem @aduskett is experiencing boils down to variables of "domain" type (that are managed as strings by the Python code), and not string (or "visible_string", using the canfestival nomenclature). Please see #10, where I explained what the problem is with "domain" and how to reproduce it. |
The py2 objdictgen have an implicit encoding of strings and unicode in the od format: <!-- A) This is a string -->
<attr name="s" type="string" value="hello" />
<!-- B) This is an unicode -->
<attr name="s" type="string">world</attr> In py3, strings are all This is where I think the xml encoding goes wrong for Are there other composite datatypes than |
The title is a bit vague, so please let me explain:
Currently, there are two significant issues with how string handling is done:
When processing a .od file, strings are not processed as byte arrays, which causes the size of arrays in generated c files to be much larger than intended. Take, for example, the following string: /X00/X00/X00. The old canfestival based on Python 2 creates an array of size three because it has three null characters, and Python2 treats strings as byte arrays. The current code treats the above as “/X00/X00/X00” which generates an array of size 12 because Python 3 treats all strings as UTF8!
In the old canfestival GUI, strings were converted to base 10. IE: 0XFF is converted to decimal (255) for the GUI, then converted back to hex for the .OD file. The current GUI does not convert the base 16 numbers to base 10 for the GUI, which seems like a significant regression.
Any help? The XML parser had a lot of warnings and odd-looking code when I loaded it up into PyCharm.
Thanks!
Adam
The text was updated successfully, but these errors were encountered: