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

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  }

http://www.lryc.cn/news/2401665.html

相关文章:

  • WebRTC中的几个Rtp*Sender
  • 代码随想录算法训练营第十一天 | 150. 逆波兰表达式求值、239. 滑动窗口最大值、347.前 K 个高频元素、栈与队列总结
  • Java编程课(一)
  • IDEA202403 设置主题和护眼色
  • 无人机螺旋桨平衡方法详解
  • VUE混合开发用哪个PHP框架好?
  • 基于51单片机的车内防窒息检测报警系统
  • Flask-Babel 使用示例
  • Android 轻松实现 增强版灵活的 滑动式表格视图
  • 寄存器模型生成:从手工到自动化
  • 国标GB28181视频平台EasyGBS视频实时监控系统打造换热站全景可视化管理方案
  • docker生命周期
  • 鸿蒙缺少WMIC missing WMIC
  • 25.6.5学习总结
  • Spring Boot 使用 SLF4J 实现控制台输出与分类日志文件管理
  • linux_centos7.x的ifconfig命令显示内容详解
  • CentOS 7 如何pip3安装pyaudio?
  • 6.5本日总结
  • 【个人笔记】数据库原理(西电)
  • 嵌入式学习之系统编程(十)网络编程之TCP传输控制协议
  • 【react+antd+vite】优雅的引入svg和阿里巴巴图标
  • 3D动画在微信小程序的实现方法
  • 计算机网络 | 1.2 计算机网络体系结构与参考模型
  • 网心云 OEC/OECT 笔记(1) 拆机刷入Armbian固件
  • 【Web应用】若依框架:基础篇17二次开发-项目名称修改-新建业务模块
  • C获取unix操作系统的信息
  • MQTT入门实战宝典:从零起步掌握物联网核心通信协议
  • 05【Linux经典命令】Linux 用户管理全面指南:从基础到高级操作
  • POP3、IMAP、SMTP:三大邮件协议核心差异与应用场景解析
  • HarmonyOS5 仓颉入门:和 ArkTs 互操作