tree: 41a3e20cf735a22746854774b2d92eec8fa2e376
  1. BUILD.gn
  2. device_resolver.cc
  3. device_resolver.h
  4. main.cc
  5. README.md
src/devices/thermal/bin/temperature-cli/README.md

temperature-cli

temperature-cli is a command-line tool for interacting with temperature, ADC (Analog-to-Digital Converter), and trippoint devices in Fuchsia.

Usage

temperature-cli [device] <command> [args...] [<command2> [args2...] ...]
temperature-cli list
temperature-cli read-all
temperature-cli --help

device can be:

  • An absolute path (e.g., /dev/class/temperature/000 or /svc/fuchsia.hardware.temperature.Service/default)
  • A friendly name (e.g., soc-thermal)
  • A service instance name/hash (e.g., a2471f28e36fbe951476bce7910aa396)

If device is omitted, the tool will attempt to resolve it automatically:

  • If only one compatible device is found, it will be used.
  • If multiple compatible devices are found, you will be prompted to select one.
  • For ADC commands, it will scan for ADC devices. For other commands, it will scan for temperature devices.

Command Chaining

Multiple commands can be chained together sequentially (e.g., trippoint ... wait). Commands targeting the same device protocol share the same persistent connection. This is particularly useful for oneshot trippoints to guarantee they trigger and get handled without a connection drop reset:

$ temperature-cli LITTLE trippoint 0:above,35 wait

Note that only one device can be targeted with each temperature-cli invocation.

Commands & Examples

General Commands

  • help (also -h, --help): Show the usage help message.
    $ temperature-cli --help
    Usage: temperature-cli [device_path_or_name] <command> [args...]
           temperature-cli list
           temperature-cli --help
    ...
    
  • list: List all temperature device paths and their friendly names.
    $ temperature-cli list
    Found 2 temperature devices:
      soc-thermal          (/svc/fuchsia.hardware.temperature.Service/default)
      pmic-thermal         (/dev/class/temperature/001)
    
  • read-all: List all temperature devices found and read their temperatures.
    $ temperature-cli read-all
    Found 2 temperature devices:
      soc-thermal          (/svc/fuchsia.hardware.temperature.Service/default)
      pmic-thermal         (/dev/class/temperature/001)
    
    Reading soc-thermal ...
    temperature = 42.500000
    Reading pmic-thermal ...
    temperature = 38.200000
    

Temperature Device Commands

These commands operate on fuchsia.hardware.temperature devices. You can refer to them by their absolute path or their friendly name (as shown in list).

  • read: Read the current temperature in Celsius.
    • By friendly name:
      $ temperature-cli soc-thermal read
      temperature = 42.500000
      
    • By absolute path:
      $ temperature-cli /dev/class/temperature/000 read
      temperature = 42.500000
      
    • With interactive selection (if no device is specified and multiple exist):
      $ temperature-cli read
      Multiple temperature devices found:
        1. soc-thermal (/svc/fuchsia.hardware.temperature.Service/default)
        2. pmic-thermal (/dev/class/temperature/001)
      Select a device (1-2): 1
      Using temperature device: soc-thermal (/svc/fuchsia.hardware.temperature.Service/default/device)
      temperature = 42.500000
      
  • name: Get the sensor's friendly name.
    $ temperature-cli /svc/fuchsia.hardware.temperature.Service/default name
    Sensor Name = soc-thermal
    

ADC Device Commands

These commands operate on fuchsia.hardware.adc devices.

  • resolution: Get the ADC resolution.
    $ temperature-cli /dev/class/adc/000 resolution
    adc resolution  = 12
    
  • read: Read a raw ADC sample.
    $ temperature-cli /dev/class/adc/000 read
    Value = 2048
    
  • read-norm: Read a normalized ADC sample (range 0.0 to 1.0).
    $ temperature-cli /dev/class/adc/000 read-norm
    Value  = 0.500000
    

Trippoint Device Commands

These commands operate on fuchsia.hardware.trippoint devices.

  • trippoint: Get or set trippoints.
    • Get Trippoints:
      $ temperature-cli /svc/fuchsia.hardware.trippoint.Service/default/trippoint trippoint
      {
         .index = 0,
         .type = OneshotTempAbove,
         .configuration = OneshotTempAboveTripPoint(85.000000),
      },
      {
         .index = 1,
         .type = OneshotTempBelow,
         .configuration = ClearedTripPoint,
      },
      
    • Set Trippoints (format: index:type,configuration):
      $ temperature-cli /svc/fuchsia.hardware.trippoint.Service/default/trippoint trippoint 0:above,90.0 1:below,cleared
      Setting trippoints:
      {
         .index = 0,
         .type = OneshotTempAbove,
         .configuration = OneshotTempAboveTripPoint(90.000000),
      },
      {
         .index = 1,
         .type = OneshotTempBelow,
         .configuration = ClearedTripPoint,
      },
      
  • wait: Wait for any trippoint to be triggered.
    $ temperature-cli /svc/fuchsia.hardware.trippoint.Service/default/trippoint wait
    # (blocks until triggered)
    TripPoint indexed 0 was tripped. Measured temperature was 90.500000 C
    
  • trigger (Debug): Manually trigger a trippoint (requires Debug service).
    $ temperature-cli /svc/fuchsia.hardware.trippoint.DebugService/default/debug trigger 1