【IVI】车载设备硬件抽象层VHAL

android12-release
Android Automotive OS知识体系
Android 知识体系


1、概要

  车载硬件抽象层 (HAL) 接口会定义原始设备制造商 (OEM) 可以实现的属性,并会包含属性元数据(例如,属性是否为 int 以及允许使用哪些更改模式)。VHAL 接口以对属性(特定功能的抽象表示)的访问(读取、写入、订阅)为基础。

2、HAL 接口

【IVI】VehicleService启动

2.1 VHAL 使用以下接口

hardware/interfaces/automotive/vehicle/2.0/IVehicle.hal

  • getAllPropConfigs() 会生成 (vecpropConfigs)
    列出 VHAL 所支持的所有属性的配置。CarService 仅使用支持的属性。
  • getPropConfigs(vec<int32_t> props) 会生成 (StatusCode status,vec propConfigs);
    返回所选属性的配置。
  • set(VehiclePropValue propValue) 会生成 (StatusCodestatus);
    向属性写入一个值。写入的结果是按属性进行定义的。
  • subscribe(IVehicleCallback callback, vec options) 会生成 (StatusCode status);
    开始监视属性值的变化。对于区域属性,unsubscribe(IVehicleCallback callback, int32_t propId) 会生成 (StatusCode status);

2.2 VHAL 使用以下回调接口

hardware/interfaces/automotive/vehicle/2.0/IVehicleCallback.hal

  • oneway onPropertyEvent(vecpropValues);
    通知车辆属性值的变化。应只针对已订阅属性执行。
  • oneway onPropertySetError(StatusCode errorCode,int32_t propId,int32_tareaId);
    返回全局 VHAL 级错误或每个属性的错误。全局错误会导致 HAL 重新启动,这可能会导致包括应用在内的其他组件重新启动。

2.3 Set 调用

set 调用属于异步操作,涉及所请求更改发生之后的事件通知。在通常的操作中,set 调用会导致在车辆网络中发出更改请求。某些 set 调用可能要求准备好初始数据,而这些数据在初始化期间可能尚不可用。在这种情况下,set 调用应返回 -EAGAIN。某些具有独立的电源开/关的属性应在属性关闭且无法设置时返回 -ESHUTDOWN。在 set 生效之前,get 不一定会返回所设置的值。例如:set HVAC Temperature


(CS = CarService、VHAL = 车载 HAL)

2.4 Get 调用

在初始化期间,由于尚未收到匹配的车辆网络消息,属性的值可能不可用。在这种情况下,get 调用应返回 -EAGAIN。一些属性(例如 HVAC)具有独立的电源开/关属性。对此类属性调用 get(关闭电源时)应返回 UNAVAILABLE 状态,而不是返回错误。例如,get HVAC 温度


(CS = CarService、VHAL = 车载 HAL)

3、车辆属性

3.1 车辆属性

hardware/interfaces/automotive/vehicle/2.0/types.hal
属性可以为只读、只写(用于将信息传递到 VHAL 一级),也可以为读写(对大多数属性而言对读写的支持是可选的)。每个属性都由一个 int32 键唯一标识,且具有一个预定义的类型 (value_type):

  • BYTES
  • BOOLEAN
  • EPOCH_TIME
  • FLOAT
  • FLOAT[]
  • INT32
  • INT32[]
  • INT64
  • INT64[]
  • STRING
  • MIXED

区域属性可能具有多个值,具体取决于属性所支持的区域数量。

