

AWS 自 2026 年 4 月 30 日起，物联网 FleetWise 将不再向新客户开放。现有的 AWS 物联网 FleetWise 客户可以继续使用该服务。[上的《互联移动指南》 AWS提供了有关如何为](https://aws.amazon.com/solutions/guidance/connected-mobility-on-aws/)互联移动解决方案开发和部署模块化服务的指导，这些解决方案可用于实现与 AWS 物联网同等的功能 FleetWise。

本文属于机器翻译版本。若本译文内容与英语原文存在差异，则一律以英文原文为准。

# 诊断故障代码用例
<a name="dtc-use-cases"></a>

**重要**  
目前对某些 AWS 物联网 FleetWise 功能的访问受到限制。有关更多信息，请参阅 [AWS AWS 物联网中的区域和功能可用性 FleetWise](fleetwise-regions.md)。

以下用例假设该`DTC_QUERY`函数是在[演示脚本](https://github.com/aws/aws-iot-fleetwise-edge/blob/main/docs/dev-guide/edge-agent-uds-dtc-dev-guide.md)中定义的。

## 定期获取
<a name="dtc-periodic-fetch"></a>

按配置的时间间隔获取 DTC 集合。

以下示例是一个为所有人定期获取信号的`Vehicle.DTC_INFO`广告系列，所有人 DTCs 都有状态掩码。 ECUs收集数据是有条件的`Vehicle.DTC_INFO`。

```
{
  "compression": "SNAPPY",
  "spoolingMode": "TO_DISK",
  "signalsToFetch": [
    {
      "fullyQualifiedName": "Vehicle.ECU1.DTC_INFO",
      "signalFetchConfig": {
        "timeBased": {
        // The FleetWise Edge Agent will query the UDS module for all DTCs every five seconds.
          "executionFrequencyMs": 5000
        }
      },
      "actions": [
      // Every five seconds, this action is called and its output is stored in the
      // signal history buffer of Vehicle.DTC_INFO
        "custom_function(\"DTC_QUERY\", -1, 2, -1)"
      ]
    }
  ],
  "signalsToCollect": [
    {
      "name": "Vehicle.ECU1.DTC_INFO"
    }
  ],
  "collectionScheme": {
    "conditionBasedCollectionScheme": {
      "conditionLanguageVersion": 1,
      // Whenever a new DTC is filled into the signal, the data is ingested.
      "expression": "!isNull($variable.`Vehicle.ECU1.DTC_INFO`)",
      "minimumTriggerIntervalMs": 1000,
      // Make sure that data is ingested only when there are new DTCs.
      "triggerMode": "RISING_EDGE"
    }
  },
  "dataDestinationConfigs": [
    {
      "s3Config": 
        {
          "bucketArn": "bucket-arn",
          "dataFormat": "PARQUET",
          "prefix": "campaign-name",
          "storageCompressionFormat": "GZIP"
        }
    }
  ]
}
```

## 条件驱动的获取
<a name="dtc-condition-fetch"></a>

满足条件时获取 DTC 集合。例如，当 CAN 信号为时`Vehicle.Ignition == 1`，获取并上传 DTC 数据。

以下示例广告系列具有条件驱动的信号提取，`Vehicle.ECU1.DTC_INFO`用于检查 DTC (”) 是否处于待处理状态，ECU-1 的 RecordNumber 1 AAA123 为 RecordNumber 1。此活动采用基于时间的数据收集和上传。

```
{
  "compression": "SNAPPY",
  "spoolingMode": "TO_DISK",
  "signalsToFetch": [
    {
      "fullyQualifiedName": "Vehicle.ECU1.DTC_INFO",
      "signalFetchConfig": {
        "conditionBased": {
        // The action will only run when the ignition is on.
          "conditionExpression": "$variable.`Vehicle.Ignition` == 1",
          "triggerMode": "ALWAYS"
        }
      },
      // The UDS module is only requested for the specific ECU address and the specific DTC Number/Status.
      "actions": ["custom_function(\"DTC_QUERY\", 1, 2, 8, \"0xAAA123\")"]
    }
  ],
  "signalsToCollect": [
    {
      "name": "Vehicle.ECU1.DTC_INFO"
    },
    {
      "name": "Vehicle.Ignition"
    }
  ],
  "collectionScheme": {
    "timeBasedCollectionScheme": {
      "periodMs": 10000
    }
  },
  "dataDestinationConfigs": [
    {
      "s3Config": 
        {
          "bucketArn": "bucket-arn",
          "dataFormat": "PARQUET",
          "prefix": "campaign-name",
          "storageCompressionFormat": "GZIP"
        }
    }
  ]
}
```

## 按需获取
<a name="fetch-dtc-for-fleet"></a>

为舰队获取特定 DTC。

对于按需使用案例，您可以使用定期提取中定义的相同活动。通过使用 AWS 物联网 FleetWise 控制台在部署活动后不久暂停活动或运行以下 CLI 命令来实现按需效果。
+ {{command-name}}替换为命令名。

```
aws iotfleetwise update-campaign \
    --name {{campaign-name}} \
    --action APPROVE
```

然后，在 DTC 数据到来后暂停活动。

```
aws iotfleetwise update-campaign \
    --name {{campaign-name}} \
    --action SUSPEND
```

您可以再次恢复活动以获取 DTC 数据。

```
aws iotfleetwise update-campaign \
    --name {{campaign-name}} \
    --action RESUME
```