Files

79 lines
2.2 KiB
C
Raw Permalink Normal View History

2025-07-22 11:15:46 +08:00
/*
*
* SPDX-License-Identifier: Apache-2.0
*
*/
#include "SID11_EcuReset.h"
#include "service_cfg.h"
#include "uds_def.h"
2025-10-21 13:59:50 +08:00
typedef enum __UDS_RESET_T_ {
UDS_RESET_NONE = 0,
UDS_RESET_HARD,
UDS_RESET_KEYOFFON,
UDS_RESET_SOFT
} uds_reset_t;
2025-07-22 11:15:46 +08:00
/******************************************************************************
* : bool_t service_11_check_len(const uint8_t* msg_buf, uint16_t msg_dlc)
* : 11
* : uint16_t msg_dlc --
* :
* : TRUE: ; FALSE:
* :
******************************************************************************/
2025-10-21 13:59:50 +08:00
bool_t service_11_check_len(const uint8_t *msg_buf, uint16_t msg_dlc)
2025-07-22 11:15:46 +08:00
{
2025-10-21 13:59:50 +08:00
bool_t ret = FALSE;
(void)msg_buf;
if (2 == msg_dlc)
ret = TRUE;
2025-07-22 11:15:46 +08:00
2025-10-21 13:59:50 +08:00
return ret;
2025-07-22 11:15:46 +08:00
}
/******************************************************************************
* : void service_11_EcuReset(const uint8_t* msg_buf, uint16_t msg_dlc)
* : 11 - ECU
* : uint8_t* msg_buf --
    uint8_t msg_dlc --
* :
* :
* :
******************************************************************************/
2025-10-21 13:59:50 +08:00
void service_11_EcuReset(const uint8_t *msg_buf, uint16_t msg_dlc)
2025-07-22 11:15:46 +08:00
{
uint8_t subfunction;
2025-10-21 13:59:50 +08:00
uint8_t rsp_buf[8];
2025-07-22 11:15:46 +08:00
2025-10-21 13:59:50 +08:00
subfunction = UDS_GET_SUB_FUNCTION(msg_buf[1]);
2025-07-22 11:15:46 +08:00
2025-10-21 13:59:50 +08:00
switch (subfunction) {
case UDS_RESET_HARD:
rsp_buf[0] = USD_GET_POSITIVE_RSP(SID_11);
rsp_buf[1] = UDS_RESET_HARD;
uds_positive_rsp(rsp_buf, 2);
2025-07-22 11:15:46 +08:00
2025-10-21 13:59:50 +08:00
// Wait a moment for hard reset
// Add hard reset here
break;
2025-07-22 11:15:46 +08:00
2025-10-21 13:59:50 +08:00
case UDS_RESET_SOFT:
rsp_buf[0] = USD_GET_POSITIVE_RSP(SID_11);
rsp_buf[1] = UDS_RESET_SOFT;
uds_positive_rsp(rsp_buf, 2);
// Wait a moment for hard reset
// Add soft reset here
break;
2025-07-22 11:15:46 +08:00
2025-10-21 13:59:50 +08:00
default:
uds_negative_rsp(SID_11, NRC_SUBFUNCTION_NOT_SUPPORTED);
break;
}
}
2025-07-22 11:15:46 +08:00
/****************EOF****************/