Commit 7b12dfa0 authored by 张明扬's avatar 张明扬 🇨🇳

feat:增加2E服务对UUID的写入

parent cd6f8c18
...@@ -50,6 +50,7 @@ static void Power_KL30_Init(void) ...@@ -50,6 +50,7 @@ static void Power_KL30_Init(void)
Can_Init(); Can_Init();
CAN_TX_SetEnable(&CAN_CH0_CanMsgTxOp, CAN_N_TX_Enable); CAN_TX_SetEnable(&CAN_CH0_CanMsgTxOp, CAN_N_TX_Enable);
DFlash_init(); DFlash_init();
Data_Read_DiagPara();
Analog_Signal_Conv_Init(); Analog_Signal_Conv_Init();
BU98R10_Init(); BU98R10_Init();
//Uart0_Init(115200); //Uart0_Init(115200);
......
...@@ -213,6 +213,8 @@ void UDS_Process_Service_Request(void) ...@@ -213,6 +213,8 @@ void UDS_Process_Service_Request(void)
break; break;
case 0x22: UDS_Service_22_Indication(UDS_APP_RX.A_PDU.TA_type, UDS_APP_RX.A_PDU.Length, UDS_APP_RX.A_PDU.Data); case 0x22: UDS_Service_22_Indication(UDS_APP_RX.A_PDU.TA_type, UDS_APP_RX.A_PDU.Length, UDS_APP_RX.A_PDU.Data);
break; break;
case 0x2E: UDS_Service_2E_Indication(UDS_APP_RX.A_PDU.TA_type, UDS_APP_RX.A_PDU.Length, UDS_APP_RX.A_PDU.Data);
break;
case 0x27: UDS_Service_27_Indication(UDS_APP_RX.A_PDU.TA_type, UDS_APP_RX.A_PDU.Length, UDS_APP_RX.A_PDU.Data); case 0x27: UDS_Service_27_Indication(UDS_APP_RX.A_PDU.TA_type, UDS_APP_RX.A_PDU.Length, UDS_APP_RX.A_PDU.Data);
break; break;
case 0x28: UDS_Service_28_Indication(UDS_APP_RX.A_PDU.TA_type, UDS_APP_RX.A_PDU.Length, UDS_APP_RX.A_PDU.Data); case 0x28: UDS_Service_28_Indication(UDS_APP_RX.A_PDU.TA_type, UDS_APP_RX.A_PDU.Length, UDS_APP_RX.A_PDU.Data);
......
...@@ -43,6 +43,7 @@ DiagSendDataNeg NegRes; ...@@ -43,6 +43,7 @@ DiagSendDataNeg NegRes;
uint8_t UDS_ISO14229_Transfer[250]; uint8_t UDS_ISO14229_Transfer[250];
DiagDFlashData DiagDataForDFlash; DiagDFlashData DiagDataForDFlash;
Ser2EDFlashData Ser2EDataForDFlash;
DiagFlag DiagDataForFlag; DiagFlag DiagDataForFlag;
Ser27_FlowCtrlCntUnion Ser27_FlowCtrlCnt; Ser27_FlowCtrlCntUnion Ser27_FlowCtrlCnt;
uint8_t FlashDriverCheckSum = 0; uint8_t FlashDriverCheckSum = 0;
...@@ -160,6 +161,15 @@ void DFlash_init(void) ...@@ -160,6 +161,15 @@ void DFlash_init(void)
} }
} }
void Data_Read_DiagPara(void)
{
uint8_t i;
Ser2EDFlashData* ReadSer2EDataForDFlash = (Ser2EDFlashData*)0x500600ul;
for ( i = 0; i < 32; i++)
{
Ser2EDataForDFlash.DID_F184[i] = ReadSer2EDataForDFlash->DID_F184[i];
}
}
void S3_ServerCNTT(void) void S3_ServerCNTT(void)
{ {
if ( Wait10sFlag == 1 ) if ( Wait10sFlag == 1 )
...@@ -673,7 +683,7 @@ static const uint8_t Ser22BanResponse = DisableResponseType; ...@@ -673,7 +683,7 @@ static const uint8_t Ser22BanResponse = DisableResponseType;
static const uint8_t Ser22Sub [] = {0xFF}; static const uint8_t Ser22Sub [] = {0xFF};
static const uint8_t Ser22MinLen [] = {2}; static const uint8_t Ser22MinLen [] = {2};
static const uint8_t Ser22SubLen [] = {2}; static const uint8_t Ser22SubLen [] = {2};
static const uint16_t Ser22DIDList [] = {0xF195, 0xF193, 0xF180, 0xF187, 0x1024, 0x1028}; static const uint16_t Ser22DIDList [] = {0xF195, 0xF193, 0xF180, 0xF187, 0x1024, 0x1028, 0xF184 };
static const uint8_t Ser22UnlockLevel [] = {NoNeed}; static const uint8_t Ser22UnlockLevel [] = {NoNeed};
static const uint8_t Ser22SupportSession = DefaultMode | ProgrammingMode | ExtendedDiagnosticMode; static const uint8_t Ser22SupportSession = DefaultMode | ProgrammingMode | ExtendedDiagnosticMode;
static const uint8_t Ser22SubSupportSession [] = {DefaultMode | ProgrammingMode | ExtendedDiagnosticMode}; static const uint8_t Ser22SubSupportSession [] = {DefaultMode | ProgrammingMode | ExtendedDiagnosticMode};
...@@ -809,6 +819,14 @@ void UDS_Service_22_Indication(uint16_t A_TA_type, uint16_t A_Length, uint8_t *A ...@@ -809,6 +819,14 @@ void UDS_Service_22_Indication(uint16_t A_TA_type, uint16_t A_Length, uint8_t *A
UDS_Service_Response(si, POSITIVE_RSP, DIAG_ID_Tx, 2 + 8, UDS_ISO14229_Transfer); UDS_Service_Response(si, POSITIVE_RSP, DIAG_ID_Tx, 2 + 8, UDS_ISO14229_Transfer);
break; break;
case 0xF184: // UUID
for (i = 0; i < 32; i++)
{
UDS_ISO14229_Transfer[i + 2] = Ser2EDataForDFlash.DID_F184[i];
}
UDS_Service_Response(0x22, POSITIVE_RSP, DIAG_ID_Tx, 2 + 32, UDS_ISO14229_Transfer);
break;
default: default:
if (FunorPhy == DIAG_ID_Rx_FUN) if (FunorPhy == DIAG_ID_Rx_FUN)
{ {
...@@ -839,6 +857,74 @@ void UDS_Service_22_Indication(uint16_t A_TA_type, uint16_t A_Length, uint8_t *A ...@@ -839,6 +857,74 @@ void UDS_Service_22_Indication(uint16_t A_TA_type, uint16_t A_Length, uint8_t *A
} }
} }
void UDS_Service_2E_Indication ( uint16_t A_TA_type, uint16_t A_Length, uint8_t *A_Data )
{
uint16_t i;
uint16_t DID;
uint8_t Data[8];
uint8_t Service2EDiagDataLength;
uint16_t FunorPhy = 0;
Service2EDiagDataLength = A_Length;
S3_ServerCnt = 0;
FunorPhy = A_TA_type;
for (i = 0; i < Service2EDiagDataLength; ++i)
{
UDS_ISO14229_Transfer[i] = *(A_Data + i);
}
if ( FunorPhy == 0X7DF )
return;
if ( DiagLockFlag == 0x00 )
{
NegRes.code = securityAccessDenied; //NRC33
UDS_Service_Response ( 0x2E, NEGATIVE_RSP, DIAG_ID_Tx, 1, ( uint8_t * ) ( &NegRes.code ) );
return;
}
if ( Service2EDiagDataLength < 3 )
{
NegRes.code = incorrectMessageLength; //NRC13
UDS_Service_Response ( 0x2E, NEGATIVE_RSP, DIAG_ID_Tx, 1, ( uint8_t * ) ( &NegRes.code ) );
return;
}
if( (SessionType == DefaultSession) || (SessionType == ProgrammingSession))
{
NegRes.code = serviceNotSupportedInActiveSession; //NRC7F
UDS_Service_Response ( 0x2E, NEGATIVE_RSP, DIAG_ID_Tx, 1, ( uint8_t * ) ( &NegRes.code ) );
return;
}
DID = ((uint16_t)UDS_ISO14229_Transfer[0] << 8) | ((uint16_t)UDS_ISO14229_Transfer[1]);
switch ( DID )
{
case 0xF184: // 读指纹数据标识符
for (i = 0; i < 33; i++)
{
Data[i] = UDS_ISO14229_Transfer[i+2];
}
for (i = 0; i < (sizeof(Ser2EDataForDFlash.DID_F184)); i++)
{
Ser2EDataForDFlash.DID_F184[i] = Data[i];
}
Ser2EDataForDFlash.Flag = 0x5AA5A77Au;
// memcpy(Ser2EDataForDFlash.DID_F184, Data, sizeof(Ser2EDataForDFlash.DID_F184));
//擦除扇区
EraseSector (0x500600ul);
//App程序状态和22服务数据全写进去
ProgramPage (0x500600ul, sizeof(Ser2EDataForDFlash), (uint8_t *)(&Ser2EDataForDFlash));
UDS_Service_Response(0x2E, POSITIVE_RSP, DIAG_ID_Tx, 2, UDS_ISO14229_Transfer);
break;
default:
if ( FunorPhy == 0x7df )
{
return;
}
NegRes.code = requestOutOfRange;
UDS_Service_Response ( 0x2E, NEGATIVE_RSP, DIAG_ID_Tx, 1, ( uint8_t * ) ( &NegRes.code ) );
break;
}
}
void GetSeed(void) void GetSeed(void)
{ {
uint8_t SeedHigh; uint8_t SeedHigh;
......
...@@ -347,6 +347,14 @@ typedef struct ...@@ -347,6 +347,14 @@ typedef struct
uint8_t Filldata[1]; uint8_t Filldata[1];
}DiagDFlashData; }DiagDFlashData;
extern DiagDFlashData DiagDataForDFlash; extern DiagDFlashData DiagDataForDFlash;
typedef struct
{
uint32_t Flag;
uint8_t DID_F184[32];
} Ser2EDFlashData;
extern Ser2EDFlashData Ser2EDataForDFlash;
typedef struct typedef struct
{ {
uint32_t Flag; uint32_t Flag;
...@@ -364,6 +372,7 @@ typedef struct ...@@ -364,6 +372,7 @@ typedef struct
void UDS_Service_10_Indication(uint16_t A_TA_type, uint16_t A_Length, uint8_t *A_Data); void UDS_Service_10_Indication(uint16_t A_TA_type, uint16_t A_Length, uint8_t *A_Data);
void UDS_Service_11_Indication(uint16_t A_TA_type, uint16_t A_Length, uint8_t *A_Data); void UDS_Service_11_Indication(uint16_t A_TA_type, uint16_t A_Length, uint8_t *A_Data);
void UDS_Service_22_Indication(uint16_t A_TA_type, uint16_t A_Length, uint8_t *A_Data); void UDS_Service_22_Indication(uint16_t A_TA_type, uint16_t A_Length, uint8_t *A_Data);
void UDS_Service_2E_Indication(uint16_t A_TA_type, uint16_t A_Length, uint8_t *A_Data);
void UDS_Service_27_Indication(uint16_t A_TA_type, uint16_t A_Length, uint8_t *A_Data); void UDS_Service_27_Indication(uint16_t A_TA_type, uint16_t A_Length, uint8_t *A_Data);
void UDS_Service_28_Indication(uint16_t A_TA_type, uint16_t A_Length, uint8_t *A_Data); void UDS_Service_28_Indication(uint16_t A_TA_type, uint16_t A_Length, uint8_t *A_Data);
void UDS_Service_3E_Indication(uint16_t A_TA_type, uint16_t A_Length, uint8_t *A_Data); void UDS_Service_3E_Indication(uint16_t A_TA_type, uint16_t A_Length, uint8_t *A_Data);
...@@ -389,6 +398,7 @@ uint8_t SerXXNRC7EFilter(const uint8_t *SubSupportSession, uint8_t index); ...@@ -389,6 +398,7 @@ uint8_t SerXXNRC7EFilter(const uint8_t *SubSupportSession, uint8_t index);
uint8_t SerXXNRC7FFilter(uint8_t SupportSession); uint8_t SerXXNRC7FFilter(uint8_t SupportSession);
extern void Data_Set_DiagPara(void); extern void Data_Set_DiagPara(void);
void Write_App_InValid(uint32_t m32); void Write_App_InValid(uint32_t m32);
void Data_Read_DiagPara(void);
void DFlash_init(void); void DFlash_init(void);
#endif #endif
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