# 工具

支持使用以下工具进行功能测试和搭建编译环境。

## 传感器功能测试工具

传感器信息测试、驱动程序验收测试和 sensor workhorse 测试旨在促进对传感器功能的全面测试。

- 传感器信息测试提供有关传感器的详细信息。
- 驱动程序验收测试可确保传感器驱动程序正常运行并与 QSH 兼容。
- Sensor workhorse 是在多种条件下对传感器进行压力测试的工具。

测试工具可确保应用中基于硬件和软件的传感器的准确性、可靠性和最佳性能。以下部分提供有关测试工具的信息。

### 传感器信息测试 (ssc\_sensor\_info)

#### 传感器信息测试定义

传感器信息测试 `ssc_sensor_info` 是 QSH 测试套件中的一个应用程序。其中列出了 QSH 支持的传感器及其属性。您可以查询给定数据类型的属性。

ssc_sensor_info [-sensor=<sensor_type>] [-delay=<time_in_seconds>][-duration=<time_in_seconds>][-default_only=<1|0>][-log=<1|0>][-help]
    Copy to clipboard

表：ssc_sensor_info 的参数

| **标志** | **类型** | **值** | **单位** | 备注 |
| --- | --- | --- | --- | --- |
| Sensor | `string` | 任何有效的传感器类型，例如 *accel* 和 *gyro*。 | 不适用 | 为指定的传感器类型查询属性信息。 |
| Log | `int` | 0 | 1 | – | 启用或禁用诊断 (API) 日志。 |
| help(h) | `int` | – | – | 显示命令用法帮助。 |
| Duration | `int` | 正值 | s | 指定传感器属性更新的等待时间。 |
| Delay | `int` | 正值 | s | 指定发送传感器请求之前的时间延迟。 |
| default\_only | `int` | 0 | 1 | – | 如果 `default_only` 标志设置为 false，则发送支持指定数据类型的所有可用传感器的 UID。如果 `default_only` 标志设置为 true，则仅发送默认传感器可用性的 UID。 |

**传感器信息测试示例**

- 查询传感器属性并生成诊断日志。

ssc_sensor_info
        Copy to clipboard