/*** Enumerates supported data type for VehicleProperty.** Used to create property ID in VehicleProperty enum.*/
enum VehiclePropertyType : int32_t {STRING          = 0x00100000,BOOLEAN         = 0x00200000,INT32           = 0x00400000,INT32_VEC       = 0x00410000,INT64           = 0x00500000,INT64_VEC       = 0x00510000,FLOAT           = 0x00600000,FLOAT_VEC       = 0x00610000,BYTES           = 0x00700000,/*** Any combination of scalar or vector types. The exact format must be* provided in the description of the property.** For vendor MIXED type properties, configArray needs to be formatted in this* structure.* configArray[0], 1 indicates the property has a String value* configArray[1], 1 indicates the property has a Boolean value .* configArray[2], 1 indicates the property has an Integer value.* configArray[3], the number indicates the size of Integer[] in the property.* configArray[4], 1 indicates the property has a Long value.* configArray[5], the number indicates the size of Long[] in the property.* configArray[6], 1 indicates the property has a Float value.* configArray[7], the number indicates the size of Float[] in the property.* configArray[8], the number indicates the size of byte[] in the property.* For example:* {@code configArray = {1, 1, 1, 3, 0, 0, 0, 0, 0}} indicates the property has* a String value, a Boolean value, an Integer value and an array with 3 integers.*/MIXED           = 0x00e00000,MASK            = 0x00ff0000
};

3.2 区域类型

区域类型 说明
GLOBAL 此属性是一个单例,不具备多个区域。
WINDOW 基于车窗的区域,使用 VehicleAreaWindow 枚举。
MIRROR 基于车镜的区域,使用 VehicleAreaMirror 枚举。
SEAT 基于座椅的区域,使用 VehicleAreaSeat 枚举。
DOOR 基于车门的区域,使用 VehicleAreaDoor 枚举。
WHEEL 基于车轮的区域,使用 VehicleAreaWheel 枚举。
enum VehicleArea : int32_t {GLOBAL      = 0x01000000,/** WINDOW maps to enum VehicleAreaWindow */WINDOW      = 0x03000000,/** MIRROR maps to enum VehicleAreaMirror */MIRROR      = 0x04000000,/** SEAT maps to enum VehicleAreaSeat */SEAT        = 0x05000000,/** DOOR maps to enum VehicleAreaDoor */DOOR        = 0x06000000,/** WHEEL maps to enum VehicleAreaWheel */WHEEL       = 0x07000000,MASK        = 0x0f000000,
};

3.2.1 WINDOW区域类型 VehicleAreaWindow

/*** Various windshields/windows in the car.*/
enum VehicleAreaWindow : int32_t {FRONT_WINDSHIELD  = 0x00000001,REAR_WINDSHIELD   = 0x00000002,ROW_1_LEFT        = 0x00000010,ROW_1_RIGHT       = 0x00000040,ROW_2_LEFT        = 0x00000100,ROW_2_RIGHT       = 0x00000400,ROW_3_LEFT        = 0x00001000,ROW_3_RIGHT       = 0x00004000,ROOF_TOP_1        = 0x00010000,ROOF_TOP_2        = 0x00020000,};

3.2.2 MIRROR区域类型 VehicleAreaMirror

enum VehicleAreaMirror : int32_t {DRIVER_LEFT = 0x00000001,DRIVER_RIGHT = 0x00000002,DRIVER_CENTER = 0x00000004,
};

3.2.3 SEAT区域类型 VehicleAreaSeat

/*** Various Seats in the car.*/
enum VehicleAreaSeat : int32_t {ROW_1_LEFT   = 0x0001,ROW_1_CENTER = 0x0002,ROW_1_RIGHT  = 0x0004,ROW_2_LEFT   = 0x0010,ROW_2_CENTER = 0x0020,ROW_2_RIGHT  = 0x0040,ROW_3_LEFT   = 0x0100,ROW_3_CENTER = 0x0200,ROW_3_RIGHT  = 0x0400
};

3.2.4 DOOR区域类型 VehicleAreaDoor

enum VehicleAreaDoor : int32_t {ROW_1_LEFT = 0x00000001,ROW_1_RIGHT = 0x00000004,ROW_2_LEFT = 0x00000010,ROW_2_RIGHT = 0x00000040,ROW_3_LEFT = 0x00000100,ROW_3_RIGHT = 0x00000400,HOOD = 0x10000000,REAR = 0x20000000,
};

3.2.5 WHEEL区域类型 VehicleAreaWheel

enum VehicleAreaWheel : int32_t {UNKNOWN = 0x0,LEFT_FRONT = 0x1,RIGHT_FRONT = 0x2,LEFT_REAR = 0x4,RIGHT_REAR = 0x8,
};

