Commit d771d74a authored by hu's avatar hu

调整K-LING密钥随机数计算方式

parent 741d792b
......@@ -14,16 +14,12 @@
* structure
*********************************************************************
*/
#define TEST_TYPE 0
/*
*********************************************************************
* variable
*********************************************************************
*/
Kwp2000_Negative_t Kwp2000_Negative;
_K_LINE_SIGNAL_FLAG K_LINE_SIGNAL_FLAG;
unsigned char Sendseed1;
unsigned char Sendseed2;
unsigned char Sendseed3;
......@@ -41,11 +37,19 @@ unsigned char DTCstatusCHGFFK_Line = 0u;
unsigned char AccessMode2701KeyTimeFlag;
unsigned char AccessMode2701KeyTime;
unsigned long EOLSeedRandomNumber = 0x727u;
#pragma alignvar(8)
_ECUStatus ECUStatusONE;
#pragma alignvar(8)
_EOL_K_LINE_SET K_Line_Set;
#pragma alignvar(8)
Kwp2000_Negative_t Kwp2000_Negative;
#pragma alignvar(8)
_K_LINE_SIGNAL_FLAG K_LINE_SIGNAL_FLAG;
#pragma ghs section bss=".myNonInitArea"
unsigned long SeedKey = 0;
unsigned long EOLSeedRandomNumber = 0x727u;
#pragma ghs section bss=default
/*
*********************************************************************
* function
......@@ -1118,7 +1122,6 @@ unsigned char kwp_readDataByCommonIdentifier(unsigned char *TxData, unsigned cha
--------------------------------------------------------------------------*/
unsigned char kwp_readDataAccessMode(unsigned char *TxData, unsigned char *RequestData)
{
static unsigned long SeedKey = 0;
unsigned char Tx_Len = 0;
switch (RequestData[0]) /* subFunction */
......@@ -1127,8 +1130,8 @@ unsigned char kwp_readDataAccessMode(unsigned char *TxData, unsigned char *Reque
if (K_Line_Set.KLINE == 1)/*是否锁定标记*/
{
/*密钥随机数生成*/
SeedKey = EOLSeedRandomNumber * 1103515245ul + 12345u;
//SeedKey = (unsigned long)EOLSeedRandomNumber;
EOLSeedRandomNumber = (unsigned long)(EOLSeedRandomNumber * 1103515245ul + 12345u);
SeedKey = (unsigned long)EOLSeedRandomNumber;
//SeedKey = SeedKey << 16;
//SeedKey |= (unsigned long)(~EOLSeedRandomNumber);
......@@ -1450,6 +1453,7 @@ void Common_Set_DTCstatusCHGFFK_Flag(unsigned char Val)
* Return : None
* onther :
--------------------------------------------------------------------------*/
#if TEST_TYPE == 0
void K_LINE_EOL_InitVal(void)
{
K_Line_Set.Flag = 0x7AA7A55Au;
......@@ -1529,4 +1533,86 @@ void K_LINE_EOL_InitVal(void)
K_Line_Set.TesterECUCAN = 0x00u; /* 20 */
K_Line_Set.User_Light1 = 10u; /*背光亮度等级*/
K_Line_Set.User_Light2 = 10u; /*背光亮度等级*/
}
\ No newline at end of file
}
#else
void K_LINE_EOL_InitVal(void)
{
K_Line_Set.Flag = 0x7AA7A55Bu;
K_Line_Set.K_Line_LID20 = 0x00u; /* 00 应对ECE R13 //0:非应对、1:应对 */
K_Line_Set.K_Line_LID21 = 0x01u; /* 00 EBS/ABS //0:无、1:EBS、2:ABS(CAN应对) 3:ABS (CAN非应对) */
K_Line_Set.K_Line_LID22 = 0x01u; /* 00 EVSC //0:无、1:有 */
K_Line_Set.K_Line_LID23 = 0x00u; /* 00 驻车锁定 //0:无、1:有 */
K_Line_Set.K_Line_LID24 = 0x00u; /* 00 HSA //0:无、1:有 */
K_Line_Set.K_Line_LID25 = 0x00u; /* 00 AEBS //0:无、1:有 */
K_Line_Set.K_Line_LID26 = 0x00u; /* 00 ACC //0:无、1:有 */
K_Line_Set.K_Line_LID27 = 0x01u; /* 00 LDWS //0:无、1:有 */
K_Line_Set.K_Line_LID28 = 0x01u; /* 01 车辆间报警 //0:无、1:有 */
K_Line_Set.K_Line_LID29 = 0x01u; /* 01 有无巡航 //0:无、1:有 /*初值1*/
K_Line_Set.K_Line_LID2A = 0x01u; /* 00 气悬 //0:Reef、1:Rear air、2:Full air */
K_Line_Set.K_Line_LID2B = 0x00u; /* 00 ISS //0:无、1: eco stop、 2:Idle Stop */
K_Line_Set.K_Line_LID2C = 0x01u; /* 00 装货台工作警报蜂鸣 //0:无、1:有 */
K_Line_Set.K_Line_LID2D = 0x00u; /* 00 ROWS //0:无、1:ROWS有、2LOCAL警报有 */
K_Line_Set.K_Line_LID2E = 0x00u; /* 00 行车记录仪 //0:模拟记录仪、1:数字记录仪或行车记录仪 */
K_Line_Set.K_Line_LID2F = 0x00u; /* 00 车型 //0:单车、1:拖车、2:全拖车 */
K_Line_Set.K_Line_LID30 = 0x00u; /* 00 缓速器 //0:无、1:有(C&E)、2:有(F) */
K_Line_Set.K_Line_LID31 = 0x01u; /* -- 定速巡航 //0:无、1:有 */
K_Line_Set.K_Line_LID32 = 0x00u; /* 00 装货台种类 //0:一般、1:侧翼、2:倾倒 */
K_Line_Set.K_Line_LID33 = 0x00u; /* 01 SCR?DPD //0:SCR无/DPD有、1:SCR有/DPD有、2:SCR无/DPD无、3:SCR有/DPD无 /*初值1*/
K_Line_Set.K_Line_LID34 = 0x00u; /* 00 驻车种类 //0:FULL AIR、1:AOH /*初值1*/
K_Line_Set.K_Line_LID35 = 0x00u; /* -- 气压计 //0:2针式、1:1针式 */
K_Line_Set.K_Line_LID36 = 0x00u; /* -- 低压警报压 //0:一般输出(539kPa)、1:ADR(588kPa) */
K_Line_Set.K_Line_LID37 = 0x01u; /* -- 超限警报 //0:无、1:有 */
K_Line_Set.K_Line_LID38 = 0x01u; /* -- 速度警报 //0:无、1:有 */
K_Line_Set.K_Line_LID39 = 0x01u; /* 00 可变SLD //0:无、1:1车速、2:2车速 /*初值1*/
K_Line_Set.K_Line_LID3A = 0x00u; /* -- OEM //0:ISZ、1:UDT */
K_Line_Set.K_Line_LID3B = 0x00u; /* -- 预留 */
K_Line_Set.K_Line_LID3C = 0x00u; /* -- 预留 */
K_Line_Set.K_Line_LID3D = 0x00u; /* -- 预留 */
K_Line_Set.K_Line_LID3E = 0x01u; /* 01 胎压匹配功能 //0:胎压功能未匹配 1:匹配 */
K_Line_Set.K_Line_LID3F = 0x00u; /* -- 预留 */
K_Line_Set.K_Line_LID40 = 0x00u; /* 00 发动机种类 */
K_Line_Set.K_Line_LID41 = 0x13u; /* 50 变速器种类&控制 /*初值50*/
K_Line_Set.K_Line_LID42 = 0x00u; /* 00 驻车管道 /*初值 0*/
K_Line_Set.K_Line_LID43 = 0x82u; /* 82 车型 /*初值44*/
K_Line_Set.K_Line_LID44 = 0xFFu; /* FF 速度警报 /*初值FF*/
K_Line_Set.K_Line_LID45 = 0xFFu; /* FF 发动机转速 /*初值FF*/
K_Line_Set.K_Line_LID46 = 0xFFu; /* FF 急加速 /*初FF*/
K_Line_Set.K_Line_LID47 = 0xFFu; /* FF 急减速 /*初值FF*/
K_Line_Set.K_Line_LID48 = 0xFFu; /* FF 长时间怠速 /*初值FF*/
K_Line_Set.K_Line_LID49 = 0xFFu; /* FF 辅助驻车 /*初值FF*/
K_Line_Set.K_Line_LID4A = 0x32u; /* 37 变速箱油 55000 */
K_Line_Set.K_Line_LID4B = 0x32u; /* 37 差速器油 55000 */
K_Line_Set.K_Line_LID4C = 0x32u; /* 37 离合器油 55000 */
K_Line_Set.K_Line_LID4D = 0x64u; /* 37 动力转向油 55000 */
K_Line_Set.K_Line_LID4E = 0x3Cu; /* 32 轮胎 50000 */
K_Line_Set.K_Line_LID4F = 0x1Eu; /* 34 机油&滤清器 22000 */
K_Line_Set.K_Line_LID50 = 0x00u; /* -- 预留 */
K_Line_Set.K_Line_LID51 = 0x01u; /* 01 工作模式 */
K_Line_Set.K_Line_LID52 = 0x00u; /* 00 电子部件设定 */
K_Line_Set.KLINE = 0x00u;
K_Line_Set.No_Digit1 = 0x38u; /* 01 */
K_Line_Set.No_Digit2 = 0x39u; /* 02 */
K_Line_Set.No_Digit3 = 0x38u; /* 03 */
K_Line_Set.No_Digit4 = 0x31u; /* 04 */
K_Line_Set.No_Digit5 = 0x38u; /* 05 */
K_Line_Set.No_Digit6 = 0x30u; /* 06 */
K_Line_Set.No_Digit7 = 0x36u; /* 07 */
K_Line_Set.No_Digit8 = 0x35u; /* 08 */
K_Line_Set.No_Digit9 = 0x33u; /* 09 */
K_Line_Set.No_Digit10 = 0x30u; /* 10 */
K_Line_Set.ECUStatus1 = 0x00u; /* 11 */
K_Line_Set.ECUStatus2 = 0x00u; /* 12 */
K_Line_Set.ECUStatus3 = 0x00u; /* 13 */
K_Line_Set.ECUStatus4 = 0x00u; /* 14 */
K_Line_Set.ECUStatus5 = 0x00u; /* 15 */
K_Line_Set.METERCOUNT = 0x00u; /* 16 */
K_Line_Set.NoOfDTCFF00 = 0x00u; /* 17 */
K_Line_Set.NoOfDTC8000 = 0x00u; /* 18 */
K_Line_Set.TesterECU = 0x00u; /* 19 */
K_Line_Set.TesterECUCAN = 0x00u; /* 20 */
K_Line_Set.User_Light1 = 10u; /*背光亮度等级*/
K_Line_Set.User_Light2 = 10u; /*背光亮度等级*/
}
#endif
\ No newline at end of file
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment