Skip to content

[RFC PATCH v4] iio: repeat channel support and dummy client example #42

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

Closed

Conversation

lucasrangit
Copy link
Contributor

iio_chan_type IIO_ROT uses the repeat channel iio_chan_spec.scan_type.repeat to store repeated elements in a channel without modifiers.

This patch series adds support to libiio and creates a new example tool that exercises the iio_dummy driver. For testing this series the iio_dummy can be patched to include the IIO_ROT channel. See lucasrangit/linux-iio#1 .

Signed-off-by: Lucas Magasweran [email protected]


Changes since v1:

  • tests: iio_info: compared format->repeat > 1 for consistent output and avoid duplicated printf
  • examples: dummy: remove debug print of scan channel size and repeat count
    and squashed commits since this is a new sample tool
  • added missing Signed-off-by to commits

Changes since v2:

  • iio: moved struct iio_data_format member repeat to the end of the struct to maintain forward ABI compatibility.
  • iio: added a note specifying that the member was added in version v0.8 (assuming this will be merged). this shows up in the doxygen documentation where users are more likely to see a potential version dependency.
  • docs: added note to main page about abi compatibility and recommended usage of iio_library_get_version().
  • examples: dummy: even though this is versioned with the latest source, it may be run against older library versions so it includes an example of checking the library for a feature and conditionally using that feature if supported.

Linux struct iio_chan_spec supports a 'repeat' scan_type attribute that
represents the number of times the element repeats. A value of 0 and 1
signifies no repeat.

In order maintain backwards and forwards compatibility, the repeat field was
added to the end of the struct. This means applications compiled against an
older version will work fine with the newer dynamically linked library.
Applications compiled against a newer version will work fine with the older
dynamically linked library so long as they don't access this new feature.
Applications using this new feature should ensure the libiio version is
compatible by using iio_library_get_version() to avoid undefined behavior.

Signed-off-by: Lucas Magasweran <[email protected]>
This matches the optional X%u repeat count in sysfs _type scan element
format attribute.

Signed-off-by: Lucas Magasweran <[email protected]>
@@ -1232,6 +1233,9 @@ struct iio_data_format {

/** @brief Contains the scale to apply if with_scale is set */
double scale;

/** @brief Number of times length repeats (added in v0.8) */
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I am assuming this will be merged and released with v0.8.

printf("Library version: %u.%u (git tag: %s)\n", major, minor, git_tag);

/* check for struct iio_data_format.repeat support */
has_repeat = major >= 0 && minor >= 8 ? true : false;
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I am assuming this will be merged and released with v0.8.

@pcercuei
Copy link
Contributor

I don't like how you use "(chn->format.repeat ? chn->format.repeat : 1)" everywhere.
It does not make sense to have chn->format.repeat set to 0 anyway, why not initialize it to 1 by default?

@lucasrangit
Copy link
Contributor Author

I did that so that the libiio repeat field matched the value in the kernel,
which doesn't initialize to 1. However, I see your point and will change
it.

Thanks for the feedback!

On Tue, Sep 20, 2016, 05:52 Paul Cercueil [email protected] wrote:

I don't like how you use "(chn->format.repeat ? chn->format.repeat : 1)"
everywhere.
It does not make sense to have chn->format.repeat set to 0 anyway, why not
initialize it to 1 by default?


You are receiving this because you authored the thread.
Reply to this email directly, view it on GitHub
#42 (comment),
or mute the thread
https://github.com/notifications/unsubscribe-auth/AAq1ertkQ3-nOs_NfenPzGrPCQbLP0ziks5qr9bsgaJpZM4J-e64
.

@pcercuei
Copy link
Contributor

Thanks :)

@lucasrangit
Copy link
Contributor Author

Changed the initial value of repeat in pull request #43.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants