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

Vehicle HAL(5)--vhal 实现设置属性的流程

目录

1. ard11 vhal 设置属性的时序图 CarService > vhal > CarService

2. EmulatedVehicleHal::set(xxx) 的实现


本文介绍ard11的vhal属性设置流程图。

1. ard11 vhal 设置属性的时序图 CarService > vhal > CarService

2. EmulatedVehicleHal::set(xxx) 的实现

从client端来的set调用最后会调用到EmulatedVehicleHal中。再由它转到其他地方(车身、ECU),和传回CarService。

android11/hardware/interfaces/automotive/vehicle/2.0/default/impl/vhal_v2_0/EmulatedVehicleHal.cpp

163  StatusCode EmulatedVehicleHal::set(const VehiclePropValue& propValue) {
164      constexpr bool updateStatus = false;
165 
166      if (propValue.prop == kGenerateFakeDataControllingProperty) {
167          // Send the generator controlling request to the server.
168          // 'updateStatus' flag is only for the value sent by setProperty (propValue in this case)
169          // instead of the generated values triggered by it. 'propValue' works as a control signal
170          // here, since we never send the control signal back, the value of 'updateStatus' flag
171          // does not matter here.
172          auto status = mVehicleClient->setProperty(propValue, updateStatus);
173          return status;
174      } else if (mHvacPowerProps.count(propValue.prop)) {
175          auto hvacPowerOn = mPropStore->readValueOrNull(
176              toInt(VehicleProperty::HVAC_POWER_ON),
177              (VehicleAreaSeat::ROW_1_LEFT | VehicleAreaSeat::ROW_1_RIGHT |
178               VehicleAreaSeat::ROW_2_LEFT | VehicleAreaSeat::ROW_2_CENTER |
179               VehicleAreaSeat::ROW_2_RIGHT));
180 
181          if (hvacPowerOn && hvacPowerOn->value.int32Values.size() == 1
182                  && hvacPowerOn->value.int32Values[0] == 0) {
183              return StatusCode::NOT_AVAILABLE;
184          }
185      } else {
186          // Handle property specific code
187          switch (propValue.prop) {
188              case OBD2_FREEZE_FRAME_CLEAR:
189                  return clearObd2FreezeFrames(propValue);
190              case VEHICLE_MAP_SERVICE:
191                  // Placeholder for future implementation of VMS property in the default hal. For
192                  // now, just returns OK; otherwise, hal clients crash with property not supported.
193                  return StatusCode::OK;
194          }
195      }
196 
197      if (propValue.status != VehiclePropertyStatus::AVAILABLE) {
198          // Android side cannot set property status - this value is the
199          // purview of the HAL implementation to reflect the state of
200          // its underlying hardware
201          return StatusCode::INVALID_ARG;
202      }
203      auto currentPropValue = mPropStore->readValueOrNull(propValue);
204 
205      if (currentPropValue == nullptr) {
206          return StatusCode::INVALID_ARG;
207      }
208      if (currentPropValue->status != VehiclePropertyStatus::AVAILABLE) {
209          // do not allow Android side to set() a disabled/error property
210          return StatusCode::NOT_AVAILABLE;
211      }
212 
213      /**
214       * After checking all conditions, such as the property is available, a real vhal will
215       * sent the events to Car ECU to take actions.
216       */
217 
218      // Send the value to the vehicle server, the server will talk to the (real or emulated) car
219      auto setValueStatus = mVehicleClient->setProperty(propValue, updateStatus);//关键代码
220      if (setValueStatus != StatusCode::OK) {
221          return setValueStatus;
222      }
223 
224      return StatusCode::OK;
225  }

相关文章:

  • Three.js光与影代码分析及原理阐述
  • 能不能用string接收数据库的datetime类型字段
  • 晨读笔记 6-5 (主题:打造15分钟就业服务圈)
  • MySQL 索引:聚集索引与二级索引
  • 线段树~~~
  • 软件项目管理(2) 软件项目确立
  • Debugger encountered an exception:Exception at 0x7ff809232bdc
  • python类的高级方法(slots,dataclass,named tuples)
  • Postgresql源码(146)二进制文件格式分析
  • 408第一季 - 408内容概述
  • Modbus转Ethernet IP深度解析:磨粉设备效率跃升的底层技术密码
  • 老旧热泵设备智能化改造:Ethernet IP转Modbus的低成本升级路径
  • linux 串口调试命令 stty
  • 两张关联表,INNER JOIN同步公共属性(工作实战)
  • [zynq] Zynq Linux 环境下 AXI BRAM 控制器驱动方法详解(代码示例)
  • 【Linux】Linux基础指令1
  • 最小硬件系统概念及其组成
  • 14.AI搭建preparationのBERT预训练模型进行文本分类
  • Form开发指南-第二弹:基本配置与开发流程
  • MDK程序调试
  • wordpress如何搭建一个购物网站/线上运营推广方案
  • 养生网站建设免费/百度客服怎么联系
  • 网站制作要学哪些/武汉网络推广网络营销
  • 重庆seo小潘大神/seo手机搜索快速排名
  • 禅城网站建设报价/web网站模板
  • 沭阳哪里可以做网站/国外seo