Add attribute values support to XML generation#1406
Open
Conversation
34d0b84 to
294a140
Compare
Collaborator
Author
Feedback RequestI wanted to get feedback on the Alternative options I thought of:
Open to other suggestions for better naming as well. Note: I discovered that buffer attributes changed (thanks to the pre-allocated buffer changes in main). This means buffer attribute values could and will be added to XML generation as a follow-up push. |
294a140 to
0111bb3
Compare
Collaborator
Author
|
Update V2:
|
Contributor
|
does |
Collaborator
Author
Good point, |
…ructs Add char **values fields to iio_device (per attr type), iio_channel, and iio_buffer to store attribute values alongside names. Update xml_header with optional value attribute (CDATA #IMPLIED) for attribute, debug-attribute, and buffer-attribute elements. Signed-off-by: Marius Lucacel <[email protected]>
Add include_values flag to XML generation functions so attribute values can optionally be serialized into the XML. Restructure leaf functions (iio_snprintf_xml_attr, iio_snprintf_chan_attr_xml) to build attributes in XML: name, optional filename, optional value Extends to buffer attributes inside <buffer> blocks. The backward-compat <buffer-attribute> tags intentionally omit values as they exist for older clients. iio_context_generate_xml() is now the helper instead of the older iio_context_get_xml() which now wraps it with include_values = false Signed-off-by: Marius Lucacel <[email protected]>
Add iio_context_refresh_attr_values() to read and cache all attribute values from devices, channels, and buffers into the context structures. Add iio_context_free_attr_values() to free those cached values after XML generation is complete. iio_context_generate_xml() calls refresh when include_values is true and always cleans up via iio_context_free_attr_values() Attribute values are now serialized into the XML output when include_values is true. Signed-off-by: Marius Lucacel <[email protected]>
Add a public wrapper function that generates XML including current attribute values. The function wraps iio_context_generate_xml(ctx, true) which refreshes all attribute values before serialization. Signed-off-by: Marius Lucacel <[email protected]>
Add a new -e/--emulator command-line option to iio_genxml to generate XML with device, channel and buffer attribute values. This utilizes the new iio_context_get_xml_with_values(). Update man page. Signed-off-by: Marius Lucacel <[email protected]>
0111bb3 to
3056ab0
Compare
Collaborator
Author
|
Update V3:
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
PR Description
This PR adds support for including attribute values in XML generation within libiio. The new functionality allows XML output to contain both attribute names and their values.
Currently, iio-emu has separate XML generation logic that duplicates functionality in
libiio.These commits add support for including attribute values in XML generation. This is the first step toward integrating
iio-emufunctionality intolibiio.Changes
iio_device,iio_channelandiio_bufferstructuresiio_context_get_xml_with_values()public API-eflag toiio_genxmlutilityiio_context_refresh_attr_values()to populate value arraysiio_context_free_attr_values()to free value arraysThe existing XML generation functions are extended with an
include_valuesparameter. When enabled, attribute values are refreshed from devices and serialized into the XML alongside their names.How it works
iio_context_get_xml_with_values()is called, it invokesiio_context_generate_xml(ctx, true)iio_context_generate_xml(ctx, true)first callsiio_context_refresh_attr_values()to read current attribute values from the hardwareiio_refresh_device_attr_values()to read device and debug attributes, allocating storage arrays on first useiio_refresh_channel_attr_values()to read channel attributes, allocating storage arrays on first useiio_refresh_buffer_attr_values()to read buffer attributes, allocating storage arrays on first useiio_snprintf_context_xml()generates the XML with the include_values flag, serializing storedvalues alongside attribute names
iio_context_generate_xml()frees all attribute values viaiio_context_free_attr_values()Usage
PR Type
PR Checklist