root@qcm6490:~# ssc_sensor_info
        ssc_sensor_info v1.86
        
        SUID           = 0xebd5604d09d379bca54dcf30ec041e0f
        NAME           = ak0991x
        VENDOR         = akm
        TYPE           = mag
        AVAILABLE      = true
        VERSION        = 2.62.47
        API            = sns_mag.proto
        RATES          = [1.000000, 10.000000, 20.000000, 50.000000, 100.000000]
        RESOLUTIONS    = 0.150000
        RANGES         = [-4912.000000,4912.000000]
        DRI            = false
        FIFO_SIZE      = 0
        STREAM_TYPE    = streaming
        STREAM_SYNC    = false
        DYNAMIC        = false
        EVENT_SIZE     = 16
        OP_MODES       = [LOW_POWER, LOW_NOISE]
        ACTIVE_CURRENT = 900
        SLEEP_CURRENT  = 3
        HW_ID          = 0
        RIGID_BODY     = display
        PHYSICAL_SENSOR       = true
        PHYSICAL_SENSOR_TESTS = [3, 1]
        SELECTED_RESOLUTION   = 0.150000
        SELECTED_RANGE        = [-4912.000000,4912.000000]
        
        SUID           = 0xaddeaddeaddeaddeaddeaddeaddeadde
        NAME           = da_test
        VENDOR         = QTI
        TYPE           = da_test
        AVAILABLE      = true
        VERSION        = 0.51.0
        API            = sns_da_test.proto
        STREAM_TYPE    = on_change
        
        SUID           = 0x69def905fea2fbac6a43ca273221a2eb
        NAME           = aont
        VENDOR         = QTI
        TYPE           = aont
        AVAILABLE      = true
        VERSION        = 0.0.1
        API            = sns_aont.proto
        STREAM_TYPE    = on_change
        
        SUID           = 0xabababababababababababababababab
        NAME           = suid
        VENDOR         = QTI
        TYPE           = suid
        AVAILABLE      = true
        VERSION        = 0.0.1
        API            = sns_suid.proto
        STREAM_TYPE    = single_output
        
        SUID           = 0xe12754a7007f27595e2541b4701e2275
        NAME           = registry
        VENDOR         = QTI
        TYPE           = registry
        AVAILABLE      = true
        VERSION        = 0.0.1
        API            = sns_registry.proto
        STREAM_TYPE    = single_output
        
        SUID           = 0xadfeadfeadfeadfeadfeadfeadfeadfe
        NAME           = da_test_big_image
        VENDOR         = QTI
        TYPE           = da_test
        AVAILABLE      = true
        VERSION        = 0.49.0
        API            = sns_da_test.proto
        STREAM_TYPE    = on_change
        
        SUID           = 0x61ab5376b4a5c9aa58442ede47acd316
        NAME           = icm4x6xx
        VENDOR         = TDK-Invensense
        TYPE           = accel
        AVAILABLE      = true
        VERSION        = 1.65.2
        API            = sns_accel.proto
        RATES          = [12.500000, 25.000000, 50.000000, 100.000000, 200.000000, 500.000000]
        RESOLUTIONS    = [0.000019, 0.000037, 0.000075, 0.000150, 0.000299]
        RANGES         = [[-9.806650,9.806650], [-19.613300,19.613300], [-39.226601,39.226601], [-78.453201,78.453201], [-156.906403,156.906403]]
        DRI            = true
        FIFO_SIZE      = 200
        STREAM_TYPE    = streaming
        STREAM_SYNC    = false
        DYNAMIC        = false
        EVENT_SIZE     = 16
        OP_MODES       = [LPM, NORMAL, HIGH_PERF]
        ACTIVE_CURRENT = [50, 240, 240]
        SLEEP_CURRENT  = 6
        HW_ID          = 0
        RIGID_BODY     = display
        PHYSICAL_SENSOR       = true
        PHYSICAL_SENSOR_TESTS = [3, 2, 1]
        SELECTED_RESOLUTION   = 0.000299
        SELECTED_RANGE        = [-156.906403,156.906403]
        LOW_LATENCY_RATES     = 1000.000000
        PASSIVE_REQUEST       = true
        Copy to clipboard
- 查询所有 *accel* 传感器属性

ssc_sensor_info -sensor=accel
        Copy to clipboard

root@qcm6490:~# ssc_sensor_info -sensor=accel
        ssc_sensor_info v1.86
        
        SUID           = 0x61ab5376b4a5c9aa58442ede47acd316
        NAME           = icm4x6xx
        VENDOR         = TDK-Invensense
        TYPE           = accel
        AVAILABLE      = true
        VERSION        = 1.65.2
        API            = sns_accel.proto
        RATES          = [12.500000, 25.000000, 50.000000, 100.000000, 200.000000, 500.000000]
        RESOLUTIONS    = [0.000019, 0.000037, 0.000075, 0.000150, 0.000299]
        RANGES         = [[-9.806650,9.806650], [-19.613300,19.613300], [-39.226601,39.226601], [-78.453201,78.453201], [-156.906403,156.906403]]
        DRI            = true
        FIFO_SIZE      = 80
        STREAM_TYPE    = streaming
        STREAM_SYNC    = false
        DYNAMIC        = false
        EVENT_SIZE     = 16
        OP_MODES       = [LPM, NORMAL, HIGH_PERF]
        ACTIVE_CURRENT = [50, 240, 240]
        SLEEP_CURRENT  = 6
        HW_ID          = 0
        RIGID_BODY     = display
        PHYSICAL_SENSOR       = true
        PHYSICAL_SENSOR_TESTS = [3, 2, 1]
        SELECTED_RESOLUTION   = 0.000299
        SELECTED_RANGE        = [-156.906403,156.906403]
        LOW_LATENCY_RATES     = [1000.000000, 2000.000000]
        PASSIVE_REQUEST       = true
        Copy to clipboard

