commit | 0dd994dc32d0c36c352f79539375d37e04a6b82b | [log] [tgz] |
---|---|---|
author | Harvey Yang <chenghaoyang@chromium.org> | Sat Jan 16 15:43:45 2021 |
committer | Copybara-Service <copybara-worker@google.com> | Fri Jan 22 10:15:00 2021 |
tree | 52fcc3c23ad7e3d9628eea3b267edc585ca07eb7 | |
parent | 0e2a2d4994192b83f16810b32750feecb564b4fc [diff] |
libmems: Add CreateBuffer and FreeBuffer in IioDevice To flush old samples in IIO buffer, we should add CreateBuffer and FreeBuffer in IioDevice to allow users to control the lifetime of the buffer directly. BUG=b:177707650 TEST=unit tests Cq-Depend: chromium:2631711 Change-Id: Ic113f5a8c69aa60b410c822bc5f45f8210e60c15 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform2/+/2631710 Tested-by: Gwendal Grignou <gwendal@chromium.org> Commit-Queue: Cheng-Hao Yang <chenghaoyang@chromium.org> Reviewed-by: Gwendal Grignou <gwendal@chromium.org> GitOrigin-RevId: df365181399a901c864dc038cc395ea3caf64073
Project goal and motivation
This library provides a set of wrapper and test helpers around libiio.
It is meant to provide a common foundation for Chrome OS to access and interface IIO sensors, with:
At the root of the hierarchy, there exists the IioContext
, which represents the IIO devices currently available on the system. These can be retrieved by name and inspected, via instances of IioDevice
.
An IioDevice
allows reading and writing attributes of an IIO device via type-safe helper APIs. It also offers support for configuring the buffer and trigger of an IIO device, which we use in order to allow the Chrome UI to read accelerometer data and support screen rotation.
An IioDevice
also exposes a list of IioChannel
s, which can individually be enabled and disabled.
Useful mocks for the core classes are provided, such that a test author can focus on the logic of the unit tests and share a common testing language with other engineers working in this space. Sharing the foundation of testing IIO sensor access helps ensure that any improvement in this area can benefit all clients.