The Probe Framework

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.

Functions

AbstractCombinationFunction

While evaluation, the function first evaluates the functions specified in the functions arguments and then combines the outputs in a certain way.

Function Name

Short Description

concat

Returns the concatenation of output.

inner_join

Inner join the result of functions.

or

Returns the first successful output.

sequence

Sequential execute the functions.

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.

Function Name

Short Description

audio_codec

chromeos_firmware

Get firmware information from a flash chip.

detachable_base

Probe the detachable base information.

ec_component

Probe EC Component.

edid

embedded_controller

Get information of EC.

factory_device_data

Reads some fields from the device data.

feature_management_flags

Probes the feature management flags.

file

Read the content of a file.

flash_chip

Get information of flash chips.

generic_battery

generic_bluetooth

Probe the generic Bluetooth information.

generic_camera

generic_cpu

generic_dram

Probe the generic DRAM information.

generic_fingerprint

Probe the fingerprint information.

generic_hps

Probe the HPS (human presence sensor) information.

generic_storage

generic_usb_hosts

Probe the generic USB host information.

glob_path

Finds all the pathnames matching the pattern.

gpu

i2c

Probes the I2C device.

input_device

mmc

Probes all eMMC devices listed in the sysfs /sys/bus/mmc/devices/.

mmc_host

network

nfc_reader

Probes internal USB NFC reader devices.

pci

Probes all PCI devices listed in the sysfs /sys/bus/pci/devices/.

sdio

Probes all SDIO devices listed in the sysfs /sys/bus/sdio/devices/.

shell

Execute the shell command and return the output.

smart_card_usb

Probes all USB smart card reader devices.

sysfs

Read the required files in a directory.

tcpc

tpm

usb

Probes all usb devices listed in the sysfs /sys/bus/usb/devices/.

vpd

Reads the information from VPD.

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.

Function Name

Short Description

approx_match

Return the items which match the most rules.

Misc

Function Name

Short Description

match

Filter the results which does not match the rule.