**测试程序输出**

测试程序生成以下输出：

- 控制台上的标准输出
- 结果文件

### 驱动程序验收测试 (ssc\_drva\_test)

#### 驱动程序验收测试定义

驱动程序验收测试工具 `ssc_drva_test`，用于传感器驱动程序验证，并在 QSH 传感器 API 层运行。它执行一系列传感器用例。该工具直接从命令行接受参数，无需编译时选项。这种方法使该工具成为执行基本驱动程序级测试或验证的便捷而有效的工具。

ssc_drva_test [-sensor=<sensor_type>] [-duration=<time_in_seconds>] [-sample_rate=<value_in_Hz>] [-batch_period=<value_in_seconds>] [-iterations=<value>] [-num_samples=<value>] [-factory_test=<value>]
    Copy to clipboard

表：ssc_drva_test 参数

| **标志** | **类型** | **值** | **单位** | **备注** |
| --- | --- | --- | --- | --- |
| `sensor` | `string` | <ul class="simple"><br><li><p><code class="docutils literal notranslate"><span class="pre">accel</span></code></p></li><br><li><p><code class="docutils literal notranslate"><span class="pre">gyro</span></code></p></li><br><li><p><code class="docutils literal notranslate"><span class="pre">sensor_temperature</span></code></p></li><br><li><p><code class="docutils literal notranslate"><span class="pre">pressure</span></code></p></li><br><li><p><code class="docutils literal notranslate"><span class="pre">mag</span></code></p></li><br><li><p><code class="docutils literal notranslate"><span class="pre">humidity</span></code></p></li><br><li><p><code class="docutils literal notranslate"><span class="pre">ambient_temperature</span></code></p></li><br><li><p><code class="docutils literal notranslate"><span class="pre">ultra_violet</span></code></p></li><br><li><p><code class="docutils literal notranslate"><span class="pre">proximity</span></code></p></li><br><li><p><code class="docutils literal notranslate"><span class="pre">ambient_light</span></code></p></li><br><li><p><code class="docutils literal notranslate"><span class="pre">rgb</span></code></p></li><br><li><p><code class="docutils literal notranslate"><span class="pre">hall</span></code></p></li><br><li><p>添加的任何自定义传感器</p></li><br></ul> | – | 强制参数：仅限于可用的传感器类型。 |
| `duration` | `float` | 仅限正值 | S | 强制参数：传感器测试持续时间（以 s 为单位）。 |
| `sample_rate` | `float` | 正浮点数值：<br><br><br><br>> <br>> <br>> <ul class="simple"><br>> <li><p>-1：最大采样率</p></li><br>> <li><p>-2：最小采样率</p></li><br>> </ul> | Hz | 对于流传感器是强制性的，对于变化传感器则是可选的。 |
| `batch_period` | `float` | 正浮点数 | S | 该周期与报告周期相同，指示在低功耗处理器外部缓冲示例和报告的时间。 |
| `iterations` | `int` | 仅限正值 | 不适用 | 提供必须重复测试的次数。 |
| `num_samples` | `int` | 仅限正值 | 不适用 | 指示要收集的最小示例数。如果已指定 `num_samples` 参数，并且测试在测试期间未收集到足够的示例，则测试传感器将生成 FAIL。<br><br><br>`num_samples` 参数强制测试运行一段时间，此时间的最大值为指定的持续时间或由以下公式计算的值：<br><ul class="simple"><br><li><p><code class="docutils literal notranslate"><span class="pre">num_samples*</span></code> 预期采样率，其中的预期采样率是传感器的预期工作速率。</p></li><br></ul> |
| `factory_test` | `int` | <ul class="simple"><br><li><p><code class="docutils literal notranslate"><span class="pre">0</span> <span class="pre">(SNS_PHYSICAL_SENSOR_TEST_TYPE_SW)</span></code></p></li><br><li><p><code class="docutils literal notranslate"><span class="pre">1</span> <span class="pre">(SNS_PHYSICAL_SENSOR_TEST_TYPE_HW)</span></code></p></li><br><li><p><code class="docutils literal notranslate"><span class="pre">2</span> <span class="pre">(SNS_PHYSICAL_SENSOR_TEST_TYPE_FACTORY)</span></code></p></li><br><li><p><code class="docutils literal notranslate"><span class="pre">3</span> <span class="pre">(SNS_PHYSICAL_SENSOR_TEST_TYPE_COM)</span></code></p></li><br></ul> | 不适用 | 选择要运行的工厂测试类型（从值列中选择）。 |

