The Probe Framework =================== .. Include a hidden toctree so Sphinx won't complain about missing documents. We'll generate all the links ourselves in the table below. .. toctree:: :hidden: :glob: functions/* Overview -------- The Probe Framework focuses on supplying different ways to scan the device so that the user can easily figure out whether a specific hardware component is installed. The overall introduction is in this README_. This document describes all functions available throughout the Probe Framework. .. _README: https://chromium.googlesource.com/chromiumos/platform/factory/+/HEAD/py/probe/README.md Functions --------- .. _AbstractCombinationFunction: AbstractCombinationFunction ``````````````````````````` While evaluation, the function first evaluates the functions specified in the ``functions`` arguments and then combines the outputs in a certain way. .. list-table:: :header-rows: 1 :align: left * - Function Name - Short Description * - :doc:`concat ` - Returns the concatenation of output. * - :doc:`inner_join ` - Inner join the result of functions. * - :doc:`or ` - Returns the first successful output. * - :doc:`sequence ` - Sequential execute the functions. .. _AbstractProbeFunction: AbstractProbeFunction ````````````````````` While evaluation, the function probes the result, and update to the input data by the probed results. If there are multiple probed results, the output list contains all the combination of the input and the probed data. .. list-table:: :header-rows: 1 :align: left * - Function Name - Short Description * - :doc:`audio_codec ` - * - :doc:`chromeos_firmware ` - Get firmware information from a flash chip. * - :doc:`detachable_base ` - Probe the detachable base information. * - :doc:`ec_component ` - Probe EC Component. * - :doc:`edid ` - * - :doc:`embedded_controller ` - Get information of EC. * - :doc:`factory_device_data ` - Reads some fields from the device data. * - :doc:`feature_management_flags ` - Probes the feature management flags. * - :doc:`file ` - Read the content of a file. * - :doc:`flash_chip ` - Get information of flash chips. * - :doc:`generic_battery ` - * - :doc:`generic_bluetooth ` - Probe the generic Bluetooth information. * - :doc:`generic_camera ` - * - :doc:`generic_cpu ` - * - :doc:`generic_dram ` - Probe the generic DRAM information. * - :doc:`generic_fingerprint ` - Probe the fingerprint information. * - :doc:`generic_hps ` - Probe the HPS (human presence sensor) information. * - :doc:`generic_storage ` - * - :doc:`generic_usb_hosts ` - Probe the generic USB host information. * - :doc:`glob_path ` - Finds all the pathnames matching the pattern. * - :doc:`gpu ` - * - :doc:`i2c ` - Probes the I2C device. * - :doc:`input_device ` - * - :doc:`mmc ` - Probes all eMMC devices listed in the sysfs ``/sys/bus/mmc/devices/``. * - :doc:`mmc_host ` - * - :doc:`network ` - * - :doc:`nfc_reader ` - Probes internal USB NFC reader devices. * - :doc:`pci ` - Probes all PCI devices listed in the sysfs ``/sys/bus/pci/devices/``. * - :doc:`sdio ` - Probes all SDIO devices listed in the sysfs ``/sys/bus/sdio/devices/``. * - :doc:`shell ` - Execute the shell command and return the output. * - :doc:`smart_card_usb ` - Probes all USB smart card reader devices. * - :doc:`sysfs ` - Read the required files in a directory. * - :doc:`tcpc ` - * - :doc:`tpm ` - * - :doc:`usb ` - Probes all usb devices listed in the sysfs ``/sys/bus/usb/devices/``. * - :doc:`vpd ` - Reads the information from VPD. .. _MatchFunction: MatchFunction ````````````` Description ----------- The rule might be a dict or a string. A result is matched if every value of the rule is matched. If the rule is a string, then the matched result should only contain one item and the value is matched to the string. If the string starts with ``!re``, then the remaining string is treated as a regular expression. If the string starts with ``!num``, the probed value will be treated as floating point number, and the remaining of rule string should be ``< '==' | '>' | '<' | '>=' | '<=' | '!=' > ' ' NUMBER``, e.g. ``!num >= 10``. Otherwise, the value of the result should be the same. Examples -------- This function is used by the probe framework itself to filter the outputs of the evaluated functions by ``expect`` field in the probe statement. Below is a probe statement which simply asks the probe framework to output all usb devices:: { "eval": "usb" } Let's assume the probed output is:: [ { "idVendor": "01ab", "idProduct": "1122", ... }, { "idVendor": "01ac", "idProduct": "3344", ... }, { "idVendor": "23cd", "idProduct": "3344", ... } ] If we modify the probe statement to:: { "eval": "usb", "expect": { "idVendor": "01ab" } } , then the probed results will become:: [ { "idVendor": "01ab", "idProduct": "1122", ... } ] We can also use the regular expression described in above. For example, if we modify ``expect`` field in the probe statement to:: "expect": { "idVendor": "!re ^01.*$" } , then the probed results will contain both the item with ``idVendor=01ab`` and the item with ``idVendor=01ac``. .. list-table:: :header-rows: 1 :align: left * - Function Name - Short Description * - :doc:`approx_match ` - Return the items which match the most rules. .. _Misc: Misc ```` .. list-table:: :header-rows: 1 :align: left * - Function Name - Short Description * - :doc:`match ` - Filter the results which does not match the rule.