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

VFlash的自动化和自定义动作

文章目录

  • 一、automation 自动化
  • 二、custom actions 自定义动作
    • 常用方法
    • 如何选择要发送的诊断请求
    • CustomActionValueList 作用
    • Pre Action和Post Action之间交换信息
  • 提示:如何打印软件中变量
  • 报错:无法打开源文件 Windows.h stdio.h conio.h
  • 报错:找不到 Windows SDK 版本 10.0.17763.0
  • 参考

一、automation 自动化

官方示例路径:C:\Users\Public\Documents\Vector\vFlash\10\Examples\Automation\vFlashAutomation

使用 VFlash Automation 需要有能刷写成功的工程。在 VFlash 中将工程保存为 Pack&Go 工程,文件后缀名为 .vflashpack

二、custom actions 自定义动作

官方示例路径:C:\Users\Public\Documents\Vector\vFlash\10\Examples\CustomActions

  1. 根据上方参考地址,或者参考下图找到官方示例
    在这里插入图片描述
  2. CustomActionAttributes 示例工程为例,首先将该工程下的CDD文件替换为自己实际使用的CDD文件
    在这里插入图片描述
  3. 主要关注Execute 函数的实现,该函数实现的内容即为 Pre Action 或者 Post Action 执行的内容
    在这里插入图片描述
  4. 获取可发送诊断请求的ECU对象
// Get ECU object to which diagnostic requests can be sent
Ecu ecu = Application.GetEcu();
  1. 发送诊断请求
using (Request request = ecu.CreateRequest("ExtendedDiagnosticSession_Start"))
{request.Send();
}
  1. 读取DID
// ---------------------------------------------------------
// Service: Software_Version_Read (Signature: [0x] 22 F1 89)
// ---------------------------------------------------------
{using (Request request = ecu.CreateRequest("Software_Version_Read")){// Send the requestSendResult result = request.Send();if (result.Status == SendStatus.Ok){// Get the responseusing (Response response = result.Response){if (response != null && response.IsPositive){// Get parameter "SoftwareVersion" from responseParameter softwareVersionParam = response.GetParameter("SoftwareVersion");if (softwareVersionParam != null){return softwareVersionParam.Value.ToString(); // parameter value: "1.0.0"}}}}}
}

常用方法

  • controlHandle.SkipFlashing = true;:跳过刷写

如何选择要发送的诊断请求

当要发送诊断请求时,需要调用ecu.CreateRequest("ExtendedDiagnosticSession_Start"),传入的参数为字符串,而字符串则代表了我们需要发送的诊断请求。

字符串主要分为两部分:Name_Supported Service
在这里插入图片描述
字符串中不能有空格,当Name中包含空格时,使用下划线
当调用 response.GetParameter("SoftwareVersion") 时,同样字符串中不能有空格,当Name中包含空格时,需要删除空格

CustomActionValueList 作用

在一个 vFlash 项目中,自定义操作值列表CustomActionValueList的标识符应该是唯一的。
用户可以通过 VFlash 设置其值,例如创建如下标识符:

[CustomActionValueList("Skip flashing if voltage is low", new[] { "Yes", "No" }, DefaultSelection = "No" ]

在这里插入图片描述

// 获取值
customActionConfig.CustomActionValueListContainer.GetCustomActionValueList("Skip flashing if voltage is low").Selection;

Pre Action和Post Action之间交换信息

通过 CustomActionAttribute需要注意的是,在 PreAction.cs中定义后,在PostAction.cs 不能重复定义,否则会导致不能获得 PreAction.cs 设置的值。

[CustomActionAttribute("Type Identifier", CustomActionAttributeType.AsciiString, VisibleInUi = true)]

VisibleInUi = true 表示在 VFlash 窗口中显示
在这里插入图片描述

// 获取信息
string cATypeIdentifier = customActionConfig.CustomActionAttributeContainer.GetCustomActionAttribute("Type Identifier").ToString();
// 打印信息
Output.WriteLine(cATypeIdentifier);
// 修改信息
customActionConfig.CustomActionAttributeContainer.GetCustomActionAttribute("Type Identifier").Set("demo");
// 获取信息
cATypeIdentifier = customActionConfig.CustomActionAttributeContainer.GetCustomActionAttribute("Type Identifier").ToString();
// 打印信息
Output.WriteLine(cATypeIdentifier);

提示:如何打印软件中变量

使用 Output.WriteLine("string");

报错:无法打开源文件 Windows.h stdio.h conio.h

依次点击“项目——配置属性——C/C++——常规”,在“附加包含目录”中加入.h文件所在的文件夹路径
在这里插入图片描述

报错:找不到 Windows SDK 版本 10.0.17763.0

在这里插入图片描述
在这里插入图片描述
在这里插入图片描述

参考

  • vFlash的用户自定义操作-Custom Action
  • 【诊断线上活动视频合集】 ECU刷写解决方案

相关文章:

  • 深入理解Qt状态机的应用
  • C++23 新特性:std::size_t 字面量后缀 Z/z
  • B3634 最大公约数和最小公倍数
  • InfiniBand与RoCEv2负载均衡机制的技术梳理与优化实践
  • AWS中国区服务部署与ICP备案全流程指南:从0到1实现合规上线
  • Python爬虫实战:基于 Scrapy 框架的微博数据爬取研究
  • 给你的 Rust 通用库“插上” WebAssembly 的翅膀
  • 批量给文件创建一个同名的文件夹,并将文件放入对应同名的文件夹
  • 第9篇:Linux程序访问控制FPGA端HEX<二>
  • 常用UI设计工具及平台概览
  • Mac配置Java的环境变量
  • 案例驱动的 IT 团队管理:创新与突破之路:第五章 创新管理:从机制设计到文化养成-5.2 技术决策民主化-5.2.2技术选型的量化评估矩阵
  • 4.15BUUCTF Ez_bypass,HardSQL,AreUSerialz,BabyUpload,CheckIn
  • GitLab-CI集成FTP自动发布
  • docker 启动mysql9认证失败
  • Postman实现接口测试(附项目实战)
  • kubesphere(一) Ubuntu 24 云服务器 单节点 kubekey 安装k8s和kubesphere
  • 碳排放因子库
  • 利用redis实现订单倒计结束后更改订单状态为已失效
  • 大数据调度组件
  • 德州国资欲退出三东筑工,后者大股东系当地房企东海集团
  • 获派驻6年后,中国驻厄瓜多尔大使陈国友即将离任
  • 知名猎头公司创始人兼首席执行官庄华因突发疾病逝世,享年62岁
  • 国际能源署:全球电动汽车市场强劲增长,中国市场继续领跑
  • 工人日报:“鼠标手”被纳入职业病,劳动保障网越织越密
  • 商务部召开外贸企业圆桌会:全力为外贸企业纾困解难,提供更多支持