**驱动程序验收测试示例**

- 在已知持续时间内以选定的采样频率对单个传感器进行数据流动：

ssc_drva_test -sensor=accel -duration=5 -sample_rate=500
        Copy to clipboard

root@qcm6490:~# ssc_drva_test -sensor=accel -duration=5 -sample_rate=500
        6 ssc_drva_test version 1.27k
        6 ssc_drva_test -sensor=accel -duration=5 -sample_rate=500
        diag: Diag_LSM_Init: invoked for pid: 1141 with init_count: 0
        diag:successfully connected to socket 3
        diag: Diag_LSM_Init: done for pid: 1141 with init_count: 1
        6 event_cb attribute event for da_test
        6 event_cb attribute event for da_test
        6 using da_test name=da_test, suid = [high addeaddeaddeadde, low addeaddeaddeadde
        6 enter send_memory_log_req cookie: 6
        6 exit send_memory_log_req
        6 enter da_test runner. -rumifact=1
        6 -time_to_first_event=233206
        6 -time_to_last_event=-20008
        6 -sample_ts=50267544823
        6 -total_samples=2528
        6 -avg_delta=37875
        6 -recvd_phy_config_sample_rate=500
        6 -random_seed_used=2926886043
        6 -num_request_sent=2
        6 -first_sample_timestamp=50171775915
        6 received event: PASS
        6 enter send_memory_log_req cookie: 6
        6 exit send_memory_log_req
        6 PASS
        Copy to clipboard
- 在已知持续时间内以选定的采样频率和报告周期批处理单个传感器：

ssc_drva_test -sensor=accel -duration=30.0 -sample_rate=100 -batch_period=2.0
        Copy to clipboard

root@qcm6490:~# ssc_drva_test -sensor=accel -duration=30.0 -sample_rate=100 -batch_period=2.0
        3 ssc_drva_test version 1.27k
        3 ssc_drva_test -sensor=accel -duration=30.0 -sample_rate=100 -batch_period=2.0
        diag: Diag_LSM_Init: invoked for pid: 1413 with init_count: 0
        diag:successfully connected to socket 3
        diag: Diag_LSM_Init: done for pid: 1413 with init_count: 1
        3 event_cb attribute event for da_test
        3 event_cb attribute event for da_test
        3 using da_test name=da_test, suid = [high addeaddeaddeadde, low addeaddeaddeadde
        3 enter send_memory_log_req cookie: 3
        3 exit send_memory_log_req
        3 enter da_test runner. -rumifact=1
        3 -time_to_first_event=15321140
        3 -time_to_last_event=-13606286
        3 -sample_ts=8591389823
        3 -total_samples=2960
        3 -avg_delta=184826
        3 -recvd_phy_config_sample_rate=100.000000
        3 -random_seed_used=3720387971
        3 -num_request_sent=2
        3 -first_sample_timestamp=8030694123
        3 received event: PASS
        3 enter send_memory_log_req cookie: 3
        3 exit send_memory_log_req
        3 PASS
        Copy to clipboard
- 加速度计自检（硬件自检）：

ssc_drva_test -sensor=accel -factory_test=1 -duration=10
        Copy to clipboard

root@qcm6490:~# ssc_drva_test -sensor=accel -factory_test=1 -duration=10
        4 ssc_drva_test version 1.27k
        4 ssc_drva_test -sensor=accel -factory_test=1 -duration=10
        diag: Diag_LSM_Init: invoked for pid: 1439 with init_count: 0
        diag:successfully connected to socket 3
        diag: Diag_LSM_Init: done for pid: 1439 with init_count: 1
        4 event_cb attribute event for da_test
        4 event_cb attribute event for da_test
        4 using da_test name=da_test, suid = [high addeaddeaddeadde, low addeaddeaddeadde
        4 enter send_memory_log_req cookie: 4
        4 exit send_memory_log_req
        4 enter da_test runner. -rumifact=1
        4 -time_to_first_event=0
        4 -time_to_last_event=-2032137957
        4 -sample_ts=10622073335
        4 -total_samples=0
        4 -avg_delta=0
        4 -recvd_phy_config_sample_rate=0.000000
        4 -random_seed_used=1840104635
        4 -num_request_sent=2
        4 -first_sample_timestamp=0
        4 received event: PASS
        4 enter send_memory_log_req cookie: 4
        4 exit send_memory_log_req
        4 PASS
        Copy to clipboard

**输出**：

在控制台命令行上，此测试仅输出为 pass 或 fail，仅指示测试执行状态（测试是否完成）。

### Sensor workhorse (see\_workhorse)

#### Sensor workhorse 定义

Sensor workhorse 工具 `see_workhorse`，根据命令行参数操作特定的传感器。它旨在简化各种配置中的传感器测试和数据收集。

see_workhorse [-sensor=<sensor_type>][-sample_rate=<min | max | number>] [-batch_period=<seconds>] [-calibrated=<0 | 1>] [-wakeup=<0 | 1>]
    Copy to clipboard

表：see_workhorse 的参数

| 标志 | 类型 | 取值范围 | 单位 | 备注 |
| --- | --- | --- | --- | --- |
| `sensor` | `string` | <ul class="simple"><br><li><p><code class="docutils literal notranslate"><span class="pre">accel</span></code></p></li><br><li><p><code class="docutils literal notranslate"><span class="pre">gyro</span></code></p></li><br><li><p><code class="docutils literal notranslate"><span class="pre">sensor_temperature</span></code></p></li><br><li><p><code class="docutils literal notranslate"><span class="pre">pressure</span></code></p></li><br><li><p><code class="docutils literal notranslate"><span class="pre">mag</span></code></p></li><br><li><p><code class="docutils literal notranslate"><span class="pre">humidity</span></code></p></li><br><li><p><code class="docutils literal notranslate"><span class="pre">ambient_temperature</span></code></p></li><br><li><p><code class="docutils literal notranslate"><span class="pre">ultra_violet</span></code></p></li><br><li><p><code class="docutils literal notranslate"><span class="pre">proximity</span></code></p></li><br><li><p><code class="docutils literal notranslate"><span class="pre">ambient_light</span></code></p></li><br><li><p><code class="docutils literal notranslate"><span class="pre">rgb</span></code></p></li><br><li><p><code class="docutils literal notranslate"><span class="pre">hall</span></code></p></li><br><li><p>添加的任何自定义传感器</p></li><br></ul> | 不适用 | 强制参数：仅限于可用的传感器类型。 |
| `on_change` | `int` | 0 | 1 | 不适用 | <ul class="simple"><br><li><p>0 使用 <code class="docutils literal notranslate"><span class="pre">SNS_STD_SENSOR_STREAM_TYPE_STREAMING</span></code> 选择。</p></li><br><li><p>1 使用 <code class="docutils literal notranslate"><span class="pre">SNS_STD_SENSOR_STREAM_TYPE_ON_CHANGE</span></code> 选择。</p></li><br></ul> |
| `sample_rate` | `float` | 正浮点数值：<br><ul class="simple"><br><li><p>-1：最大采样率</p></li><br><li><p>-2：最小采样率</p></li><br></ul> | Hz | 对于流传感器是强制性的，对于变化传感器则是可选的。 |
| `batch_period` | `float` | 正浮点数 | s | 与批处理周期或报告周期相同。 |
| `calibrated` | `int` | 0 | 1 | 不适用 | <ul class="simple"><br><li><p>0: nop（默认值）。</p></li><br><li><p>1：如果 <code class="docutils literal notranslate"><span class="pre">sensor_type</span></code> 是 gyro 或 mag，则还分别激活 <code class="docutils literal notranslate"><span class="pre">gyro_cal</span></code> 或 <code class="docutils literal notranslate"><span class="pre">/mag_cal</span></code>。</p></li><br></ul> |
| `wakeup` | `int` | 0 | 1 | 不适用 | <ul class="simple"><br><li><p>0：将 <code class="docutils literal notranslate"><span class="pre">suspend_config</span></code> 唤醒设置为 <code class="docutils literal notranslate"><span class="pre">SEE_CLIENT_DELIVERY_NO_WAKEUP</span></code>。</p></li><br><li><p>1：将 <code class="docutils literal notranslate"><span class="pre">suspend_config</span></code> 唤醒设置为 <code class="docutils literal notranslate"><span class="pre">SEE_CLIENT_DELIVERY_WAKEUP</span></code>（默认）。</p></li><br></ul> |
| `display_events` | `int` | 0 | 1 | 不适用 | 使用事件回调以 JSON 格式显示传感器事件。 |

**Sensor workhorse 示例**

例如，使用以下命令以最大速率对加速度传感器数据进行 30 s 数据流传输：

see_workhorse -sensor=accel -sample_rate=max -duration=30 -display_events=1
    Copy to clipboard

root@qcm6490:~# see_workhorse -sensor=accel -sample_rate=max -duration=30 -display_events=1
    see_workhorse version 2.04
    20:22:15.406 see_workhorse -sensor=accel -sample_rate=max -duration=30 -display_events=1
    begin usta_get_sensor_list
    Copy to clipboard

此命令指示 `see_workhorse` 以最大采样率运行加速度计 `accel`，持续 30 秒。

20:22:15.731 stream_sensor( accel)
    20:22:15.731 + sample_rate: 500.000000 hz
    20:22:15.838 config_stream_sensor() complete rc 0
    20:22:15.838 sleep(30) seconds
    
    "sns_client_event_msg" : {
     "suid" : {
      "suid_low" : "0x58442ede47acd316",
      "suid_high" : "0x61ab5376b4a5c9aa"
     },
     "events" : [
      {
       "msg_id" : 768,
       "timestamp" : 78497742089,
       "payload" : {
        "sample_rate" : 500.000000,
        "water_mark" : 1,
    Copy to clipboard

## 其他工具

以下是用于搭建编译环境和提供功能诊断的工具：

- **Qualcomm® Hexagon™ DSP 工具链**

    Hexagon 8.4.07 工具链
- **QXDM Professional 工具**

    The Qualcomm® eXtensible diagnostic monitor (QXDM) Professional™ 工具是一个诊断客户端。

    - QSH 框架可以直接调用宏和 API 来发送调试信息以打印字符串和日志数据包。
    - QXDM 日志主要用于 aDSP 端调试。有关详细信息，参见 [Qualcomm Linux Sensors Guide - Addendum](https://docs.qualcomm.com/bundle/resource/topics/80-70017-7A/debugging.html) 中的 [Debug](https://docs.qualcomm.com/bundle/resource/topics/80-70017-7A/overview.html)。

Note

[Qualcomm Linux Sensors Guide -  Addendum](https://docs.qualcomm.com/bundle/resource/topics/80-70017-7A/overview.html) 仅可由许可用户访问。
    - QXDM Professional 工具需要 USB 连接。应用处理器可直接连接到 USB 端口，但 aDSP 不能。

Last Published: Jan 23, 2025

[Previous Topic
样品](https://docs.qualcomm.com/bundle/publicresource/80-70017-7SC/topics/samples.md) [Next Topic
校准](https://docs.qualcomm.com/bundle/publicresource/80-70017-7SC/topics/calibrate.md)