Read-only gsubtree of platform2/libmems/ code

Clone this repo:

Branches

  1. 8ae8f0d libmems: Check sys path before creating IioDevice instances by Harvey Yang · 1 year, 1 month ago main
  2. 17f3618 platform2: Migrate base::StringPiece to std::string_view by Byron Lee · 8 months ago
  3. b5ec656 libmems: Mark libmems_test_support as test library by Gwendal Grignou · 8 months ago
  4. c6b395f libmems: Remove .pc files by Gwendal Grignou · 10 months ago
  5. dd8f9e7 libmems: Remove test library from rootfs image by Gwendal Grignou · 10 months ago

Chrome OS IIO Sensor Utility Library

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:

  • a strong emphasis on testability;
  • readable code, with the ergonomics typical of platform2;
  • high performance.

Class hierarchy

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 IioChannels, which can individually be enabled and disabled.

Test mocks

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.