3.3 属性状态

每个属性值都有一个 VehiclePropertyStatus 值。该值指示相应属性的当前状态:

项目 说明
AVAILABLE 属性可用,且值有效。
UNAVAILABLE 属性值目前不可用。用于某个受支持属性的被暂时停用的功能。
ERROR 该属性有问题。
/*** Property status is a dynamic value that may change based on the vehicle state.*/
enum VehiclePropertyStatus : int32_t {/** Property is available and behaving normally */AVAILABLE   = 0x00,/*** A property in this state is not available for reading and writing.  This* is a transient state that depends on the availability of the underlying* implementation (e.g. hardware or driver). It MUST NOT be used to* represent features that this vehicle is always incapable of.  A get() of* a property in this state MAY return an undefined value, but MUST* correctly describe its status as UNAVAILABLE A set() of a property in* this state MAY return NOT_AVAILABLE. The HAL implementation MUST ignore* the value of the status field when writing a property value coming from* Android.*/UNAVAILABLE = 0x01,/** There is an error with this property. */ERROR       = 0x02,
};

2.4 配置属性

使用 VehiclePropConfig 为每个属性提供配置信息。具体信息包括:

变量 说明
access r、w、rw
changeMode 表示监视属性的方式:变化时监视或持续监视。
areaConfigs areaId、min 和 max 值。
configArray 额外配置参数。
configString 以字符串形式传递的额外信息。
minSampleRate maxSampleRate
prop 属性 ID,整数
struct VehiclePropConfig {/** Property identifier */int32_t prop;/*** Defines if the property is read or write or both.*/VehiclePropertyAccess access;/*** Defines the change mode of the property.*/VehiclePropertyChangeMode changeMode;/*** Contains per-area configuration.*/vec<VehicleAreaConfig> areaConfigs;/** Contains additional configuration parameters */vec<int32_t> configArray;/*** Some properties may require additional information passed over this* string. Most properties do not need to set this.*/string configString;/*** Min sample rate in Hz.* Must be defined for VehiclePropertyChangeMode::CONTINUOUS*/float minSampleRate;/*** Must be defined for VehiclePropertyChangeMode::CONTINUOUS* Max sample rate in Hz.*/float maxSampleRate;
};

2.4.1 property可读、可写或读写

/*** Property config defines the capabilities of it. User of the API* must first get the property config to understand the output from get()* commands and also to ensure that set() or events commands are in sync with* the expected output.*/
enum VehiclePropertyAccess : int32_t {NONE = 0x00,READ = 0x01,WRITE = 0x02,READ_WRITE = 0x03,
};

2.4.2 property改变模式

/*** This describes how value of property can change.*/
enum VehiclePropertyChangeMode : int32_t {/*** Property of this type must never be changed. Subscription is not supported* for these properties.*/STATIC = 0x00,/*** Properties of this type must report when there is a change.* IVehicle#get call must return the current value.* Set operation for this property is assumed to be asynchronous. When the* property is read (using IVehicle#get) after IVehicle#set, it may still* return old value until underlying H/W backing this property has actually* changed the state. Once state is changed, the property must dispatch* changed value as event.*/ON_CHANGE = 0x01,/*** Properties of this type change continuously and require a fixed rate of* sampling to retrieve the data.  Implementers may choose to send extra* notifications on significant value changes.*/CONTINUOUS = 0x02,
};

