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

【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 为每个属性提供配置信息。具体信息包括:

变量说明
accessr、w、rw
changeMode表示监视属性的方式:变化时监视或持续监视。
areaConfigsareaId、min 和 max 值。
configArray额外配置参数。
configString以字符串形式传递的额外信息。
minSampleRatemaxSampleRate
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,
};
  • 4
    点赞
  • 25
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 0
    评论
车载ivi(In-Vehicle Infotainment)开发是指开发车辆中的娱乐和信息系统。在这个系统中,MCU(Microcontroller Unit,微控制器单元)和SOC(System-on-a-Chip,片上系统)是两个重要的组成部分。Framework(框架)则指的是一种开发的基础架构,提供了开发过程中的基本结构和工具。 在车载ivi开发中,MCU被用于控制硬件设备和外围接口,以及处理实时数据。它可以通过提供各种输入和输出接口来与其他设备进行通信,包括触摸屏、按钮、摄像头、声音系统等。MCU还可以处理来自传感器的数据,并根据这些数据控制车辆的不同功能,如温度控制、空调控制等。同时,MCU还与SOC之间通过总线进行通信,以便将数据传输到SOC进行处理。 SOC在车载ivi开发中扮演着处理和存储数据的角色。它集成了处理器、内存、图形加速器、网络接口等功能,可以高效地处理和管理各种媒体数据,如音频、视频、导航系统等。SOC还负责提供操作系统的支持和运行其他应用程序所需的资源。 在开发车载ivi系统时,需要使用框架来简化开发过程。这个框架提供了一套通用的库和工具,以便开发者可以更容易地构建和定制车载ivi应用程序。框架通常包括界面、控制逻辑、数据管理和硬件访问等基本模块,开发者可以在此基础上进行二次开发。通过使用框架,开发者可以节省时间和精力,实现系统的快速开发和调试。 综上所述,车载ivi开发中,MCU和SOC是实现系统功能的核心组件,而框架则是简化开发过程的基础架构。这些元素共同协作,为车载ivi系统的开发和优化提供支持。
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

xhBruce

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值