| | |
| | | static UDS_CONTOL_TYPE_e UDS_L_CommunicationControlType_e = EnableRxAndTx; |
| | | |
| | | static uint8_t UDS_L_SecurityFault_cnt; |
| | | static uint8_t UDS_L_SecurityStartDelay = 1; |
| | | static uint8_t UDS_L_SecurityStartDelay = 0; |
| | | static uint8_t UDS_L_SecurityAccessStep_e = SECURITY_ACCESS_STEP_MAX; |
| | | /*****************************************************************************/ |
| | | /* Local Variables Definition */ |
| | |
| | | static uint16_t ResponsePendingTimer_u16; |
| | | static bool UDS_L_TransferDataInProgressing_b = false; |
| | | static bool UDS_L_CRCCheckFail_b = false; |
| | | static uint32_t UDS_L_CRCReceived = 0; |
| | | static UDS_TRANFER_DATA_STATE_Te UDS_L_TransferDataState_e; |
| | | |
| | | static uint8_t expectedSequenceCnt; /* Block sequence counter */ |
| | |
| | | #define ROUTINE_CONTROL_MIN_LEN (0x04u) |
| | | #define TESTER_PRESENT_MIN_LEN (0x02u) |
| | | #define CONTROL_DTC_SETTING_MIN_LEN (0x02u) |
| | | #define REQUEST_DOWNLOAD_MIN_LEN (0xB) |
| | | #define TRANSFER_DATA_MIN_LEN (0XC) |
| | | #define REQUEST_TRANSFER_EXIT_MIN_LEN (0X01) |
| | | |
| | | typedef struct |
| | | { |
| | |
| | | uint8_t sid; |
| | | sid = msg_buf[0]; |
| | | |
| | | if (msg_dlc < 2) |
| | | { |
| | | result = false; |
| | | } |
| | | else |
| | | { |
| | | subfunction = UDS_GET_SUB_FUNCTION(msg_buf[1]); |
| | | |
| | | switch (sid) |
| | |
| | | } |
| | | } |
| | | break; |
| | | case REQUEST_DOWNLOAD: |
| | | if (msg_dlc == REQUEST_DOWNLOAD_MIN_LEN) |
| | | { |
| | | result = true; |
| | | } |
| | | else |
| | | { |
| | | result = false; |
| | | } |
| | | break; |
| | | case TRANSFER_DATA: |
| | | if (msg_dlc >= TRANSFER_DATA_MIN_LEN) |
| | | { |
| | | result = true; |
| | | } |
| | | else |
| | | { |
| | | result = false; |
| | | } |
| | | break; |
| | | case REQUEST_TRANSFER_EXIT: |
| | | result = true; |
| | | |
| | | break; |
| | | default: |
| | | result = false; |
| | | break; |
| | | } |
| | | } |
| | | return result; |
| | | } |
| | |
| | | TesterPresentTimer_u16 = 0; |
| | | UDS_NS_SessionTimeout_u16 = 5000; |
| | | UDS_L_SecurityFault_cnt = 0; |
| | | UDS_L_SecurityStartDelay = 1; |
| | | UDS_L_SecurityStartDelay = 0; |
| | | UDS_L_Diag_session_e = DEFAULT; |
| | | UDS_O_SecurityAccessState_e = SECURITY_ACCESS_LOCKED; |
| | | UDS_L_Current_SID = 0; |
| | |
| | | static void UDS_RxTask_1ms(void) |
| | | { |
| | | static TP_PDU_t msg_rx_temp = {0}; |
| | | |
| | | CAN_PDU_t msg_can_temp = {0}; |
| | | uint8_t msg_num = MCAN_GetReceiveMessageCounter(MCAN); |
| | | while (msg_num--) |
| | | { |
| | | MCAN_ReceiveData(MCAN, (MCAN_MsgTypeDef *)(&msg_rx_temp)); |
| | | MCAN_ReceiveData(MCAN, (MCAN_MsgTypeDef *)(&msg_can_temp)); |
| | | |
| | | msg_rx_temp.arbId = msg_can_temp.MCAN_ID; |
| | | msg_rx_temp.dlc = msg_can_temp.MCAN_DLC; |
| | | |
| | | for (TP_uint8_t i = 0; i < msg_can_temp.MCAN_DLC; i++) |
| | | { |
| | | msg_rx_temp.frame[i] = msg_can_temp.MCAN_Data[i]; |
| | | } |
| | | |
| | | if (msg_rx_temp.arbId == UDS_PHY_REQ_RID) |
| | | { |
| | | UDS_RxMessage(&msg_rx_temp); |
| | |
| | | |
| | | if (CDT_HASEXPIRED(TesterPresentTimer_u16) != false) |
| | | { |
| | | UDS_SwitchtoDefaultSession(true); |
| | | UDS_SwitchtoDefaultSession(false); |
| | | } |
| | | } |
| | | else |
| | | { |
| | | UDS_SwitchtoDefaultSession(true); |
| | | UDS_SwitchtoDefaultSession(false); |
| | | } |
| | | } |
| | | else |
| | |
| | | { |
| | | if (transferType == DOWNLOAD_FLASH) |
| | | { |
| | | UDS_L_CRCCheckFail_b = !MEM_PartitionCRCOK((uint8_t)MEM_PARTITION_CODEFLASH); |
| | | UDS_L_CRCCheckFail_b = !MEM_PartitionCRCOK((uint8_t)MEM_PARTITION_CODEFLASH, UDS_L_CRCReceived); |
| | | if (UDS_L_CRCCheckFail_b == false) |
| | | { |
| | | NVM_ReInitFlashDriveRam(); // CLEAR FLASH DRIVE IN RAM |
| | |
| | | } |
| | | else |
| | | { |
| | | UDS_L_CRCCheckFail_b = !MEM_PartitionCRCOK((uint8_t)MEM_PARTITION_RAM); |
| | | UDS_L_CRCCheckFail_b = !MEM_PartitionCRCOK((uint8_t)MEM_PARTITION_RAM, UDS_L_CRCReceived); |
| | | if (UDS_L_CRCCheckFail_b == true) |
| | | { |
| | | NVM_ReInitFlashDriveRam(); // CLEAR FLASH DRIVE IN RAM |
| | | } |
| | | } |
| | | if (UDS_L_CRCCheckFail_b == false) |
| | | { |
| | | UDS_L_tx_msg_buffer[0] = GET_RESPONSE_SERVICE_ID(ROUTINE_CONTROL); |
| | | UDS_L_tx_msg_buffer[1] = 0x01; |
| | | UDS_L_tx_msg_buffer[2] = 0xf0; |
| | |
| | | |
| | | UDS_L_ResponsePendingRequest_e &= (~CHECK_PROGRAMMING_INTERGRITY_PENDING); |
| | | UDS_L_ResponsePendingRelease_e &= (~CHECK_PROGRAMMING_INTERGRITY_PENDING); |
| | | } |
| | | } |
| | | } |
| | | } |
| | |
| | | FBL_UDS_L_ResponsePendingRelease_e &=(~CHECK_PROGRAMMING_INTERGRITY_PENDING); |
| | | } |
| | | #endif |
| | | |
| | | UDS_L_CRCReceived = (uint32_t)payload[4] << 24 | (uint32_t)payload[5] << 16 | (uint32_t)payload[6] << 8 | (uint32_t)payload[7]; |
| | | UDS_L_ResponsePendingRequest_e |= CHECK_PROGRAMMING_INTERGRITY_PENDING; |
| | | CDT_RESET(ResponsePendingTimer_u16, P2SERVER_PENDING_TIMEROUT); |
| | | } |