xref: /aosp_15_r20/external/pigweed/pw_sensor/py/docs.rst (revision 61c4878ac05f98d0ceed94b57d316916de578985)
1*61c4878aSAndroid Build Coastguard Worker.. _module-pw_sensor-py:
2*61c4878aSAndroid Build Coastguard Worker
3*61c4878aSAndroid Build Coastguard Worker========================
4*61c4878aSAndroid Build Coastguard Workerpw_sensor Python package
5*61c4878aSAndroid Build Coastguard Worker========================
6*61c4878aSAndroid Build Coastguard Worker.. pigweed-module::
7*61c4878aSAndroid Build Coastguard Worker   :name: pw_sensor
8*61c4878aSAndroid Build Coastguard Worker
9*61c4878aSAndroid Build Coastguard Worker   - **Configure Sensors**: Update the sensor configurations to match your
10*61c4878aSAndroid Build Coastguard Worker     requirements. Sensor configurations can be checked at compile time using
11*61c4878aSAndroid Build Coastguard Worker     a YAML sensor description.
12*61c4878aSAndroid Build Coastguard Worker   - **2 Phase Reading**: Design your own pipeline and priorities. Sensor can be
13*61c4878aSAndroid Build Coastguard Worker     read on one thread (or no thread if DMA is available) and the data can be
14*61c4878aSAndroid Build Coastguard Worker     decoded on another thread/core/device.
15*61c4878aSAndroid Build Coastguard Worker
16*61c4878aSAndroid Build Coastguard WorkerThe ``pw_sensor`` Python package provides utilities for generating data and code
17*61c4878aSAndroid Build Coastguard Workerfor Pigweed sensor drivers.
18*61c4878aSAndroid Build Coastguard Worker
19*61c4878aSAndroid Build Coastguard Worker.. warning::
20*61c4878aSAndroid Build Coastguard Worker   This package is under development and the APIs are *VERY* likely to change.
21*61c4878aSAndroid Build Coastguard Worker
22*61c4878aSAndroid Build Coastguard Worker-----------------
23*61c4878aSAndroid Build Coastguard WorkerUsing the package
24*61c4878aSAndroid Build Coastguard Worker-----------------
25*61c4878aSAndroid Build Coastguard WorkerTypical users of ``pw_sensor`` begin by writing a YAML description of their
26*61c4878aSAndroid Build Coastguard Workersensor using the `metadata_schema.json`_ format, e.g.:
27*61c4878aSAndroid Build Coastguard Worker
28*61c4878aSAndroid Build Coastguard Worker.. code-block:: yaml
29*61c4878aSAndroid Build Coastguard Worker
30*61c4878aSAndroid Build Coastguard Worker   deps:
31*61c4878aSAndroid Build Coastguard Worker      - "pw_sensor/channels.yaml"
32*61c4878aSAndroid Build Coastguard Worker      - "pw_sensor/attributes.yaml"
33*61c4878aSAndroid Build Coastguard Worker   compatible:
34*61c4878aSAndroid Build Coastguard Worker      org: "Bosch"
35*61c4878aSAndroid Build Coastguard Worker      part: "BMA4xx"
36*61c4878aSAndroid Build Coastguard Worker   supported-buses:
37*61c4878aSAndroid Build Coastguard Worker      - i2c
38*61c4878aSAndroid Build Coastguard Worker      - spi
39*61c4878aSAndroid Build Coastguard Worker   channels:
40*61c4878aSAndroid Build Coastguard Worker      acceleration: []
41*61c4878aSAndroid Build Coastguard Worker      die_temperature: []
42*61c4878aSAndroid Build Coastguard Worker
43*61c4878aSAndroid Build Coastguard Worker
44*61c4878aSAndroid Build Coastguard Worker``pw_sensor`` provides a validator which will resolve any 'default' properties
45*61c4878aSAndroid Build Coastguard Workerand make the final YAML easier for code generators to consume. The returned
46*61c4878aSAndroid Build Coastguard Workerdictionary uses the `resolved_schema.json`_ format.
47*61c4878aSAndroid Build Coastguard Worker
48*61c4878aSAndroid Build Coastguard WorkerEvery platform/language may implement their own generator.
49*61c4878aSAndroid Build Coastguard WorkerGenerators consume the validated (schema-compliant) YAML and may produce
50*61c4878aSAndroid Build Coastguard Workermany types of outputs, such as a PDF datasheet, a C++ abstract class definition,
51*61c4878aSAndroid Build Coastguard Workeror a Zephyr header of definitions describing the sensor.
52*61c4878aSAndroid Build Coastguard Worker
53*61c4878aSAndroid Build Coastguard Worker-------------------
54*61c4878aSAndroid Build Coastguard WorkerDescribing a sensor
55*61c4878aSAndroid Build Coastguard Worker-------------------
56*61c4878aSAndroid Build Coastguard WorkerWhen describing a sensor from the user's perspective, there are 3 primary points
57*61c4878aSAndroid Build Coastguard Workerof interaction:
58*61c4878aSAndroid Build Coastguard Worker
59*61c4878aSAndroid Build Coastguard Worker#. compatible descriptor
60*61c4878aSAndroid Build Coastguard Worker#. supported buses
61*61c4878aSAndroid Build Coastguard Worker#. channels
62*61c4878aSAndroid Build Coastguard Worker#. attributes
63*61c4878aSAndroid Build Coastguard Worker#. triggers
64*61c4878aSAndroid Build Coastguard Worker
65*61c4878aSAndroid Build Coastguard Worker.. note::
66*61c4878aSAndroid Build Coastguard Worker   Compatible string in Linux's devicetree are used to detail what a hardware
67*61c4878aSAndroid Build Coastguard Worker   device is. They include a manufacturer and a model name in the format:
68*61c4878aSAndroid Build Coastguard Worker   ``<manufacturer>,<model>``. In order to make this a bit more generic and
69*61c4878aSAndroid Build Coastguard Worker   still functional with devicetree, Pigweed's compatible node consists of 2
70*61c4878aSAndroid Build Coastguard Worker   separate properties instead of a single string: ``org`` and ``part``. This
71*61c4878aSAndroid Build Coastguard Worker   abstracts away the devicetree model such that generators may produce other
72*61c4878aSAndroid Build Coastguard Worker   targeted code. To read more about the compatible property, see
73*61c4878aSAndroid Build Coastguard Worker   `Understanding the compatible Property`_
74*61c4878aSAndroid Build Coastguard Worker
75*61c4878aSAndroid Build Coastguard WorkerBoth *channels* and *attributes* covered in :ref:`seed-0120`, while the
76*61c4878aSAndroid Build Coastguard Worker*compatible* descriptor allows us to have a unique identifier for each sensor.
77*61c4878aSAndroid Build Coastguard WorkerNext, we need a way to describe a sensor in a platform and language agnostic
78*61c4878aSAndroid Build Coastguard Workerway.
79*61c4878aSAndroid Build Coastguard Worker
80*61c4878aSAndroid Build Coastguard WorkerWhat are supported buses?
81*61c4878aSAndroid Build Coastguard Worker=========================
82*61c4878aSAndroid Build Coastguard WorkerCurrently, pw_sensor supports 2 types of sensor buses: i2c and spi. Each sensor
83*61c4878aSAndroid Build Coastguard Workermust list at least 1 supported bus. Additional buses may be added as well as
84*61c4878aSAndroid Build Coastguard Workersupport for custom bus descriptors in downstream projects.
85*61c4878aSAndroid Build Coastguard Worker
86*61c4878aSAndroid Build Coastguard WorkerWhat are channels?
87*61c4878aSAndroid Build Coastguard Worker==================
88*61c4878aSAndroid Build Coastguard WorkerA channel is something that we can measure from a sensor. It's reasonable to ask
89*61c4878aSAndroid Build Coastguard Worker"why not call it a measurement"? The answer is that a measurement isn't specific
90*61c4878aSAndroid Build Coastguard Workerenough. A single illuminance sensor might provide a lux reading for:
91*61c4878aSAndroid Build Coastguard Worker- Total lux (amount of light per square meter)
92*61c4878aSAndroid Build Coastguard Worker- Red lux (amount of red light per square meter)
93*61c4878aSAndroid Build Coastguard Worker- Green lux (amount of green light per square meter)
94*61c4878aSAndroid Build Coastguard Worker- Blue lux (amount of blue light per square meter)
95*61c4878aSAndroid Build Coastguard Worker- UV lux (amount of UV light per square meter)
96*61c4878aSAndroid Build Coastguard Worker- IR lux (amount of infra-red light per square meter)
97*61c4878aSAndroid Build Coastguard Worker
98*61c4878aSAndroid Build Coastguard WorkerAll these are a "measurement" of light intensity, but they're different
99*61c4878aSAndroid Build Coastguard Workerchannels. When defining a channel we need to provide units. In the example
100*61c4878aSAndroid Build Coastguard Workerabove, the units are lux. Represented by the symbol "lx". It's likely that when
101*61c4878aSAndroid Build Coastguard Workerverbose logging is needed or when generating documentation we might want to also
102*61c4878aSAndroid Build Coastguard Workerassociate a name and a longer description for the channel. This leaves us with
103*61c4878aSAndroid Build Coastguard Workerthe following structure for a channel:
104*61c4878aSAndroid Build Coastguard Worker
105*61c4878aSAndroid Build Coastguard Worker.. code-block:: yaml
106*61c4878aSAndroid Build Coastguard Worker
107*61c4878aSAndroid Build Coastguard Worker   <channel_id>:
108*61c4878aSAndroid Build Coastguard Worker      "name": "string"
109*61c4878aSAndroid Build Coastguard Worker      "description": "string"
110*61c4878aSAndroid Build Coastguard Worker      "units": <string_units_id>
111*61c4878aSAndroid Build Coastguard Worker
112*61c4878aSAndroid Build Coastguard WorkerWhen we construct the final sensor metadata, we can list the channels supported
113*61c4878aSAndroid Build Coastguard Workerby that sensor. In some cases, the same channel may be available more than once.
114*61c4878aSAndroid Build Coastguard WorkerThis happens at times with temperature sensors. In these cases, we can list
115*61c4878aSAndroid Build Coastguard Workermultiple instances of a channel. Generally, if no instances are provided, it
116*61c4878aSAndroid Build Coastguard Workerwill be assumed that there's 1 instance of the channel. Otherwise, we might have
117*61c4878aSAndroid Build Coastguard Workersomething like:
118*61c4878aSAndroid Build Coastguard Worker
119*61c4878aSAndroid Build Coastguard Worker.. code-block:: yaml
120*61c4878aSAndroid Build Coastguard Worker
121*61c4878aSAndroid Build Coastguard Worker   channels:
122*61c4878aSAndroid Build Coastguard Worker      ambient_temperature:
123*61c4878aSAndroid Build Coastguard Worker         -  name: "-X"
124*61c4878aSAndroid Build Coastguard Worker            description: "temperature measured in the -X direction"
125*61c4878aSAndroid Build Coastguard Worker            units: "temperature"
126*61c4878aSAndroid Build Coastguard Worker         -  name: "X"
127*61c4878aSAndroid Build Coastguard Worker            description: "temperature measured in the +X direction"
128*61c4878aSAndroid Build Coastguard Worker            units: "temperature"
129*61c4878aSAndroid Build Coastguard Worker
130*61c4878aSAndroid Build Coastguard WorkerWhat are attributes?
131*61c4878aSAndroid Build Coastguard Worker====================
132*61c4878aSAndroid Build Coastguard WorkerAttributes are used to change the behavior of a sensor. They're defined using
133*61c4878aSAndroid Build Coastguard Workerthe ``attributes`` key and are structured by associating the defined attribute
134*61c4878aSAndroid Build Coastguard Workertype with a channel along with units and a representation (``float``,
135*61c4878aSAndroid Build Coastguard Worker``signed``, or ``unsigned``). Here's an example:
136*61c4878aSAndroid Build Coastguard Worker
137*61c4878aSAndroid Build Coastguard Worker.. code-block:: yaml
138*61c4878aSAndroid Build Coastguard Worker
139*61c4878aSAndroid Build Coastguard Worker   attributes:
140*61c4878aSAndroid Build Coastguard Worker      -  attribute: "sample_rate"
141*61c4878aSAndroid Build Coastguard Worker         channel: "acceleration"
142*61c4878aSAndroid Build Coastguard Worker         units: "frequency"
143*61c4878aSAndroid Build Coastguard Worker         representation: "float"
144*61c4878aSAndroid Build Coastguard Worker
145*61c4878aSAndroid Build Coastguard WorkerWhen associated with a ``sensor``, ``attributes`` define specific instances of
146*61c4878aSAndroid Build Coastguard Workerconfigurable states for that sensor:
147*61c4878aSAndroid Build Coastguard Worker
148*61c4878aSAndroid Build Coastguard Worker.. code-block:: yaml
149*61c4878aSAndroid Build Coastguard Worker
150*61c4878aSAndroid Build Coastguard Worker   compatible: ...
151*61c4878aSAndroid Build Coastguard Worker   channels: ...
152*61c4878aSAndroid Build Coastguard Worker   attributes:
153*61c4878aSAndroid Build Coastguard Worker      -  {}
154*61c4878aSAndroid Build Coastguard Worker
155*61c4878aSAndroid Build Coastguard WorkerWhat are triggers?
156*61c4878aSAndroid Build Coastguard Worker==================
157*61c4878aSAndroid Build Coastguard WorkerTriggers are events that have an interrupt associated with them. We can define
158*61c4878aSAndroid Build Coastguard Workercommon triggers which sensors can individually subscribe to. The definition
159*61c4878aSAndroid Build Coastguard Workerlooks like:
160*61c4878aSAndroid Build Coastguard Worker
161*61c4878aSAndroid Build Coastguard Worker.. code-block:: yaml
162*61c4878aSAndroid Build Coastguard Worker
163*61c4878aSAndroid Build Coastguard Worker   triggers:
164*61c4878aSAndroid Build Coastguard Worker      fifo_watermark:
165*61c4878aSAndroid Build Coastguard Worker         name: "FIFO watermark"
166*61c4878aSAndroid Build Coastguard Worker         description: "Interrupt when the FIFO watermark has been reached (set as an attribute)"
167*61c4878aSAndroid Build Coastguard Worker
168*61c4878aSAndroid Build Coastguard WorkerWhen associated with a ``sensor``, we simply need to match the right key in a
169*61c4878aSAndroid Build Coastguard Workerlist:
170*61c4878aSAndroid Build Coastguard Worker
171*61c4878aSAndroid Build Coastguard Worker.. code-block:: yaml
172*61c4878aSAndroid Build Coastguard Worker
173*61c4878aSAndroid Build Coastguard Worker   compatible: ...
174*61c4878aSAndroid Build Coastguard Worker   channels: ...
175*61c4878aSAndroid Build Coastguard Worker   attributes: ...
176*61c4878aSAndroid Build Coastguard Worker   triggers:
177*61c4878aSAndroid Build Coastguard Worker      -  fifo_watermark
178*61c4878aSAndroid Build Coastguard Worker
179*61c4878aSAndroid Build Coastguard WorkerAdditional metadata
180*61c4878aSAndroid Build Coastguard Worker===================
181*61c4878aSAndroid Build Coastguard WorkerIt's common for applications to require additional metadata that's not
182*61c4878aSAndroid Build Coastguard Workersupported or used by Pigweed. These additional values can be added to the
183*61c4878aSAndroid Build Coastguard Worker``extras`` key of the sensor:
184*61c4878aSAndroid Build Coastguard Worker
185*61c4878aSAndroid Build Coastguard Worker.. code-block:: yaml
186*61c4878aSAndroid Build Coastguard Worker
187*61c4878aSAndroid Build Coastguard Worker   compatible: ...
188*61c4878aSAndroid Build Coastguard Worker   channels: ...
189*61c4878aSAndroid Build Coastguard Worker   extras:
190*61c4878aSAndroid Build Coastguard Worker     doc-ref: "my-driver-rst-ref"
191*61c4878aSAndroid Build Coastguard Worker     memory-req: 512
192*61c4878aSAndroid Build Coastguard Worker
193*61c4878aSAndroid Build Coastguard WorkerValues added here can be read by generator scripts.
194*61c4878aSAndroid Build Coastguard Worker
195*61c4878aSAndroid Build Coastguard Worker-----------------------
196*61c4878aSAndroid Build Coastguard WorkerThe ``Validator`` class
197*61c4878aSAndroid Build Coastguard Worker-----------------------
198*61c4878aSAndroid Build Coastguard WorkerThe ``Validator`` class is used to take a sensor spec YAML file and expand it
199*61c4878aSAndroid Build Coastguard Workerwhile verifying that all the information is available. It consists of 2 layers:
200*61c4878aSAndroid Build Coastguard Worker1. Declarations
201*61c4878aSAndroid Build Coastguard Worker2. Definitions
202*61c4878aSAndroid Build Coastguard Worker
203*61c4878aSAndroid Build Coastguard WorkerThe declaration YAML
204*61c4878aSAndroid Build Coastguard Worker====================
205*61c4878aSAndroid Build Coastguard WorkerThe declaration YAML files allow projects to define new sensor channels and
206*61c4878aSAndroid Build Coastguard Workerattributes for their drivers. This allows proprietary functionality of sensors
207*61c4878aSAndroid Build Coastguard Workerwhich cannot be made public. Pigweed will provide some baseline set of channels
208*61c4878aSAndroid Build Coastguard Workerand attributes.
209*61c4878aSAndroid Build Coastguard Worker
210*61c4878aSAndroid Build Coastguard WorkerThe following YAML file is used to create a sensor which counts cakes. The
211*61c4878aSAndroid Build Coastguard Workersensor provides the ability to get the total cake count or a separate
212*61c4878aSAndroid Build Coastguard Workerlarge/small cake count (for a total of 3 channels):
213*61c4878aSAndroid Build Coastguard Worker
214*61c4878aSAndroid Build Coastguard Worker.. code-block:: yaml
215*61c4878aSAndroid Build Coastguard Worker
216*61c4878aSAndroid Build Coastguard Worker   # File: my/org/sensors/cakes.yaml
217*61c4878aSAndroid Build Coastguard Worker   units:
218*61c4878aSAndroid Build Coastguard Worker      cake:
219*61c4878aSAndroid Build Coastguard Worker         symbol: "cakes"
220*61c4878aSAndroid Build Coastguard Worker   channels:
221*61c4878aSAndroid Build Coastguard Worker     cakes:
222*61c4878aSAndroid Build Coastguard Worker         description: "The number of cakes seen by the sensor"
223*61c4878aSAndroid Build Coastguard Worker         units: "cake"
224*61c4878aSAndroid Build Coastguard Worker      cakes_small:
225*61c4878aSAndroid Build Coastguard Worker         description: "The number of cakes measuring 6 inches or less"
226*61c4878aSAndroid Build Coastguard Worker         units: "cake"
227*61c4878aSAndroid Build Coastguard Worker      cakes_large:
228*61c4878aSAndroid Build Coastguard Worker         description: "The number of cakes measuring more than 6 inches"
229*61c4878aSAndroid Build Coastguard Worker         units: "cake"
230*61c4878aSAndroid Build Coastguard Worker
231*61c4878aSAndroid Build Coastguard WorkerThe above YAML file will enable a 3 new channels: ``cakes``, ``cakes_small``,
232*61c4878aSAndroid Build Coastguard Workerand ``cakes_large``. All 3 channels will use a unit ``cake``. A sensor
233*61c4878aSAndroid Build Coastguard Workerimplementing this channel would provide a definition file:
234*61c4878aSAndroid Build Coastguard Worker
235*61c4878aSAndroid Build Coastguard Worker.. code-block:: yaml
236*61c4878aSAndroid Build Coastguard Worker
237*61c4878aSAndroid Build Coastguard Worker   # File: my/org/sensors/cake/sensor.yaml
238*61c4878aSAndroid Build Coastguard Worker   deps:
239*61c4878aSAndroid Build Coastguard Worker      - "my/org/sensors/cakes.yaml"
240*61c4878aSAndroid Build Coastguard Worker   compatible:
241*61c4878aSAndroid Build Coastguard Worker      org: "myorg"
242*61c4878aSAndroid Build Coastguard Worker      part: "cakevision"
243*61c4878aSAndroid Build Coastguard Worker   supported-buses:
244*61c4878aSAndroid Build Coastguard Worker      - i2c
245*61c4878aSAndroid Build Coastguard Worker      - spi
246*61c4878aSAndroid Build Coastguard Worker   channels:
247*61c4878aSAndroid Build Coastguard Worker      cakes: []
248*61c4878aSAndroid Build Coastguard Worker      cakes_small: []
249*61c4878aSAndroid Build Coastguard Worker      cakes_large: []
250*61c4878aSAndroid Build Coastguard Worker
251*61c4878aSAndroid Build Coastguard WorkerWhen validated, the above YAML will be converted to fill in the defined values.
252*61c4878aSAndroid Build Coastguard WorkerThis means that ``channels/cakes`` will be automatically filled with:
253*61c4878aSAndroid Build Coastguard Worker
254*61c4878aSAndroid Build Coastguard Worker- ``name: "cakes"``: automatically derived from the name sinde the definition
255*61c4878aSAndroid Build Coastguard Worker  did not provide a name.
256*61c4878aSAndroid Build Coastguard Worker- ``description: "The number of cakes seen by the sensor"``: attained from the
257*61c4878aSAndroid Build Coastguard Worker  definition file.
258*61c4878aSAndroid Build Coastguard Worker- ``units``
259*61c4878aSAndroid Build Coastguard Worker   - ``name: "cake"``: derived from the definition's ``symbol`` since ``name``
260*61c4878aSAndroid Build Coastguard Worker     is not explicitly specified
261*61c4878aSAndroid Build Coastguard Worker   - ``symbol: "cake"``: attained from definition file
262*61c4878aSAndroid Build Coastguard Worker
263*61c4878aSAndroid Build Coastguard WorkerOutput
264*61c4878aSAndroid Build Coastguard Worker======
265*61c4878aSAndroid Build Coastguard WorkerThe resulting output uses references. At times described above, things such as
266*61c4878aSAndroid Build Coastguard Worker``units`` will be referenced from inside a sensor's channel. When validated, the
267*61c4878aSAndroid Build Coastguard Workercorresponding ``units`` entry is guaranteed to be found at the top level
268*61c4878aSAndroid Build Coastguard Worker``units`` map. Currently, there will be 5 keys in the returned dictionary:
269*61c4878aSAndroid Build Coastguard Worker``sensors``, ``channels``, ``attributes``, ``units``, and ``triggers``.
270*61c4878aSAndroid Build Coastguard Worker
271*61c4878aSAndroid Build Coastguard WorkerThe ``sensors`` key is a dictionary mapping unique identifiers generated from
272*61c4878aSAndroid Build Coastguard Workerthe sensor's compatible string to the resolved values. There will always be
273*61c4878aSAndroid Build Coastguard Workerexactly 1 of these since each sensor spec is required to only describe a single
274*61c4878aSAndroid Build Coastguard Workersensor (we'll see an example soon for how these are merged to create a project
275*61c4878aSAndroid Build Coastguard Workerlevel sensor description). Each ``sensor`` will contain: ``name`` string,
276*61c4878aSAndroid Build Coastguard Worker``description`` description struct, ``compatible`` struct, ``channels``
277*61c4878aSAndroid Build Coastguard Workerdictionary, ``attributes`` list, and ``triggers`` list.
278*61c4878aSAndroid Build Coastguard Worker
279*61c4878aSAndroid Build Coastguard WorkerThe difference between the ``/sensors/channels`` and ``/channels`` dictionaries
280*61c4878aSAndroid Build Coastguard Workeris that the former can be thought of as instantiating the latter.
281*61c4878aSAndroid Build Coastguard Worker
282*61c4878aSAndroid Build Coastguard Worker------------------------
283*61c4878aSAndroid Build Coastguard WorkerSensor descriptor script
284*61c4878aSAndroid Build Coastguard Worker------------------------
285*61c4878aSAndroid Build Coastguard WorkerA descriptor script is added to Pigweed via the ``pw sensor-desc`` subcommand.
286*61c4878aSAndroid Build Coastguard WorkerThis command allows validating multiple sensor descriptors and passing the
287*61c4878aSAndroid Build Coastguard Workerunified descriptor to a generator.
288*61c4878aSAndroid Build Coastguard Worker
289*61c4878aSAndroid Build Coastguard Worker.. list-table:: CLI Flags
290*61c4878aSAndroid Build Coastguard Worker   :header-rows: 1
291*61c4878aSAndroid Build Coastguard Worker
292*61c4878aSAndroid Build Coastguard Worker   * - Flag(s)
293*61c4878aSAndroid Build Coastguard Worker     - Description
294*61c4878aSAndroid Build Coastguard Worker   * - ``--include-path``, ``-I``
295*61c4878aSAndroid Build Coastguard Worker     - Directories in which to search for dependency files.
296*61c4878aSAndroid Build Coastguard Worker   * - ``--verbose``, ``-v``
297*61c4878aSAndroid Build Coastguard Worker     - Increase the verbosity level (can be used multiple times). Default
298*61c4878aSAndroid Build Coastguard Worker       verbosity is WARNING, so additional flags increase it to INFO then DEBUG.
299*61c4878aSAndroid Build Coastguard Worker   * - ``--generator``, ``-g``
300*61c4878aSAndroid Build Coastguard Worker     - Generator ommand to run along with any flags. Data will be passed into
301*61c4878aSAndroid Build Coastguard Worker       the generator as YAML through stdin.
302*61c4878aSAndroid Build Coastguard Worker   * - ``-o``
303*61c4878aSAndroid Build Coastguard Worker     - Write output to file instead of stdout.
304*61c4878aSAndroid Build Coastguard Worker
305*61c4878aSAndroid Build Coastguard WorkerWhat are the include paths used for?
306*61c4878aSAndroid Build Coastguard Worker====================================
307*61c4878aSAndroid Build Coastguard WorkerThe sensor descriptor includes a ``deps`` list with file names which define
308*61c4878aSAndroid Build Coastguard Workervarious attributes used by the sensor. We wouldn't want to check in absolute
309*61c4878aSAndroid Build Coastguard Workerpaths in these lists, so instead, it's possible to list a relative path to the
310*61c4878aSAndroid Build Coastguard Workerroot of the project, then add include paths to the tool which will help resolve
311*61c4878aSAndroid Build Coastguard Workerthe dependencies. This should look familiar to header file resolution in C/C++.
312*61c4878aSAndroid Build Coastguard Worker
313*61c4878aSAndroid Build Coastguard WorkerWhat is a generator?
314*61c4878aSAndroid Build Coastguard Worker====================
315*61c4878aSAndroid Build Coastguard WorkerThe sensor descriptor script validates each sensor descriptor file then creates
316*61c4878aSAndroid Build Coastguard Workera superset of all sensors and channels (making sure there aren't conflicts).
317*61c4878aSAndroid Build Coastguard WorkerOnce complete, it will call the generator (if available) and pass the string
318*61c4878aSAndroid Build Coastguard WorkerYAML representation of the superset into the generator via stdin. Some ideas for
319*61c4878aSAndroid Build Coastguard Workergenerators:
320*61c4878aSAndroid Build Coastguard Worker
321*61c4878aSAndroid Build Coastguard Worker- Create a header with a list of all channels, assigning each channel a unique
322*61c4878aSAndroid Build Coastguard Worker  ID.
323*61c4878aSAndroid Build Coastguard Worker- Generate RST file with documentation on each supported sensor.
324*61c4878aSAndroid Build Coastguard Worker- Generate stub driver implementation by knowing which channels and attributes
325*61c4878aSAndroid Build Coastguard Worker  are supported.
326*61c4878aSAndroid Build Coastguard Worker
327*61c4878aSAndroid Build Coastguard WorkerExample run (prints to stdout):
328*61c4878aSAndroid Build Coastguard Worker
329*61c4878aSAndroid Build Coastguard Worker.. code-block:: bash
330*61c4878aSAndroid Build Coastguard Worker
331*61c4878aSAndroid Build Coastguard Worker   $ pw --no-banner sensor-desc -I pw_sensor/ \
332*61c4878aSAndroid Build Coastguard Worker     -g "python3 pw_sensor/py/pw_sensor/constants_generator.py --package pw.sensor" \
333*61c4878aSAndroid Build Coastguard Worker     pw_sensor/sensor.yaml
334*61c4878aSAndroid Build Coastguard Worker
335*61c4878aSAndroid Build Coastguard Worker.. _Understanding the compatible Property: https://elinux.org/Device_Tree_Usage#Understanding_the_compatible_Property
336*61c4878aSAndroid Build Coastguard Worker.. _metadata_schema.json: https://cs.opensource.google/pigweed/pigweed/+/main:pw_sensor/py/pw_sensor/metadata_schema.json
337*61c4878aSAndroid Build Coastguard Worker.. _resolved_schema.json: https://cs.opensource.google/pigweed/pigweed/+/main:pw_sensor/py/pw_sensor/resolved_schema.json
338