当前位置: 首页 > ds >正文

Vehicle HAL(4)--vhal 的属性如何配置?

本文介绍ard11的 vhal 属性配置方法,后面vhal升级为aidl后,配置位置在其他位置,将另行介绍。

1. vhal属性配置文件DefaultConfig.h的位置

android11/hardware/interfaces/automotive/vehicle/2.0/default/impl/vhal_v2_0/DefaultConfig.h

195  const ConfigDeclaration kVehicleProperties[]{
196          {.config =
197                   {
198                           .prop = toInt(VehicleProperty::INFO_FUEL_CAPACITY),
199                           .access = VehiclePropertyAccess::READ,
200                           .changeMode = VehiclePropertyChangeMode::STATIC,
201                   },
202           .initialValue = {.floatValues = {15000.0f}}},
203 
.......

1.1 属性解析需要注意的数据结构

1.1.1 struct ConfigDeclaration

android11/hardware/interfaces/automotive/vehicle/2.0/default/impl/vhal_v2_0/DefaultConfig.h
 

struct ConfigDeclaration {VehiclePropConfig config;//注意这里/* This value will be used as an initial value for the property. If this field is specified for* property that supports multiple areas then it will be used for all areas unless particular* area is overridden in initialAreaValue field. */VehiclePropValue::RawValue initialValue;///* Use initialAreaValues if it is necessary to specify different values per each area. */std::map<int32_t, VehiclePropValue::RawValue> initialAreaValues;
};

1.1.1.1 struct VehiclePropConfig

android11/hardware/interfaces/automotive/vehicle/2.0/types.hal

3512 struct VehiclePropConfig {
3513     /** Property identifier */
3514     int32_t prop;
3515
3516     /**
3517      * Defines if the property is read or write or both.
3518      */
3519     VehiclePropertyAccess access;
3520
3521     /**
3522      * Defines the change mode of the property.
3523      */
3524     VehiclePropertyChangeMode changeMode;
3525
3526     /**
3527      * Contains per-area configuration.
3528      */
3529     vec<VehicleAreaConfig> areaConfigs;
3530
3531     /** Contains additional configuration parameters */
3532     vec<int32_t> configArray;
3533
3534     /**
3535      * Some properties may require additional information passed over this
3536      * string. Most properties do not need to set this.
3537      */
3538     string configString;
3539
3540     /**
3541      * Min sample rate in Hz.
3542      * Must be defined for VehiclePropertyChangeMode::CONTINUOUS
3543      */
3544     float minSampleRate;
3545
3546     /**
3547      * Must be defined for VehiclePropertyChangeMode::CONTINUOUS
3548      * Max sample rate in Hz.
3549      */
3550     float maxSampleRate;
3551 };

1.1.1.2 struct VehiclePropValue

android11/hardware/interfaces/automotive/vehicle/2.0/types.hal

3553 /**
3554  * Encapsulates the property name and the associated value. It
3555  * is used across various API calls to set values, get values or to register for
3556  * events.
3557  */
3558 struct VehiclePropValue {
3559     /** Time is elapsed nanoseconds since boot */
3560     int64_t timestamp;
3561
3562     /**
3563      * Area type(s) for non-global property it must be one of the value from
3564      * VehicleArea* enums or 0 for global properties.
3565      */
3566     int32_t areaId;
3567
3568     /** Property identifier */
3569     int32_t prop;
3570
3571     /** Status of the property */
3572     VehiclePropertyStatus status;
3573
3574     /**
3575      * Contains value for a single property. Depending on property data type of
3576      * this property (VehiclePropetyType) one field of this structure must be filled in.
3577      */
3578     struct RawValue {
3579         /**
3580          * This is used for properties of types VehiclePropertyType#INT
3581          * and VehiclePropertyType#INT_VEC
3582          */
3583         vec<int32_t> int32Values;
3584
3585         /**
3586          * This is used for properties of types VehiclePropertyType#FLOAT
3587          * and VehiclePropertyType#FLOAT_VEC
3588          */
3589         vec<float> floatValues;
3590
3591         /** This is used for properties of type VehiclePropertyType#INT64 */
3592         vec<int64_t> int64Values;
3593
3594         /** This is used for properties of type VehiclePropertyType#BYTES */
3595         vec<uint8_t> bytes;
3596
3597         /** This is used for properties of type VehiclePropertyType#STRING */
3598         string stringValue;
3599     };
3600
3601     RawValue value;
3602 };

2. vhal常见的属性id

(1) 0x15600503--358614275(HVAC_TEMPERATURE_SET)

android11/packages/services/Car/car-lib/src/android/car/VehiclePropertyIds.java

359      @RequiresPermission(Car.PERMISSION_CONTROL_CAR_CLIMATE)
360      public static final int HVAC_TEMPERATURE_SET = 358614275;

android11/packages/services/Car/tests/vehiclehal_test/Android.mk

android11/packages/services/Car/tests/vehiclehal_test/assets/car_hvac_test.json

8     {
9         "timestamp": 1526063904959113984,
10         "areaId": 49,
11         "value": 28,
12         "prop": 358614275
13     },

hvac的控制代码

android11/frameworks/base/packages/CarSystemUI/src/com/android/systemui/car/hvac/

android11/frameworks/base/packages/CarSystemUI/src/com/android/systemui/car/hvac/HvacController.java

60      /**
61       * Callback for getting changes from {@link CarHvacManager} and setting the UI elements to
62       * match.
63       */
64      private final CarHvacEventCallback mHardwareCallback = new CarHvacEventCallback() {
65          @Override
66          public void onChangeEvent(final CarPropertyValue val) {
67              try {
68                  int areaId = val.getAreaId();
69                  int propertyId = val.getPropertyId();
70                  List<TemperatureView> temperatureViews = mTempComponents.get(
71                          new HvacKey(propertyId, areaId));
72                  if (temperatureViews != null && !temperatureViews.isEmpty()) {
73                      float value = (float) val.getValue();
74                      if (DEBUG) {
75                          Log.d(TAG, "onChangeEvent: " + areaId + ":" + propertyId + ":" + value);
76                      }
77                      for (TemperatureView tempView : temperatureViews) {
78                          tempView.setTemp(value);
79                      }
80                  } // else the data is not of interest
81              } catch (Exception e) {
82                  // catch all so we don't take down the sysui if a new data type is
83                  // introduced.
84                  Log.e(TAG, "Failed handling hvac change event", e);
85              }
86          }
87 
88          @Override
89          public void onErrorEvent(final int propertyId, final int zone) {
90              Log.d(TAG, "HVAC error event, propertyId: " + propertyId
91                      + " zone: " + zone);
92          }
93      };
94 
95      private final CarServiceProvider.CarServiceOnConnectedListener mCarServiceLifecycleListener =
96              car -> {
97                  try {
98                      mHvacManager = (CarHvacManager) car.getCarManager(Car.HVAC_SERVICE);
99                      mHvacManager.registerCallback(mHardwareCallback);
100                      initComponents();
101                  } catch (Exception e) {
102                      Log.e(TAG, "Failed to correctly connect to HVAC", e);
103                  }
104              };

(2) 0x11410a00--289475072(AP_POWER_STATE_REQ )

553      /**
554       * Property to control power state of application processor
555       *
556       * It is assumed that AP's power state is controller by separate power
557       * controller.
558       * The property is protected by the signature permission: android.car.permission.CAR_POWER.
559       */
560      @RequiresPermission(Car.PERMISSION_CAR_POWER)
561      public static final int AP_POWER_STATE_REQ = 289475072;
562      /**
563       * Property to report power state of application processor
564       *
565       * It is assumed that AP's power state is controller by separate power
566       * controller.
567       * The property is protected by the signature permission: android.car.permission.CAR_POWER.
568       */
569      @RequiresPermission(Car.PERMISSION_CAR_POWER)
570      public static final int AP_POWER_STATE_REPORT = 289475073;

(3) 0x11400a03--289409539(DISPLAY_BRIGHTNESS )

581      /**
582       * Property to represent brightness of the display. Some cars have single
583       * control for the brightness of all displays and this property is to share
584       * change in that control.
585       * The property is protected by the signature permission: android.car.permission.CAR_POWER.
586       */
587      @RequiresPermission(Car.PERMISSION_CAR_POWER)
588      public static final int DISPLAY_BRIGHTNESS = 289409539;

 

 

http://www.xdnf.cn/news/12254.html

相关文章:

  • 【面经分享】滴滴
  • HCIE-Datacom笔试题库
  • 法律模型选型
  • 食品计算—Dpf-nutrition: Food nutrition estimation via depth prediction and fusion
  • U盘从Linux系统向Windows系统切换时出错
  • 【无标题】平面图四色问题P类归属的严格论证——基于拓扑收缩与动态调色算法框架
  • linux如何配置wifi连接
  • JAVASE:网络编程
  • 遥控器3nm模块技术解析!
  • 代码中的问题及解决方法
  • C++内联函数(inline)的作用
  • 核心线程池大小如何设置?
  • Linux系统安装DNS服务器
  • 雷卯针对易百纳 SS524多媒体处理演示评估板防雷防静电方案
  • 《10 秒建立邻居,5 秒同步全网:OSPF 如何让网络故障 “秒级自愈”?》
  • [AI Claude] 软件测试1
  • 《P4799 [CEOI 2015] 世界冰球锦标赛 (Day2)》
  • unix/linux,sudo,其基本属性、语法、操作、api
  • 区块链技术:原理、应用与发展趋势
  • CD43.vector模拟实现(2)
  • 守护生命律动:进行性核上性麻痹的专业健康护理指南
  • Docker快速部署AnythingLLM全攻略
  • CSS选择子元素
  • mysql数据库的导入导出专题
  • SpringBoot parent依赖高版本覆盖低版本问题
  • 《小明的一站式套餐服务平台》
  • Go内存模型基础:理解内存分配机制
  • 从OCR到Document Parsing,AI时代的非结构化数据处理发生了什么改变?
  • OpenProject:一款功能全面的开源项目管理软件
  • 2.0 阅读方法论与知识总结