【IVI】车载设备硬件抽象层VHAL相关推荐

  1. Android 车机初体验:Auto,Automotive 傻傻分不清楚?

    原创作者:小虾米君 转载地址:https://mp.weixin.qq.com/s/3OL8boekmBId0UVU6amp8A WWDC 2022 上野心勃勃的 CarPlay 让不少车企感受了更多 ...

  2. 【IVI】1. Android Automotive OS 安卓车载操作系统白皮书

    ---底色来自google,润色来自小B: 借助各种总线拓扑,很多汽车子系统都可以实现互连以及与车载信息娱乐 (IVI) 系统的连接.不同的制造商提供的确切总线类型和协议之间有很大差异(甚至同一品牌的 ...

  3. 【IVI】CarService启动

    [IVI]CarService启动 android12-release Android Automotive OS知识体系 Android 知识体系 1.CarServiceHelperService ...

  4. 第九章 硬件抽象层:HAL 心得笔记

    1.HAL(Handerware Abstraction Layer,硬件抽象层)是建立在linux程序上的一套程序库,这套程序库并不属于内核,而是属于内核之上的应用层. 2.要在Android中加入 ...

  5. Android硬件抽象层(HAL)深入剖析(一)

    2019独角兽企业重金招聘Python工程师标准>>> 作为一个搞android驱动或者说搞底层的人,我觉得对于hal那是必须要掌握的,而且必须达到一定深度,于是我总结了一下,将整个 ...

  6. windows 编写的硬件驱动_哪个是PXI硬件合适的设备驱动程序?VISA还是IVI?

    理想的测试系统可以认为是其组成部分的总和,包括测量和激励硬件,信号切换,电缆以及可能 的大规模互连系统,UUT电源,外部PC或嵌入式控制器,操作系统(OS)和编程环境.每个部件根据诸如UUT测试参数, ...

  7. Android帧缓冲区(Frame Buffer)硬件抽象层(HAL)模块Gralloc的实现原理分析

    前面在介绍Android系统的开机画面时提到,Android设备的显示屏被抽象为一个帧缓冲区,而Android系统中的SurfaceFlinger服务就是通过向这个帧缓冲区写入内容来绘制应用程序的用户 ...

  8. 在Ubuntu为Android硬件抽象层(HAL)模块编写JNI方法提供Java访问硬件服务接口 6...

    在上两篇文章中,我们介绍了如何为Android系统的硬件编写驱动程序,包括如何在Linux内核空间实现内核驱动程序和在用户空间实现硬件抽象层接口.实现这两者的目的是为了向更上一层提供硬件访问接口,即为 ...

  9. Android应用开发 led 驱动层 hal硬件抽象层 应用层 详细教程记录(含源码)

    本篇文章是为了能够更好的搜索到介绍驱动到应用的详细介绍文章. 关于驱动层 hal硬件抽象层 应用层请参考s5p4418 Android 4.4.2 驱动层 HAL层 服务层 应用层 开发流程记录系列, ...

最新文章

  1. Linux查找文件命令find .
  2. php基础学哪些,榆林学习php需要哪些基础(PHP是什么)
  3. 如何评价周志华深度森林模型
  4. 美国重金投资3D芯片项目!MIT+美独资公司攻关,旨在继续领先中国
  5. springMVC的文件上传于下载
  6. 关于idea,双击选中问题
  7. 用这个玩吃鸡:宏按键加一键恢复加自由移动视角,你想要的功能它都有
  8. 利用idea 打包jar包
  9. Java毕设项目直播购物平台(java+VUE+Mybatis+Maven+Mysql)
  10. 中国羽绒服市场深度调查研究报告
  11. OpenXML指定位置插入图片
  12. 数显之家快讯:「SHIO世硕心语」shio是什么牌子?
  13. 网易大神app ios和android,网易大神app是干嘛的?网易大神有什么用?
  14. 5-2 基于判定的测试
  15. 在线TSV转JSON工具
  16. Coredns+Nodelocaldns cache解决Coredns域名解析延迟
  17. dataframe按照某列排序
  18. BAT 批处理脚本 教程
  19. SAP 让库龄表飞起来!
  20. 火绒能更新服务器系统么,火绒自动升级频率是怎么样的?

热门文章

  1. 企业财务会计-2023会计继续教育知识
  2. msp430时钟/定时器收集的例程汇总
  3. 【转载】 历届Turing奖得主名单
  4. 遗传算法优化数据拟合
  5. 长沙专科学校计算机排名2015,2015湖南专科学校排名及排行榜
  6. MySQL数据库的学习笔记
  7. [Tour of Go] Golang基础
  8. 计算机专业教师理论培训小结,教师多媒体培训个人心得体会【四篇】
  9. 云端软件端侧安全防控新技术
  10. 节能灯与led灯哪个对眼睛好?分享专业护眼的led灯