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

CombinationFunction

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.

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.

ProbeFunction

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

camera_cros

Execute cros-camera-tool to list all MIPI camers.

chromeos_firmware

Get firmware information from a flash chip.

detachable_base

Probe the detachable base information.

edid

Probe EDID information from file or I2C bus.

file

Read the content of a file.

flash_chip

Get information of flash chips.

generic_audio_codec

Probe the generic audio codec information.

generic_battery

generic_bluetooth

Probe the generic Bluetooth information.

generic_cpu

Probe the generic CPU information.

generic_dram

Probe the generic DRAM information.

generic_network_device

Probes the information of network devices.

generic_storage

Probe the generic storage information.

generic_tpm

Probe the generic TPM information.

generic_usb_hosts

Probe the generic USB host information.

generic_video

Probe the generic video information.

glob_path

Finds all the pathnames matching the pattern.

i2c

Probes the I2C device.

input_device

Probes the information of input devices.

mmc

Probes all eMMC devices listed in the sysfs /sys/bus/mmc/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.

sysfs

Read the required files in a directory.

touchscreen_i2c

Probe the generic I2C (i.e. not HID over I2C) touchscreen information.

usb

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

vpd

Reads the information from VPD.

Misc

Function Name

Short Description

match

Filter the results which does not match the rule.