HONGRI_uds_tools/CAN_Tool/CanToolForm.Diag.cs
liudagui beceab4798 第一次提交:
支持广成CAN,PCAN,同星(要用低版本的TSMaster),TOOMOSS(没有测试过)
2024-11-06 16:52:30 +08:00

289 lines
10 KiB
C#

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace CanTool
{
partial class uds_tools
{
//
//当前使用的诊断相关配置参数
private ReadVersionConfig ReadVersionConfigNow = new ReadVersionConfig();
//比亚迪的诊断相关配置参数
private ReadVersionConfig ReadVersionConfigBYD;
//鸿日的诊断相关配置参数
private ReadVersionConfig ReadVersionConfigHR;
private void DiagParamsInit()
{
#region
ReadVersionConfigBYD = new ReadVersionConfig(new VersionParams[]
{
//new VersionParams("客户MCU软件版本号", 0x22, 0xf189, new byte[0], ReadVersionConfig.DefaultAnalysisVersion0x22),
//new VersionParams("客户MCU硬件版本号", 0x22, 0xf17f, new byte[0], ReadVersionConfig.DefaultAnalysisVersion0x22),
//new VersionParams("供应商软件版本号", 0x22, 0xf195, new byte[0], ReadVersionConfig.DefaultAnalysisVersion0x22),
//new VersionParams("供应商硬件版本号", 0x22, 0xf193, new byte[0], ReadVersionConfig.DefaultAnalysisVersion0x22),
//new VersionParams("BOOT版本号", 0x22, 0xf180, new byte[0], ReadVersionConfig.DefaultAnalysisVersion0x22),
//new VersionParams("UI版本号", 0x2f, 0xf063, new byte[]{0x03,0x03}, ReadVersionConfig.DefaultAnalysisVersion0x2f),
//new VersionParams("内控版本号", 0x2f, 0xf063, new byte[]{0x03, 0x01}, ReadVersionConfig.DefaultAnalysisVersion0x2f),
//new VersionParams("零件号", 0x22, 0xf187, new byte[0], ReadVersionConfig.DefaultAnalysisVersion0x22),
}
);
#endregion
#region 鸿
ReadVersionConfigHR = new ReadVersionConfig(new VersionParams[]
{
//new VersionParams("客户MCU软件版本号", 0x22, 0xf189, new byte[0], ReadVersionConfig.DefaultAnalysisVersion0x22),
//new VersionParams("客户MCU硬件版本号", 0x22, 0xf17f, new byte[0], ReadVersionConfig.DefaultAnalysisVersion0x22),
//new VersionParams("供应商软件版本号", 0x22, 0xf195, new byte[0], ReadVersionConfig.DefaultAnalysisVersion0x22),
//new VersionParams("供应商硬件版本号", 0x22, 0xf193, new byte[0], ReadVersionConfig.DefaultAnalysisVersion0x22),
//new VersionParams("BOOT版本号", 0x22, 0xf180, new byte[0], ReadVersionConfig.DefaultAnalysisVersion0x22),
//new VersionParams("UI版本号", 0x2f, 0xf063, new byte[]{0x03,0x03}, ReadVersionConfig.DefaultAnalysisVersion0x2f),
//new VersionParams("内控版本号", 0x2f, 0xf063, new byte[]{0x03, 0x01}, ReadVersionConfig.DefaultAnalysisVersion0x2f),
//new VersionParams("零件号", 0x22, 0xf187, new byte[0], ReadVersionConfig.DefaultAnalysisVersion0x22),
}
);
#endregion
//自诊断故障码对应文字说明表创建
/*
selfDiagFaultType = new Dictionary<UInt16, string>()
{
{0x01A5,"首次上电标志"},
{0x0101,"异常断电"},
{0x0102,"读取E2PROM异常"},
{0x0103,"FLASH初始化异常"},
{0x0104,"I2C初始化异常"},
{0x0105,"urat 初始化异常"},
{0x0106,"SPI 初始化异常"},
{0x0107,"timer 初始化异常"},
{0x0108,"图库版本错误"},
{0x01F1,"KL15 ON唤醒"},
{0x01F2,"CAN信号唤醒唤醒"},
{0x01F3,"预留唤醒"},
{0x0201,"背光工作状态异常"},
{0x0202,"LED 背光驱动外设异常"},
{0x0301,"到位开关失效"},
{0x0302,"TFT温度传感器开路"},
{0x0303,"TFT温度传感器短路"},
{0x0304,"LED温度传感器开路"},
{0x0305,"LED温度传感器短路"},
{0x0308,"TFT过温"},
{0x0309,"LED过温"},
{0x0401,"车速信号无效"},
{0x0402,"转速信号无效"},
{0x0403,"ACC信号无效"},
{0x0404,"IACC信号无效"},
{0x0405,"TSR信号无效"},
{0x0406,"LDW信号无效"},
{0x0407,"导航信号无效"},
{0x0408,"电话信号无效"},
{0x0501,"消息队列堵塞"},
{0x0502,"UI刷新超时"},
{0x0503,"显示层初始化失败"},
{0x0504,"RW2D 初始化失败"},
{0x0505,"HMI heap 初始化失败"},
{0x0506,"导航箭头输入信号逻辑错误"},
{0x0507,"联系人信息输入信号逻辑错误"},
{0x0508,"TSR输入信号逻辑错误"},
{0x0509,"通话状态输入信号逻辑错误"},
{0x050A,"导航箭头信号输入一直没有清零"},
{0x0601,"升级APP失败"},
{0x0602,"升级图库失败"},
{0x0603,"升级后兼容性检查失败"},
{0x0604,"升级包按校验失败"},
{0x0605,"读取升级标志失败"},
{0x0606,"数据帧checksum校验失败"},
{0x0607,"升级数据通讯超时"},
{0x0608,"code flash擦除动作失败"},
{0x0609,"code flash数据写入失败"},
{0x060A,"外部 flash擦除动作失败"},
{0x060B,"外部 flash数据写入失败"},
};
*/
}
#region DiagReceivedTable
private void DiagReceivedTableInit()
{
//升级接收表驱动初始化
this.UDSReceivedTable.Add(0x50, UDSReceived0x50);
this.UDSReceivedTable.Add(0xC5, UDSReceived0xC5);
this.UDSReceivedTable.Add(0x68, UDSReceived0x68);
this.UDSReceivedTable.Add(0x6E, UDSReceived0x6E);
this.UDSReceivedTable.Add(0x67, UDSReceived0x67);
this.UDSReceivedTable.Add(0x71, UDSReceived0x71);
this.UDSReceivedTable.Add(0x74, UDSReceived0x74);
this.UDSReceivedTable.Add(0x76, UDSReceived0x76);
this.UDSReceivedTable.Add(0x77, UDSReceived0x77);
this.UDSReceivedTable.Add(0x51, UDSReceived0x51);
this.UDSReceivedTable.Add(0x7F, UDSReceived0x7F);
}
//10服务接收
private void UDSReceived0x50(byte[] data)
{
if (data[1] == 0x01)
{
//打印log
rtxtLog.AppendText("进入默认会话成功\n");
}
else if(data[1] == 0x02)
{
//打印log
rtxtLog.AppendText("进入编程会话成功\n");
}
else if (data[1] == 0x03)
{
//打印log
rtxtLog.AppendText("进入扩展会话成功\n");
}
}
private void UDSReceived0xC5(byte[] data)
{
}
private void UDSReceived0x68(byte[] data)
{
}
private void UDSReceived0x6E(byte[] data)
{
}
private void UDSReceived0x67(byte[] data)
{
if ((this.UpdateConfigParamsNow.RequestSeedL1 == data[1])
|| (this.UpdateConfigParamsNow.RequestSeedL2 == data[1])
|| (this.UpdateConfigParamsNow.RequestSeedL3 == data[1])
|| (this.UpdateConfigParamsNow.RequestSeedL4 == data[1])
)
{
//打印log
rtxtLog.AppendText("获取种子成功\n");
Array.Copy(data, 2, RecvSeed, 0, 16);
//进入安全时
if (this.UpdateConfigParamsNow.RequestSeedL1 == data[1])
{
this.EntrySecurityFlag = EntrySecurityStatus.SendkeyLevel1;
}
else if (this.UpdateConfigParamsNow.RequestSeedL2 == data[1])
{
this.EntrySecurityFlag = EntrySecurityStatus.SendkeyLevel2;
}
else if (this.UpdateConfigParamsNow.RequestSeedL3 == data[1])
{
this.EntrySecurityFlag = EntrySecurityStatus.SendkeyLevel3;
}
else if (this.UpdateConfigParamsNow.RequestSeedL4 == data[1])
{
this.EntrySecurityFlag = EntrySecurityStatus.SendkeyLevel4;
}
}
else if ((this.UpdateConfigParamsNow.SendKeyL1 == data[1])
|| (this.UpdateConfigParamsNow.SendKeyL2 == data[1])
|| (this.UpdateConfigParamsNow.SendKeyL3 == data[1])
|| (this.UpdateConfigParamsNow.SendKeyL4 == data[1])
)
{
//打印log
rtxtLog.AppendText("进入安全模式成功\n");
//进入安全时
if (EntrySecurityStatus.Idle != this.EntrySecurityFlag)
{
this.EntrySecurityFlag = EntrySecurityStatus.Unlock;
}
}
}
private void UDSReceived0x71(byte[] data)
{
if ((0xAA == data[2]) && (0x55 == data[3]))
{
//this.UpdateConfigParamsNow.UpdateStepNum++;
// UpdateSendCmdFlag = true;
//打印log
//rtxtLog.AppendText("重置安全密钥成功\n");
rtxtLog.AppendText("升级boot成功\n");
}
}
private void UDSReceived0x74(byte[] data)
{
}
private void UDSReceived0x76(byte[] data)
{
}
private void UDSReceived0x77(byte[] data)
{
}
private void UDSReceived0x51(byte[] data)
{
//打印log
rtxtLog.AppendText("复位成功\n");
}
private void UDSReceived0x7F(byte[] data)
{
NegativeResponeseDisplay(data);
}
#endregion
}
}