20241222更改
This commit is contained in:
parent
46299f42d1
commit
a86024c223
@ -1,90 +0,0 @@
|
||||
/*
|
||||
* Copyright (c) 2022, Shenzhen CVA Innovation CO.,LTD
|
||||
* All rights reserved.
|
||||
*
|
||||
* Shenzhen CVA Innovation CO.,LTD (CVA chip) is supplying this file for use
|
||||
* exclusively with CVA's microcontroller products. This file can be freely
|
||||
* distributed within development tools that are supporting such microcontroller
|
||||
* products.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED "AS IS". NO WARRANTIES, WHETHER EXPRESS, IMPLIED
|
||||
* OR STATUTORY, INCLUDING, BUT NOT LIMITED TO, IMPLIED WARRANTIES OF
|
||||
* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE APPLY TO THIS SOFTWARE.
|
||||
* CVA SHALL NOT, IN ANY CIRCUMSTANCES, BE LIABLE FOR SPECIAL, INCIDENTAL,
|
||||
* OR CONSEQUENTIAL DAMAGES, FOR ANY REASON WHATSOEVER.
|
||||
*/
|
||||
|
||||
/*******************************************************************************
|
||||
* the includes
|
||||
******************************************************************************/
|
||||
|
||||
#include "uds_service10.h"
|
||||
|
||||
|
||||
/*******************************************************************************
|
||||
* the defines
|
||||
******************************************************************************/
|
||||
|
||||
/*******************************************************************************
|
||||
* the typedefs
|
||||
******************************************************************************/
|
||||
|
||||
/*******************************************************************************
|
||||
* the globals
|
||||
******************************************************************************/
|
||||
|
||||
/*******************************************************************************
|
||||
* the constants
|
||||
******************************************************************************/
|
||||
|
||||
/*******************************************************************************
|
||||
* the functions
|
||||
******************************************************************************/
|
||||
|
||||
void UdsService10_SessionControl(UdsType *obj, const uint8_t msgBuf[], uint16_t msgLen)
|
||||
{
|
||||
uint8_t subFunction;
|
||||
uint8_t rspBuffer[8] = {0}; /* polyspace DEFECT:PARTIALLY_ACCESSED_ARRAY [No action planned:Low] "Still keep default though member6~7 is not written" */
|
||||
|
||||
if(msgLen != obj->seviceTable[obj->curServiceIdx].minLen)
|
||||
{
|
||||
Uds_NegativeResponse(obj, 0x10, NRC_INVALID_MESSAGE_LENGTH_OR_FORMAT);
|
||||
return;
|
||||
}
|
||||
|
||||
subFunction = UDS_GET_SUB_FUNCTION (msgBuf[1]);
|
||||
|
||||
rspBuffer[0] = UDS_GET_POSITIVE_RSP(0x10);
|
||||
rspBuffer[1] = subFunction;
|
||||
rspBuffer[2] = (uint8_t)(obj->p2Server_ms >> 8);
|
||||
rspBuffer[3] = (uint8_t)(obj->p2Server_ms & 0x00ff);
|
||||
rspBuffer[4] = (uint8_t)(obj->p2xServer_10ms >> 8);
|
||||
rspBuffer[5] = (uint8_t)(obj->p2xServer_10ms & 0x00ff);
|
||||
switch(subFunction)
|
||||
{
|
||||
case UDS_SESSION_DEFAULT:
|
||||
obj->securityLevel = UDS_SA_NONE;
|
||||
obj->session = subFunction;
|
||||
Uds_PositiveResponse(obj, rspBuffer, 6);
|
||||
break;
|
||||
case UDS_SESSION_EXTENDED:
|
||||
obj->securityLevel = UDS_SA_NONE;
|
||||
obj->session = subFunction;
|
||||
Uds_PositiveResponse(obj, rspBuffer, 6);
|
||||
break;
|
||||
case UDS_SESSION_PROGRAMMING:
|
||||
obj->securityLevel = UDS_SA_NONE;
|
||||
obj->session = subFunction;
|
||||
Uds_PositiveResponse(obj, rspBuffer, 6);
|
||||
break;
|
||||
case UDS_SESSION_SAFTY:
|
||||
obj->securityLevel = UDS_SA_NONE;
|
||||
obj->session = subFunction;
|
||||
Uds_PositiveResponse(obj, rspBuffer, 6);
|
||||
break;
|
||||
default:
|
||||
Uds_NegativeResponse(obj, 0x10, NRC_SUBFUNCTION_NOT_SUPPORTED);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
@ -1,60 +0,0 @@
|
||||
/*
|
||||
* Copyright (c) 2022, Shenzhen CVA Innovation CO.,LTD
|
||||
* All rights reserved.
|
||||
*
|
||||
* Shenzhen CVA Innovation CO.,LTD (CVA chip) is supplying this file for use
|
||||
* exclusively with CVA's microcontroller products. This file can be freely
|
||||
* distributed within development tools that are supporting such microcontroller
|
||||
* products.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED "AS IS". NO WARRANTIES, WHETHER EXPRESS, IMPLIED
|
||||
* OR STATUTORY, INCLUDING, BUT NOT LIMITED TO, IMPLIED WARRANTIES OF
|
||||
* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE APPLY TO THIS SOFTWARE.
|
||||
* CVA SHALL NOT, IN ANY CIRCUMSTANCES, BE LIABLE FOR SPECIAL, INCIDENTAL,
|
||||
* OR CONSEQUENTIAL DAMAGES, FOR ANY REASON WHATSOEVER.
|
||||
*/
|
||||
|
||||
#ifndef _UDS_SERVICE10_H_
|
||||
#define _UDS_SERVICE10_H_
|
||||
|
||||
/*! \brief Contains public interface to various functions related
|
||||
* to the user-defined UDS service 10
|
||||
*/
|
||||
|
||||
/*******************************************************************************
|
||||
* the includes
|
||||
******************************************************************************/
|
||||
|
||||
#include <stdbool.h>
|
||||
#include <stdint.h>
|
||||
#include "../stack/uds.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/*******************************************************************************
|
||||
* the defines
|
||||
******************************************************************************/
|
||||
|
||||
/*******************************************************************************
|
||||
* the typedefs
|
||||
******************************************************************************/
|
||||
|
||||
/*******************************************************************************
|
||||
* the globals
|
||||
******************************************************************************/
|
||||
|
||||
/*******************************************************************************
|
||||
* the function prototypes
|
||||
******************************************************************************/
|
||||
|
||||
/*! \brief Uds Service 10 processing
|
||||
*/
|
||||
extern void UdsService10_SessionControl(UdsType *obj, const uint8_t msgBuf[], uint16_t msgLen);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif /* extern "C" */
|
||||
|
||||
#endif /* _UDS_SERVICE10_H_ */
|
@ -1,91 +0,0 @@
|
||||
/*
|
||||
* Copyright (c) 2022, Shenzhen CVA Innovation CO.,LTD
|
||||
* All rights reserved.
|
||||
*
|
||||
* Shenzhen CVA Innovation CO.,LTD (CVA chip) is supplying this file for use
|
||||
* exclusively with CVA's microcontroller products. This file can be freely
|
||||
* distributed within development tools that are supporting such microcontroller
|
||||
* products.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED "AS IS". NO WARRANTIES, WHETHER EXPRESS, IMPLIED
|
||||
* OR STATUTORY, INCLUDING, BUT NOT LIMITED TO, IMPLIED WARRANTIES OF
|
||||
* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE APPLY TO THIS SOFTWARE.
|
||||
* CVA SHALL NOT, IN ANY CIRCUMSTANCES, BE LIABLE FOR SPECIAL, INCIDENTAL,
|
||||
* OR CONSEQUENTIAL DAMAGES, FOR ANY REASON WHATSOEVER.
|
||||
*/
|
||||
|
||||
/*******************************************************************************
|
||||
* the includes
|
||||
******************************************************************************/
|
||||
|
||||
#include "uds_service11.h"
|
||||
|
||||
/*******************************************************************************
|
||||
* the defines
|
||||
******************************************************************************/
|
||||
|
||||
/*******************************************************************************
|
||||
* the typedefs
|
||||
******************************************************************************/
|
||||
|
||||
/*! \brief The Reset type definition of Uds
|
||||
*/
|
||||
typedef enum _UdsResetType_
|
||||
{
|
||||
UDS_RESET_NONE = 0,
|
||||
UDS_RESET_HARD,
|
||||
UDS_RESET_KEYOFFON,
|
||||
UDS_RESET_SOFT
|
||||
} UdsResetType;
|
||||
|
||||
/*******************************************************************************
|
||||
* the globals
|
||||
******************************************************************************/
|
||||
|
||||
/*******************************************************************************
|
||||
* the constants
|
||||
******************************************************************************/
|
||||
|
||||
/*******************************************************************************
|
||||
* the functions
|
||||
******************************************************************************/
|
||||
|
||||
void UdsService11_ResetEcu(UdsType *obj, const uint8_t msgBuf[], uint16_t msgLen)
|
||||
{
|
||||
uint8_t subFunction;
|
||||
uint8_t rspBuffer[8] = {0}; /* polyspace DEFECT:PARTIALLY_ACCESSED_ARRAY [No action planned:Low] "Still keep default though member3~7 is not written" */
|
||||
uint8_t powerDownTime = 0xFF;
|
||||
|
||||
if(msgLen != obj->seviceTable[obj->curServiceIdx].minLen)
|
||||
{
|
||||
Uds_NegativeResponse(obj, 0x11, NRC_INVALID_MESSAGE_LENGTH_OR_FORMAT);
|
||||
return;
|
||||
}
|
||||
|
||||
subFunction = UDS_GET_SUB_FUNCTION(msgBuf[1]);
|
||||
|
||||
rspBuffer[0] = UDS_GET_POSITIVE_RSP(0x11);
|
||||
rspBuffer[1] = subFunction;
|
||||
rspBuffer[2] = powerDownTime;
|
||||
switch(subFunction)
|
||||
{
|
||||
case UDS_RESET_HARD:
|
||||
Uds_PositiveResponse(obj, rspBuffer, 3);
|
||||
/*add hardware reset code*/
|
||||
|
||||
break;
|
||||
case UDS_RESET_KEYOFFON:
|
||||
Uds_PositiveResponse(obj, rspBuffer, 3);
|
||||
/*add keyoffon reset code*/
|
||||
|
||||
break;
|
||||
case UDS_RESET_SOFT:
|
||||
Uds_PositiveResponse(obj, rspBuffer, 3);
|
||||
/*add software reset code*/
|
||||
|
||||
break;
|
||||
default:
|
||||
Uds_NegativeResponse(obj, 0x11, NRC_SUBFUNCTION_NOT_SUPPORTED);
|
||||
break;
|
||||
}
|
||||
}
|
@ -1,59 +0,0 @@
|
||||
/*
|
||||
* Copyright (c) 2022, Shenzhen CVA Innovation CO.,LTD
|
||||
* All rights reserved.
|
||||
*
|
||||
* Shenzhen CVA Innovation CO.,LTD (CVA chip) is supplying this file for use
|
||||
* exclusively with CVA's microcontroller products. This file can be freely
|
||||
* distributed within development tools that are supporting such microcontroller
|
||||
* products.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED "AS IS". NO WARRANTIES, WHETHER EXPRESS, IMPLIED
|
||||
* OR STATUTORY, INCLUDING, BUT NOT LIMITED TO, IMPLIED WARRANTIES OF
|
||||
* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE APPLY TO THIS SOFTWARE.
|
||||
* CVA SHALL NOT, IN ANY CIRCUMSTANCES, BE LIABLE FOR SPECIAL, INCIDENTAL,
|
||||
* OR CONSEQUENTIAL DAMAGES, FOR ANY REASON WHATSOEVER.
|
||||
*/
|
||||
|
||||
#ifndef _UDS_SERVICE11_H_
|
||||
#define _UDS_SERVICE11_H_
|
||||
|
||||
/*! \brief Contains public interface to various functions related
|
||||
* to the user-defined UDS service 11
|
||||
*/
|
||||
/*******************************************************************************
|
||||
* the includes
|
||||
******************************************************************************/
|
||||
|
||||
#include <stdbool.h>
|
||||
#include <stdint.h>
|
||||
#include "../stack/uds.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/*******************************************************************************
|
||||
* the defines
|
||||
******************************************************************************/
|
||||
|
||||
/*******************************************************************************
|
||||
* the typedefs
|
||||
******************************************************************************/
|
||||
|
||||
/*******************************************************************************
|
||||
* the globals
|
||||
******************************************************************************/
|
||||
|
||||
/*******************************************************************************
|
||||
* the function prototypes
|
||||
******************************************************************************/
|
||||
|
||||
/*! \brief Uds Service 11 processing
|
||||
*/
|
||||
extern void UdsService11_ResetEcu(UdsType *obj, const uint8_t msgBuf[], uint16_t msgLen);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif /* extern "C" */
|
||||
|
||||
#endif /* _UDS_SERVICE11_H_ */
|
@ -1,213 +0,0 @@
|
||||
/*
|
||||
* Copyright (c) 2022, Shenzhen CVA Innovation CO.,LTD
|
||||
* All rights reserved.
|
||||
*
|
||||
* Shenzhen CVA Innovation CO.,LTD (CVA chip) is supplying this file for use
|
||||
* exclusively with CVA's microcontroller products. This file can be freely
|
||||
* distributed within development tools that are supporting such microcontroller
|
||||
* products.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED "AS IS". NO WARRANTIES, WHETHER EXPRESS, IMPLIED
|
||||
* OR STATUTORY, INCLUDING, BUT NOT LIMITED TO, IMPLIED WARRANTIES OF
|
||||
* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE APPLY TO THIS SOFTWARE.
|
||||
* CVA SHALL NOT, IN ANY CIRCUMSTANCES, BE LIABLE FOR SPECIAL, INCIDENTAL,
|
||||
* OR CONSEQUENTIAL DAMAGES, FOR ANY REASON WHATSOEVER.
|
||||
*/
|
||||
|
||||
/*******************************************************************************
|
||||
* the includes
|
||||
******************************************************************************/
|
||||
|
||||
#include <string.h>
|
||||
#include "uds_service27.h"
|
||||
|
||||
/*******************************************************************************
|
||||
* the defines
|
||||
******************************************************************************/
|
||||
|
||||
#define SUPPORT_LEVEL_NUM 4 /* supported security level number */
|
||||
|
||||
#define MAX_ALLOW_ERROR_NUM 5 /* the max allow number of key error */
|
||||
|
||||
#define STARTUP_DELAY_MS 2000 /* the service allow access time delay after UDS start */
|
||||
#define ERR_EXCEED_DELAY_MS 10000 /* the service allow access time delay after error number exceed */
|
||||
|
||||
/*******************************************************************************
|
||||
* the typedefs
|
||||
******************************************************************************/
|
||||
|
||||
typedef struct _SecurityLevel_Param_
|
||||
{
|
||||
uint8_t level;
|
||||
uint8_t keyErrorCnt;
|
||||
uint8_t maxErrNum;
|
||||
int64_t MaxErrTimeStamp;
|
||||
} SecurityLevel_Param;
|
||||
|
||||
/*******************************************************************************
|
||||
* the globals
|
||||
******************************************************************************/
|
||||
|
||||
SecurityLevel_Param scrtParam[SUPPORT_LEVEL_NUM] = {
|
||||
{UDS_SA_LEVEL_1, 0, MAX_ALLOW_ERROR_NUM, 0},
|
||||
{UDS_SA_LEVEL_3, 0, MAX_ALLOW_ERROR_NUM, 0},
|
||||
{UDS_SA_LEVEL_11, 0, MAX_ALLOW_ERROR_NUM, 0},
|
||||
{UDS_SA_LEVEL_63, 0, MAX_ALLOW_ERROR_NUM, 0},
|
||||
};
|
||||
|
||||
/*******************************************************************************
|
||||
* the constants
|
||||
******************************************************************************/
|
||||
|
||||
/*******************************************************************************
|
||||
* the functions
|
||||
******************************************************************************/
|
||||
|
||||
static void UdsSecurityAccess_GenerateSeed(UdsType *obj, uint8_t newLevel, uint8_t *outData, uint8_t outBufsize, uint16_t *outLen)
|
||||
{
|
||||
/* seed is defined by user, It's usually a random value */
|
||||
uint8_t seed[4] = {1, 2, 3, 4};
|
||||
|
||||
if(outBufsize < sizeof(seed))
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
*outLen = sizeof(seed);
|
||||
if(newLevel == obj->securityLevel)
|
||||
{
|
||||
memset(outData, 0, sizeof(seed));
|
||||
}
|
||||
else
|
||||
{
|
||||
memcpy(outData, seed, sizeof(seed));
|
||||
}
|
||||
}
|
||||
|
||||
static bool UdsSecurityAccess_ValidateKey(uint8_t seedLevel, const uint8_t *seed, uint16_t seedLen, const uint8_t *key, uint16_t keyLen)
|
||||
{
|
||||
/* The encryption algorithm is provided by the vehicle manufacturer */
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
void UdsService27_SecurityAccess(UdsType *obj, const uint8_t msgBuf[], uint16_t msgLen)
|
||||
{
|
||||
static uint8_t seedLevel = 0;
|
||||
static uint8_t seedValue[8] = {0};
|
||||
static uint16_t seedLen = 0;
|
||||
uint8_t subFunction;
|
||||
uint8_t udx = 0;
|
||||
uint8_t rspBuffer[8] = {0};
|
||||
uint16_t dataLen = 0, remainSize = 0;
|
||||
bool ret = false;
|
||||
|
||||
if(msgLen < obj->seviceTable[obj->curServiceIdx].minLen)
|
||||
{
|
||||
Uds_NegativeResponse(obj, 0x27, NRC_INVALID_MESSAGE_LENGTH_OR_FORMAT);
|
||||
return;
|
||||
}
|
||||
|
||||
if(obj->session == UDS_SESSION_DEFAULT)
|
||||
{
|
||||
Uds_NegativeResponse(obj, 0x27, NRC_CONDITIONS_NOT_CORRECT);
|
||||
return;
|
||||
}
|
||||
|
||||
if(obj->timeStamp_ms < STARTUP_DELAY_MS)
|
||||
{
|
||||
Uds_NegativeResponse(obj, 0x27, NRC_REQUIRED_TIME_DELAY_NOT_EXPIRED);
|
||||
return;
|
||||
}
|
||||
|
||||
subFunction = UDS_GET_SUB_FUNCTION(msgBuf[1]);
|
||||
rspBuffer[0] = UDS_GET_POSITIVE_RSP(0x27);
|
||||
rspBuffer[1] = subFunction;
|
||||
if(subFunction % 2)
|
||||
{
|
||||
seedLevel = 0;
|
||||
for(udx = 0; udx < SUPPORT_LEVEL_NUM; udx++)
|
||||
{
|
||||
if(subFunction == scrtParam[udx].level)
|
||||
{
|
||||
if(scrtParam[udx].keyErrorCnt > scrtParam[udx].maxErrNum)
|
||||
{
|
||||
if(obj->timeStamp_ms - scrtParam[udx].MaxErrTimeStamp < ERR_EXCEED_DELAY_MS)
|
||||
{
|
||||
Uds_NegativeResponse(obj, 0x27, NRC_EXCEEDED_NUMBER_OF_ATTEMPTS);
|
||||
return;
|
||||
}
|
||||
else
|
||||
{
|
||||
scrtParam[udx].keyErrorCnt = 0;
|
||||
}
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if(udx >= SUPPORT_LEVEL_NUM)
|
||||
{
|
||||
Uds_NegativeResponse(obj, 0x27, NRC_REQUEST_OUT_OF_RANGE);
|
||||
return;
|
||||
}
|
||||
|
||||
remainSize = sizeof(rspBuffer) - 2;
|
||||
UdsSecurityAccess_GenerateSeed(obj, subFunction, &rspBuffer[2], remainSize, &dataLen);
|
||||
if(dataLen > 0)
|
||||
{
|
||||
Uds_PositiveResponse(obj, rspBuffer, dataLen + 2);
|
||||
|
||||
seedLevel = subFunction;
|
||||
seedLen = dataLen;
|
||||
memcpy(seedValue, &rspBuffer[2], dataLen);
|
||||
}
|
||||
else
|
||||
{
|
||||
Uds_NegativeResponse(obj, 0x27, NRC_REQUEST_OUT_OF_RANGE);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if(subFunction != seedLevel + 1)
|
||||
{
|
||||
Uds_NegativeResponse(obj, 0x27, NRC_REQUEST_SEQUENCE_ERROR);
|
||||
return;
|
||||
}
|
||||
|
||||
/* polyspace-begin DEFECT:DEAD_CODE [No action planned:Low] "Still reserve though it's maybe unreachable" */
|
||||
ret = UdsSecurityAccess_ValidateKey(seedLevel, seedValue, seedLen, &msgBuf[2], msgLen - 2);
|
||||
if(ret == true)
|
||||
{
|
||||
Uds_PositiveResponse(obj, rspBuffer, 2);
|
||||
|
||||
seedLevel = 0;
|
||||
obj->securityLevel = subFunction - 1;
|
||||
|
||||
for(udx = 0; udx < SUPPORT_LEVEL_NUM; udx++)
|
||||
{
|
||||
if(subFunction == scrtParam[udx].level)
|
||||
{
|
||||
scrtParam[udx].keyErrorCnt = 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
Uds_NegativeResponse(obj, 0x27, NRC_INVALID_KEY);
|
||||
|
||||
for(udx = 0; udx < SUPPORT_LEVEL_NUM; udx++)
|
||||
{
|
||||
if(seedLevel == scrtParam[udx].level)
|
||||
{
|
||||
scrtParam[udx].keyErrorCnt++;
|
||||
if(scrtParam[udx].keyErrorCnt > scrtParam[udx].maxErrNum)
|
||||
{
|
||||
scrtParam[udx].MaxErrTimeStamp = obj->timeStamp_ms;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
/* polyspace-end DEFECT:DEAD_CODE [No action planned:Low] "Still reserve though it's maybe unreachable" */
|
||||
}
|
||||
}
|
@ -1,60 +0,0 @@
|
||||
/*
|
||||
* Copyright (c) 2022, Shenzhen CVA Innovation CO.,LTD
|
||||
* All rights reserved.
|
||||
*
|
||||
* Shenzhen CVA Innovation CO.,LTD (CVA chip) is supplying this file for use
|
||||
* exclusively with CVA's microcontroller products. This file can be freely
|
||||
* distributed within development tools that are supporting such microcontroller
|
||||
* products.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED "AS IS". NO WARRANTIES, WHETHER EXPRESS, IMPLIED
|
||||
* OR STATUTORY, INCLUDING, BUT NOT LIMITED TO, IMPLIED WARRANTIES OF
|
||||
* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE APPLY TO THIS SOFTWARE.
|
||||
* CVA SHALL NOT, IN ANY CIRCUMSTANCES, BE LIABLE FOR SPECIAL, INCIDENTAL,
|
||||
* OR CONSEQUENTIAL DAMAGES, FOR ANY REASON WHATSOEVER.
|
||||
*/
|
||||
|
||||
#ifndef _UDS_SERVICE27_H_
|
||||
#define _UDS_SERVICE27_H_
|
||||
|
||||
/*! \brief Contains public interface to various functions related
|
||||
* to the user-defined UDS service 27
|
||||
*/
|
||||
|
||||
/*******************************************************************************
|
||||
* the includes
|
||||
******************************************************************************/
|
||||
|
||||
#include <stdbool.h>
|
||||
#include <stdint.h>
|
||||
#include "../stack/uds.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/*******************************************************************************
|
||||
* the defines
|
||||
******************************************************************************/
|
||||
|
||||
/*******************************************************************************
|
||||
* the typedefs
|
||||
******************************************************************************/
|
||||
|
||||
/*******************************************************************************
|
||||
* the globals
|
||||
******************************************************************************/
|
||||
|
||||
/*******************************************************************************
|
||||
* the function prototypes
|
||||
******************************************************************************/
|
||||
|
||||
/*! \brief Uds Service 27 processing
|
||||
*/
|
||||
extern void UdsService27_SecurityAccess(UdsType *obj, const uint8_t msgBuf[], uint16_t msgLen);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif /* extern "C" */
|
||||
|
||||
#endif /* _UDS_SERVICE27_H_ */
|
@ -1,278 +0,0 @@
|
||||
/*
|
||||
* Copyright (c) 2022, Shenzhen CVA Innovation CO.,LTD
|
||||
* All rights reserved.
|
||||
*
|
||||
* Shenzhen CVA Innovation CO.,LTD (CVA chip) is supplying this file for use
|
||||
* exclusively with CVA's microcontroller products. This file can be freely
|
||||
* distributed within development tools that are supporting such microcontroller
|
||||
* products.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED "AS IS". NO WARRANTIES, WHETHER EXPRESS, IMPLIED
|
||||
* OR STATUTORY, INCLUDING, BUT NOT LIMITED TO, IMPLIED WARRANTIES OF
|
||||
* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE APPLY TO THIS SOFTWARE.
|
||||
* CVA SHALL NOT, IN ANY CIRCUMSTANCES, BE LIABLE FOR SPECIAL, INCIDENTAL,
|
||||
* OR CONSEQUENTIAL DAMAGES, FOR ANY REASON WHATSOEVER.
|
||||
*/
|
||||
|
||||
/*******************************************************************************
|
||||
* the includes
|
||||
******************************************************************************/
|
||||
|
||||
#include "uds_service31.h"
|
||||
|
||||
/*******************************************************************************
|
||||
* the defines
|
||||
******************************************************************************/
|
||||
|
||||
/*******************************************************************************
|
||||
* the typedefs
|
||||
******************************************************************************/
|
||||
|
||||
/*! \brief The Uds routine control type
|
||||
*/
|
||||
typedef enum _UdsRoutineCtrlType_
|
||||
{
|
||||
UDS_ROUTINE_CTRL_NONE = 0,
|
||||
UDS_ROUTINE_CTRL_START = 0x01,
|
||||
UDS_ROUTINE_CTRL_STOP = 0x02,
|
||||
UDS_ROUTINE_CTRL_REQUEST_RESULT = 0x03
|
||||
} UdsRoutineCtrlType;
|
||||
|
||||
/*! \brief The Uds routine control status
|
||||
*/
|
||||
typedef enum _UdsRtnCtrlStatus_
|
||||
{
|
||||
UDS_RTN_ST_IDLE = 0x00,
|
||||
UDS_RTN_ST_RUNNING = 0x01,
|
||||
} UdsRtnCtrlStatus;
|
||||
|
||||
/*! \brief The Uds routine control struct
|
||||
*/
|
||||
typedef struct _Uds_RtnCtrl_
|
||||
{
|
||||
uint16_t rtnCtrlId;
|
||||
uint8_t sessionLevel;
|
||||
uint8_t securityLevel;
|
||||
UdsRtnCtrlStatus rtnStatus;
|
||||
void (*Routine_Start)(const uint8_t *pdata, uint16_t len, uint8_t *pRspData, uint16_t rspSize, uint16_t *pRspLen);
|
||||
void (*Routine_Stop)(const uint8_t *pdata, uint16_t len, uint8_t *pRspData, uint16_t rspSize, uint16_t *pRspLen);
|
||||
void (*Routine_Result)(const uint8_t *pdata, uint16_t len, uint8_t *pRspData, uint16_t rspSize, uint16_t *pRspLen);
|
||||
} Uds_RtnCtrl;
|
||||
|
||||
/*******************************************************************************
|
||||
* the constants
|
||||
******************************************************************************/
|
||||
|
||||
static void Routine_StartEreaseMemory(const uint8_t *pdata, uint16_t len, uint8_t *pRspData, uint16_t rspSize, uint16_t *pRspLen);
|
||||
static void Routine_StopEreaseMemory(const uint8_t *pdata, uint16_t len, uint8_t *pRspData, uint16_t rspSize, uint16_t *pRspLen);
|
||||
static void Routine_EreaseMemoryResult(const uint8_t *pdata, uint16_t len, uint8_t *pRspData, uint16_t rspSize, uint16_t *pRspLen);
|
||||
static void Routine_StartCheckProgramDependencies(const uint8_t *pdata, uint16_t len, uint8_t *pRspData, uint16_t rspSize, uint16_t *pRspLen);
|
||||
static void Routine_StopCheckProgramDependencies(const uint8_t *pdata, uint16_t len, uint8_t *pRspData, uint16_t rspSize, uint16_t *pRspLen);
|
||||
static void Routine_CheckProgramDependenciesResult(const uint8_t *pdata, uint16_t len, uint8_t *pRspData, uint16_t rspSize, uint16_t *pRspLen);
|
||||
static void Routine_StartEreaseMirrorMemDtcs(const uint8_t *pdata, uint16_t len, uint8_t *pRspData, uint16_t rspSize, uint16_t *pRspLen);
|
||||
static void Routine_StopEreaseMirrorMemDtcs(const uint8_t *pdata, uint16_t len, uint8_t *pRspData, uint16_t rspSize, uint16_t *pRspLen);
|
||||
static void Routine_EreaseMirrorMemDtcsResult(const uint8_t *pdata, uint16_t len, uint8_t *pRspData, uint16_t rspSize, uint16_t *pRspLen);
|
||||
|
||||
/*******************************************************************************
|
||||
* the globals
|
||||
******************************************************************************/
|
||||
|
||||
Uds_RtnCtrl udsRtnCtrlTable[] = {
|
||||
{0xFF00, UDS_SESSION_EXTENDED, UDS_SA_LEVEL_1, UDS_RTN_ST_IDLE, &Routine_StartEreaseMemory, &Routine_StopEreaseMemory, &Routine_EreaseMemoryResult },
|
||||
{0xFF01, UDS_SESSION_EXTENDED, UDS_SA_LEVEL_1, UDS_RTN_ST_IDLE, &Routine_StartCheckProgramDependencies, &Routine_StopCheckProgramDependencies, &Routine_CheckProgramDependenciesResult},
|
||||
{0xFF02, UDS_SESSION_EXTENDED, UDS_SA_LEVEL_1, UDS_RTN_ST_IDLE, &Routine_StartEreaseMirrorMemDtcs, &Routine_StopEreaseMirrorMemDtcs, &Routine_EreaseMirrorMemDtcsResult },
|
||||
};
|
||||
|
||||
/*******************************************************************************
|
||||
* the functions
|
||||
******************************************************************************/
|
||||
|
||||
void Routine_StatusInit(uint16_t routineId)
|
||||
{
|
||||
uint8_t rtnIndex = 0;
|
||||
uint8_t rntNum = sizeof(udsRtnCtrlTable) / sizeof(Uds_RtnCtrl);
|
||||
|
||||
for(rtnIndex = 0; rtnIndex < rntNum; rtnIndex++)
|
||||
{
|
||||
if(udsRtnCtrlTable[rtnIndex].rtnCtrlId == routineId)
|
||||
{
|
||||
udsRtnCtrlTable[rtnIndex].rtnStatus = UDS_RTN_ST_IDLE;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
static void Routine_StartEreaseMemory(const uint8_t *pdata, uint16_t len, uint8_t *pRspData, uint16_t rspSize, uint16_t *pRspLen)
|
||||
{
|
||||
if(pdata == NULL)
|
||||
{
|
||||
return;
|
||||
}
|
||||
/* user add start erease memory code */
|
||||
}
|
||||
|
||||
static void Routine_StopEreaseMemory(const uint8_t *pdata, uint16_t len, uint8_t *pRspData, uint16_t rspSize, uint16_t *pRspLen)
|
||||
{
|
||||
if(pdata == NULL)
|
||||
{
|
||||
return;
|
||||
}
|
||||
/* user add stop erease memory code */
|
||||
}
|
||||
|
||||
static void Routine_EreaseMemoryResult(const uint8_t *pdata, uint16_t len, uint8_t *pRspData, uint16_t rspSize, uint16_t *pRspLen)
|
||||
{
|
||||
if(pdata == NULL)
|
||||
{
|
||||
return;
|
||||
}
|
||||
/* user add erease memory result code */
|
||||
}
|
||||
|
||||
static void Routine_StartCheckProgramDependencies(const uint8_t *pdata, uint16_t len, uint8_t *pRspData, uint16_t rspSize, uint16_t *pRspLen)
|
||||
{
|
||||
if(pdata == NULL)
|
||||
{
|
||||
return;
|
||||
}
|
||||
/* user add start check program dependencies code */
|
||||
}
|
||||
|
||||
static void Routine_StopCheckProgramDependencies(const uint8_t *pdata, uint16_t len, uint8_t *pRspData, uint16_t rspSize, uint16_t *pRspLen)
|
||||
{
|
||||
if(pdata == NULL)
|
||||
{
|
||||
return;
|
||||
}
|
||||
/* user add stop check program dependencies code */
|
||||
}
|
||||
|
||||
static void Routine_CheckProgramDependenciesResult(const uint8_t *pdata, uint16_t len, uint8_t *pRspData, uint16_t rspSize, uint16_t *pRspLen)
|
||||
{
|
||||
if(pdata == NULL)
|
||||
{
|
||||
return;
|
||||
}
|
||||
/* user add check program dependencies result code */
|
||||
}
|
||||
|
||||
static void Routine_StartEreaseMirrorMemDtcs(const uint8_t *pdata, uint16_t len, uint8_t *pRspData, uint16_t rspSize, uint16_t *pRspLen)
|
||||
{
|
||||
if(pdata == NULL)
|
||||
{
|
||||
return;
|
||||
}
|
||||
/* user add start erease mirror memory Dtcs code */
|
||||
}
|
||||
|
||||
static void Routine_StopEreaseMirrorMemDtcs(const uint8_t *pdata, uint16_t len, uint8_t *pRspData, uint16_t rspSize, uint16_t *pRspLen)
|
||||
{
|
||||
if(pdata == NULL)
|
||||
{
|
||||
return;
|
||||
}
|
||||
/* user add stop erease mirror memory Dtcs code */
|
||||
}
|
||||
|
||||
static void Routine_EreaseMirrorMemDtcsResult(const uint8_t *pdata, uint16_t len, uint8_t *pRspData, uint16_t rspSize, uint16_t *pRspLen)
|
||||
{
|
||||
if(pdata == NULL)
|
||||
{
|
||||
return;
|
||||
}
|
||||
/* user add erease mirror memory Dtcs resultl code */
|
||||
}
|
||||
|
||||
void UdsService31_RoutineControl(UdsType *obj, const uint8_t msgBuf[], uint16_t msgLen)
|
||||
{
|
||||
const uint8_t *pOptionParam = NULL;
|
||||
uint8_t subFunction = 0;
|
||||
uint16_t optionParamLen = 0;
|
||||
uint16_t routineId = 0;
|
||||
uint8_t rtnIndex = 0;
|
||||
uint8_t rntNum = sizeof(udsRtnCtrlTable) / sizeof(Uds_RtnCtrl);
|
||||
uint8_t rspBuffer[UDS_RSP_LEN_MAX] = {0};
|
||||
uint16_t rspLen = 0;
|
||||
|
||||
if(msgLen < obj->seviceTable[obj->curServiceIdx].minLen)
|
||||
{
|
||||
Uds_NegativeResponse(obj, 0x31, NRC_INVALID_MESSAGE_LENGTH_OR_FORMAT);
|
||||
return;
|
||||
}
|
||||
|
||||
subFunction = UDS_GET_SUB_FUNCTION(msgBuf[1]);
|
||||
routineId = ((uint16_t)msgBuf[2] << 8) + msgBuf[3];
|
||||
optionParamLen = msgLen - 4;
|
||||
if(optionParamLen > 0)
|
||||
{
|
||||
pOptionParam = &msgBuf[4];
|
||||
}
|
||||
|
||||
for(rtnIndex = 0; rtnIndex < rntNum; rtnIndex++)
|
||||
{
|
||||
if(udsRtnCtrlTable[rtnIndex].rtnCtrlId == routineId)
|
||||
{
|
||||
if(obj->session == udsRtnCtrlTable[rtnIndex].sessionLevel)
|
||||
{
|
||||
if((udsRtnCtrlTable[rtnIndex].securityLevel != UDS_SA_NONE) && (udsRtnCtrlTable[rtnIndex].securityLevel != obj->securityLevel))
|
||||
{
|
||||
Uds_NegativeResponse(obj, 0x31, NRC_SECURITY_ACCESS_DENIED);
|
||||
return;
|
||||
}
|
||||
|
||||
break;
|
||||
}
|
||||
else
|
||||
{
|
||||
Uds_NegativeResponse(obj, 0x31, NRC_CONDITIONS_NOT_CORRECT);
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if(rtnIndex >= rntNum)
|
||||
{
|
||||
Uds_NegativeResponse(obj, 0x31, NRC_REQUEST_OUT_OF_RANGE);
|
||||
return;
|
||||
}
|
||||
|
||||
memset(rspBuffer, 0, UDS_RSP_LEN_MAX);
|
||||
|
||||
switch(subFunction)
|
||||
{
|
||||
case UDS_ROUTINE_CTRL_START:
|
||||
udsRtnCtrlTable[rtnIndex].Routine_Start(pOptionParam, optionParamLen, rspBuffer, UDS_RSP_LEN_MAX, &rspLen);
|
||||
udsRtnCtrlTable[rtnIndex].rtnStatus = UDS_RTN_ST_RUNNING;
|
||||
break;
|
||||
case UDS_ROUTINE_CTRL_STOP:
|
||||
if(udsRtnCtrlTable[rtnIndex].rtnStatus != UDS_RTN_ST_IDLE)
|
||||
{
|
||||
udsRtnCtrlTable[rtnIndex].Routine_Stop(pOptionParam, optionParamLen, rspBuffer, UDS_RSP_LEN_MAX, &rspLen);
|
||||
udsRtnCtrlTable[rtnIndex].rtnStatus = UDS_RTN_ST_IDLE;
|
||||
}
|
||||
break;
|
||||
case UDS_ROUTINE_CTRL_REQUEST_RESULT:
|
||||
if(udsRtnCtrlTable[rtnIndex].rtnStatus != UDS_RTN_ST_IDLE)
|
||||
{
|
||||
udsRtnCtrlTable[rtnIndex].Routine_Result(pOptionParam, optionParamLen, rspBuffer, UDS_RSP_LEN_MAX, &rspLen);
|
||||
}
|
||||
break;
|
||||
default:
|
||||
Uds_NegativeResponse(obj, 0x31, NRC_SUBFUNCTION_NOT_SUPPORTED);
|
||||
return;
|
||||
}
|
||||
|
||||
/* polyspace-begin DEFECT:DEAD_CODE [No action planned:Low] "Still reserve though it's maybe unreachable" */
|
||||
if((rspLen >= 4) && (rspBuffer[0] == UDS_GET_POSITIVE_RSP(0x31)))
|
||||
{
|
||||
Uds_PositiveResponse(obj, rspBuffer, rspLen);
|
||||
}
|
||||
else if((rspLen == 3) && (rspBuffer[0] == NEGATIVE_RSP))
|
||||
{
|
||||
Uds_NegativeResponse(obj, 0x31, rspBuffer[2]);
|
||||
}
|
||||
else
|
||||
{
|
||||
Uds_NegativeResponse(obj, 0x31, NRC_REQUEST_SEQUENCE_ERROR);
|
||||
}
|
||||
/* polyspace-end DEFECT:DEAD_CODE [No action planned:Low] "Still reserve though it's maybe unreachable" */
|
||||
}
|
@ -1,62 +0,0 @@
|
||||
/*
|
||||
* Copyright (c) 2022, Shenzhen CVA Innovation CO.,LTD
|
||||
* All rights reserved.
|
||||
*
|
||||
* Shenzhen CVA Innovation CO.,LTD (CVA chip) is supplying this file for use
|
||||
* exclusively with CVA's microcontroller products. This file can be freely
|
||||
* distributed within development tools that are supporting such microcontroller
|
||||
* products.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED "AS IS". NO WARRANTIES, WHETHER EXPRESS, IMPLIED
|
||||
* OR STATUTORY, INCLUDING, BUT NOT LIMITED TO, IMPLIED WARRANTIES OF
|
||||
* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE APPLY TO THIS SOFTWARE.
|
||||
* CVA SHALL NOT, IN ANY CIRCUMSTANCES, BE LIABLE FOR SPECIAL, INCIDENTAL,
|
||||
* OR CONSEQUENTIAL DAMAGES, FOR ANY REASON WHATSOEVER.
|
||||
*/
|
||||
|
||||
#ifndef _UDS_SERVICE31_H_
|
||||
#define _UDS_SERVICE31_H_
|
||||
|
||||
/*! \brief Contains public interface to various functions related
|
||||
* to the user-defined UDS service 31
|
||||
*/
|
||||
|
||||
/*******************************************************************************
|
||||
* the includes
|
||||
******************************************************************************/
|
||||
|
||||
#include "../stack/uds.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/*******************************************************************************
|
||||
* the defines
|
||||
******************************************************************************/
|
||||
|
||||
/*******************************************************************************
|
||||
* the typedefs
|
||||
******************************************************************************/
|
||||
|
||||
/*******************************************************************************
|
||||
* the globals
|
||||
******************************************************************************/
|
||||
|
||||
/*******************************************************************************
|
||||
* the function prototypes
|
||||
******************************************************************************/
|
||||
|
||||
/*! \brief Uds Service 31 processing
|
||||
*/
|
||||
extern void UdsService31_RoutineControl(UdsType *obj, const uint8_t msgBuf[], uint16_t msgLen);
|
||||
|
||||
/*! \brief Routine status init
|
||||
*/
|
||||
extern void Routine_StatusInit(uint16_t routineId);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif /* extern "C" */
|
||||
|
||||
#endif /* _UDS_SERVICE31_H_ */
|
@ -1,146 +0,0 @@
|
||||
/*
|
||||
* Copyright (c) 2022, Shenzhen CVA Innovation CO.,LTD
|
||||
* All rights reserved.
|
||||
*
|
||||
* Shenzhen CVA Innovation CO.,LTD (CVA chip) is supplying this file for use
|
||||
* exclusively with CVA's microcontroller products. This file can be freely
|
||||
* distributed within development tools that are supporting such microcontroller
|
||||
* products.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED "AS IS". NO WARRANTIES, WHETHER EXPRESS, IMPLIED
|
||||
* OR STATUTORY, INCLUDING, BUT NOT LIMITED TO, IMPLIED WARRANTIES OF
|
||||
* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE APPLY TO THIS SOFTWARE.
|
||||
* CVA SHALL NOT, IN ANY CIRCUMSTANCES, BE LIABLE FOR SPECIAL, INCIDENTAL,
|
||||
* OR CONSEQUENTIAL DAMAGES, FOR ANY REASON WHATSOEVER.
|
||||
*/
|
||||
|
||||
/*******************************************************************************
|
||||
* the includes
|
||||
******************************************************************************/
|
||||
|
||||
#include "uds_service34.h"
|
||||
#include "uds_service36.h"
|
||||
|
||||
|
||||
/*******************************************************************************
|
||||
* the defines
|
||||
******************************************************************************/
|
||||
|
||||
/*******************************************************************************
|
||||
* the typedefs
|
||||
******************************************************************************/
|
||||
|
||||
/*******************************************************************************
|
||||
* the globals
|
||||
******************************************************************************/
|
||||
|
||||
/*******************************************************************************
|
||||
* the constants
|
||||
******************************************************************************/
|
||||
|
||||
/*******************************************************************************
|
||||
* the functions
|
||||
******************************************************************************/
|
||||
|
||||
uint32_t Uds_GetMaxfBlockSize(void)
|
||||
{
|
||||
/* user add code to get max num of block length */
|
||||
|
||||
return 128;
|
||||
}
|
||||
|
||||
uint8_t Uds_GetValidBytesNumOfData(uint32_t data)
|
||||
{
|
||||
uint8_t index = 0;
|
||||
uint8_t bytesNum = 0;
|
||||
|
||||
for(index = 1; index <= 4; index++)
|
||||
{
|
||||
if(data >> ((4 - index) * 8))
|
||||
{
|
||||
bytesNum = 4 - index + 1;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
return bytesNum;
|
||||
}
|
||||
|
||||
void UdsService34_RequestDownload(UdsType *obj, const uint8_t msgBuf[], uint16_t msgLen)
|
||||
{
|
||||
uint32_t memAddress = 0;
|
||||
uint8_t memAddrLen = 0;
|
||||
uint32_t memSize = 0;
|
||||
uint8_t memSizeLen = 0;
|
||||
uint8_t maxBlockSizeLen = 0;
|
||||
uint32_t maxBlockSize = 0;
|
||||
uint8_t index = 0;
|
||||
uint16_t rspLen = 0;
|
||||
uint8_t rspBuffer[8];
|
||||
|
||||
if(obj->session == UDS_SESSION_DEFAULT)
|
||||
{
|
||||
Uds_NegativeResponse(obj, 0x34, NRC_CONDITIONS_NOT_CORRECT);
|
||||
return;
|
||||
}
|
||||
|
||||
if(msgLen < obj->seviceTable[obj->curServiceIdx].minLen)
|
||||
{
|
||||
Uds_NegativeResponse(obj, 0x34, NRC_INVALID_MESSAGE_LENGTH_OR_FORMAT);
|
||||
return;
|
||||
}
|
||||
|
||||
memAddrLen = msgBuf[2] & 0x0F;
|
||||
memSizeLen = msgBuf[2] >> 4;
|
||||
|
||||
if((memAddrLen == 0) || (memAddrLen > sizeof(memAddress)) || (memSizeLen == 0) || (memSizeLen > sizeof(memSize)))
|
||||
{
|
||||
Uds_NegativeResponse(obj, 0x34, NRC_REQUEST_OUT_OF_RANGE);
|
||||
return;
|
||||
}
|
||||
|
||||
for(index = 0; index < memAddrLen; index++)
|
||||
{
|
||||
memAddress <<= 8;
|
||||
memAddress += msgBuf[3 + index];
|
||||
}
|
||||
|
||||
for(index = 0; index < memSizeLen; index++)
|
||||
{
|
||||
memSize <<= 8;
|
||||
memSize += msgBuf[3 + memAddrLen + index];
|
||||
}
|
||||
|
||||
if(memSize == 0)
|
||||
{
|
||||
Uds_NegativeResponse(obj, 0x34, NRC_CONDITIONS_NOT_CORRECT);
|
||||
return;
|
||||
}
|
||||
|
||||
/* user add judge code for the security level */
|
||||
if(0)
|
||||
{
|
||||
Uds_NegativeResponse(obj, 0x34, NRC_SECURITY_ACCESS_DENIED);
|
||||
return;
|
||||
}
|
||||
|
||||
Uds_SetMemAddr(memAddress);
|
||||
Uds_SetMemSize(memSize);
|
||||
|
||||
Uds_SetDataTransferDirect(UDS_TRANSFER_DIR_DOWNLOAD);
|
||||
|
||||
maxBlockSize = Uds_GetMaxfBlockSize();
|
||||
maxBlockSizeLen = Uds_GetValidBytesNumOfData(maxBlockSize);
|
||||
|
||||
rspBuffer[rspLen++] = UDS_GET_POSITIVE_RSP(0x34);
|
||||
rspBuffer[rspLen++] = maxBlockSizeLen << 4;
|
||||
for(index = 1; index <= maxBlockSizeLen; index++)
|
||||
{
|
||||
rspBuffer[rspLen++] = maxBlockSize >> (8 * (maxBlockSizeLen - index));
|
||||
}
|
||||
|
||||
Uds_PositiveResponse(obj, rspBuffer, rspLen);
|
||||
}
|
||||
|
||||
|
||||
|
@ -1,61 +0,0 @@
|
||||
/*
|
||||
* Copyright (c) 2022, Shenzhen CVA Innovation CO.,LTD
|
||||
* All rights reserved.
|
||||
*
|
||||
* Shenzhen CVA Innovation CO.,LTD (CVA chip) is supplying this file for use
|
||||
* exclusively with CVA's microcontroller products. This file can be freely
|
||||
* distributed within development tools that are supporting such microcontroller
|
||||
* products.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED "AS IS". NO WARRANTIES, WHETHER EXPRESS, IMPLIED
|
||||
* OR STATUTORY, INCLUDING, BUT NOT LIMITED TO, IMPLIED WARRANTIES OF
|
||||
* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE APPLY TO THIS SOFTWARE.
|
||||
* CVA SHALL NOT, IN ANY CIRCUMSTANCES, BE LIABLE FOR SPECIAL, INCIDENTAL,
|
||||
* OR CONSEQUENTIAL DAMAGES, FOR ANY REASON WHATSOEVER.
|
||||
*/
|
||||
|
||||
#ifndef _UDS_SERVICE34_H_
|
||||
#define _UDS_SERVICE34_H_
|
||||
|
||||
/*! \brief Contains public interface to various functions related
|
||||
* to the user-defined UDS service 34
|
||||
*/
|
||||
|
||||
/*******************************************************************************
|
||||
* the includes
|
||||
******************************************************************************/
|
||||
|
||||
#include <stdbool.h>
|
||||
#include <stdint.h>
|
||||
#include <string.h>
|
||||
#include "../stack/uds.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/*******************************************************************************
|
||||
* the defines
|
||||
******************************************************************************/
|
||||
|
||||
/*******************************************************************************
|
||||
* the typedefs
|
||||
******************************************************************************/
|
||||
|
||||
/*******************************************************************************
|
||||
* the globals
|
||||
******************************************************************************/
|
||||
|
||||
/*******************************************************************************
|
||||
* the function prototypes
|
||||
******************************************************************************/
|
||||
|
||||
/*! \brief Uds Service 34 processing
|
||||
*/
|
||||
extern void UdsService34_RequestDownload(UdsType *obj, const uint8_t msgBuf[], uint16_t msgLen);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif /* extern "C" */
|
||||
|
||||
#endif /* _UDS_SERVICE34_H_ */
|
@ -1,160 +0,0 @@
|
||||
/*
|
||||
* Copyright (c) 2022, Shenzhen CVA Innovation CO.,LTD
|
||||
* All rights reserved.
|
||||
*
|
||||
* Shenzhen CVA Innovation CO.,LTD (CVA chip) is supplying this file for use
|
||||
* exclusively with CVA's microcontroller products. This file can be freely
|
||||
* distributed within development tools that are supporting such microcontroller
|
||||
* products.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED "AS IS". NO WARRANTIES, WHETHER EXPRESS, IMPLIED
|
||||
* OR STATUTORY, INCLUDING, BUT NOT LIMITED TO, IMPLIED WARRANTIES OF
|
||||
* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE APPLY TO THIS SOFTWARE.
|
||||
* CVA SHALL NOT, IN ANY CIRCUMSTANCES, BE LIABLE FOR SPECIAL, INCIDENTAL,
|
||||
* OR CONSEQUENTIAL DAMAGES, FOR ANY REASON WHATSOEVER.
|
||||
*/
|
||||
|
||||
/*******************************************************************************
|
||||
* the includes
|
||||
******************************************************************************/
|
||||
|
||||
#include "uds_service36.h"
|
||||
|
||||
|
||||
/*******************************************************************************
|
||||
* the defines
|
||||
******************************************************************************/
|
||||
|
||||
/*******************************************************************************
|
||||
* the typedefs
|
||||
******************************************************************************/
|
||||
|
||||
/*******************************************************************************
|
||||
* the globals
|
||||
******************************************************************************/
|
||||
|
||||
static uint32_t s_memAddr = 0;
|
||||
static uint32_t s_memSize = 0;
|
||||
static UdsTransDirType s_dataTransDir = UDS_TRANSFER_DIR_NONE;
|
||||
|
||||
static uint8_t s_curRcvSequence = 0;
|
||||
static uint8_t s_lastRcvSqunce = 0;
|
||||
static uint32_t s_rcvDataTotalLen = 0;
|
||||
|
||||
/*******************************************************************************
|
||||
* the constants
|
||||
******************************************************************************/
|
||||
|
||||
/*******************************************************************************
|
||||
* the functions
|
||||
******************************************************************************/
|
||||
|
||||
void Uds_SetMemAddr(uint32_t addr)
|
||||
{
|
||||
s_memAddr = addr;
|
||||
}
|
||||
|
||||
uint32_t Uds_GetMemAddr(void)
|
||||
{
|
||||
return s_memAddr;
|
||||
}
|
||||
|
||||
void Uds_SetMemSize(uint32_t size)
|
||||
{
|
||||
s_memSize = size;
|
||||
}
|
||||
|
||||
uint32_t Uds_GetMemSize(void)
|
||||
{
|
||||
return s_memSize;
|
||||
}
|
||||
|
||||
void Uds_SetDataTransferDirect(UdsTransDirType dirType)
|
||||
{
|
||||
s_dataTransDir = dirType;
|
||||
|
||||
/* clear sequence number */
|
||||
s_lastRcvSqunce = 0x00;
|
||||
s_curRcvSequence = 0x00;
|
||||
|
||||
/* clear receive data total number */
|
||||
s_rcvDataTotalLen = 0x00;
|
||||
}
|
||||
|
||||
UdsTransDirType Uds_GetDataTransferDirect(void)
|
||||
{
|
||||
return s_dataTransDir;
|
||||
}
|
||||
|
||||
uint32_t Uds_GetRcvDataTotalLen(void)
|
||||
{
|
||||
return s_rcvDataTotalLen;
|
||||
}
|
||||
|
||||
void UdsService36_TransferData(UdsType *obj, const uint8_t msgBuf[], uint16_t msgLen)
|
||||
{
|
||||
uint16_t rspLen = 0;
|
||||
uint8_t rspBuffer[UDS_RSP_LEN_MAX] = {0}; /* polyspace DEFECT:PARTIALLY_ACCESSED_ARRAY [No action planned:Low] "Still reserve though member2~511 is not written" */
|
||||
|
||||
if(obj->session == UDS_SESSION_DEFAULT)
|
||||
{
|
||||
Uds_NegativeResponse(obj, 0x36, NRC_CONDITIONS_NOT_CORRECT);
|
||||
return;
|
||||
}
|
||||
|
||||
if(msgLen < obj->seviceTable[obj->curServiceIdx].minLen)
|
||||
{
|
||||
Uds_NegativeResponse(obj, 0x36, NRC_INVALID_MESSAGE_LENGTH_OR_FORMAT);
|
||||
return;
|
||||
}
|
||||
|
||||
switch(s_dataTransDir)
|
||||
{
|
||||
case UDS_TRANSFER_DIR_DOWNLOAD:
|
||||
s_curRcvSequence = msgBuf[1];
|
||||
|
||||
if((s_curRcvSequence != s_lastRcvSqunce) && (s_curRcvSequence != ((uint8_t)(s_lastRcvSqunce + 1))))
|
||||
{
|
||||
Uds_NegativeResponse(obj, 0x36, NRC_WRONG_BLOCK_SEQUENCE_COUNTER);
|
||||
return;
|
||||
}
|
||||
|
||||
rspBuffer[rspLen++] = UDS_GET_POSITIVE_RSP(0x36);
|
||||
rspBuffer[rspLen++] = msgBuf[1];
|
||||
if(s_curRcvSequence == s_lastRcvSqunce)
|
||||
{
|
||||
Uds_PositiveResponse(obj, rspBuffer, rspLen);
|
||||
return;
|
||||
}
|
||||
|
||||
if((s_rcvDataTotalLen + msgLen - 2) > s_memSize)
|
||||
{
|
||||
Uds_NegativeResponse(obj, 0x36, NRC_TRANSFER_DATA_SUSPENDED);
|
||||
return;
|
||||
}
|
||||
|
||||
/* user add code to deal with download data */
|
||||
/* polyspace-begin DEFECT:DEAD_CODE [No action planned:Low] "Still reserve though it's maybe unreachable" */
|
||||
if(1) /* deal success */
|
||||
{
|
||||
s_rcvDataTotalLen += msgLen - 2;
|
||||
s_lastRcvSqunce = s_curRcvSequence;
|
||||
Uds_PositiveResponse(obj, rspBuffer, rspLen);
|
||||
}
|
||||
else
|
||||
{
|
||||
Uds_NegativeResponse(obj, 0x36, NRC_GENERAL_PROGRAMMING_FAILURE);
|
||||
}
|
||||
/* polyspace-end DEFECT:DEAD_CODE [No action planned:Low] "Still reserve though it's maybe unreachable" */
|
||||
break;
|
||||
case UDS_TRANSFER_DIR_UPLOAD:
|
||||
Uds_NegativeResponse(obj, 0x36, NRC_REQUEST_OUT_OF_RANGE);
|
||||
break;
|
||||
default:
|
||||
Uds_NegativeResponse(obj, 0x36, NRC_REQUEST_SEQUENCE_ERROR);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
@ -1,97 +0,0 @@
|
||||
/*
|
||||
* Copyright (c) 2022, Shenzhen CVA Innovation CO.,LTD
|
||||
* All rights reserved.
|
||||
*
|
||||
* Shenzhen CVA Innovation CO.,LTD (CVA chip) is supplying this file for use
|
||||
* exclusively with CVA's microcontroller products. This file can be freely
|
||||
* distributed within development tools that are supporting such microcontroller
|
||||
* products.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED "AS IS". NO WARRANTIES, WHETHER EXPRESS, IMPLIED
|
||||
* OR STATUTORY, INCLUDING, BUT NOT LIMITED TO, IMPLIED WARRANTIES OF
|
||||
* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE APPLY TO THIS SOFTWARE.
|
||||
* CVA SHALL NOT, IN ANY CIRCUMSTANCES, BE LIABLE FOR SPECIAL, INCIDENTAL,
|
||||
* OR CONSEQUENTIAL DAMAGES, FOR ANY REASON WHATSOEVER.
|
||||
*/
|
||||
|
||||
#ifndef _UDS_SERVICE36_H_
|
||||
#define _UDS_SERVICE36_H_
|
||||
|
||||
/*! \brief Contains public interface to various functions related
|
||||
* to the user-defined UDS service 36
|
||||
*/
|
||||
|
||||
/*******************************************************************************
|
||||
* the includes
|
||||
******************************************************************************/
|
||||
|
||||
#include <stdbool.h>
|
||||
#include <stdint.h>
|
||||
#include "../stack/uds.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/*******************************************************************************
|
||||
* the defines
|
||||
******************************************************************************/
|
||||
|
||||
/*******************************************************************************
|
||||
* the typedefs
|
||||
******************************************************************************/
|
||||
|
||||
/*! \brief The Uds IO control type
|
||||
*/
|
||||
typedef enum _UdsTransDirType_
|
||||
{
|
||||
UDS_TRANSFER_DIR_NONE = 0x00,
|
||||
UDS_TRANSFER_DIR_DOWNLOAD = 0x01,
|
||||
UDS_TRANSFER_DIR_UPLOAD = 0x02,
|
||||
} UdsTransDirType;
|
||||
|
||||
/*******************************************************************************
|
||||
* the globals
|
||||
******************************************************************************/
|
||||
|
||||
/*******************************************************************************
|
||||
* the function prototypes
|
||||
******************************************************************************/
|
||||
|
||||
/*! \brief set memery start address
|
||||
*/
|
||||
extern void Uds_SetMemAddr(uint32_t addr);
|
||||
|
||||
/*! \brief get memery start address
|
||||
*/
|
||||
extern uint32_t Uds_GetMemAddr(void);
|
||||
|
||||
/*! \brief set memery size
|
||||
*/
|
||||
extern void Uds_SetMemSize(uint32_t size);
|
||||
|
||||
/*! \brief get memery size
|
||||
*/
|
||||
extern uint32_t Uds_GetMemSize(void);
|
||||
|
||||
/*! \brief set data transfer direct
|
||||
*/
|
||||
extern void Uds_SetDataTransferDirect(UdsTransDirType dirType);
|
||||
|
||||
/*! \brief get data transfer direct
|
||||
*/
|
||||
extern UdsTransDirType Uds_GetDataTransferDirect(void);
|
||||
|
||||
/*! \brief get receive data total len
|
||||
*/
|
||||
extern uint32_t Uds_GetRcvDataTotalLen(void);
|
||||
|
||||
/*! \brief Uds Service 10 processing
|
||||
*/
|
||||
extern void UdsService36_TransferData(UdsType *obj, const uint8_t msgBuf[], uint16_t msgLen);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif /* extern "C" */
|
||||
|
||||
#endif /* _UDS_SERVICE36_H_ */
|
@ -1,179 +0,0 @@
|
||||
/*
|
||||
* Copyright (c) 2022, Shenzhen CVA Innovation CO.,LTD
|
||||
* All rights reserved.
|
||||
*
|
||||
* Shenzhen CVA Innovation CO.,LTD (CVA chip) is supplying this file for use
|
||||
* exclusively with CVA's microcontroller products. This file can be freely
|
||||
* distributed within development tools that are supporting such microcontroller
|
||||
* products.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED "AS IS". NO WARRANTIES, WHETHER EXPRESS, IMPLIED
|
||||
* OR STATUTORY, INCLUDING, BUT NOT LIMITED TO, IMPLIED WARRANTIES OF
|
||||
* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE APPLY TO THIS SOFTWARE.
|
||||
* CVA SHALL NOT, IN ANY CIRCUMSTANCES, BE LIABLE FOR SPECIAL, INCIDENTAL,
|
||||
* OR CONSEQUENTIAL DAMAGES, FOR ANY REASON WHATSOEVER.
|
||||
*/
|
||||
|
||||
/*******************************************************************************
|
||||
* the includes
|
||||
******************************************************************************/
|
||||
|
||||
#include "uds_user.h"
|
||||
|
||||
/*******************************************************************************
|
||||
* the defines
|
||||
******************************************************************************/
|
||||
|
||||
/*******************************************************************************
|
||||
* the typedefs
|
||||
******************************************************************************/
|
||||
|
||||
/*! \brief The Data-by-ID definition of UDS
|
||||
*/
|
||||
typedef struct _Uds_DidBuffer_
|
||||
{
|
||||
uint8_t buffer_F113[4];
|
||||
uint8_t buffer_F180[16];
|
||||
uint8_t buffer_F186[1];
|
||||
uint8_t buffer_F18A[6];
|
||||
uint8_t buffer_F195[16];
|
||||
uint8_t buffer_F1A0[8];
|
||||
uint8_t buffer_F1A1[8];
|
||||
uint8_t buffer_F1A2[8];
|
||||
uint8_t buffer_F1A5[8];
|
||||
uint8_t buffer_F1AE[16];
|
||||
uint8_t buffer_4F53[1];
|
||||
uint8_t buffer_4F80[2];
|
||||
uint8_t buffer_4F65[1];
|
||||
uint8_t buffer_4F66[1];
|
||||
uint8_t buffer_4F67[2];
|
||||
uint8_t buffer_F19E[32];
|
||||
uint8_t buffer_F1AA[8];
|
||||
uint8_t buffer_F1AB[8];
|
||||
uint8_t buffer_F112[8];
|
||||
uint8_t buffer_F190[17];
|
||||
uint8_t buffer_F191[16];
|
||||
uint8_t buffer_F193[16];
|
||||
uint8_t buffer_F197[8];
|
||||
uint8_t buffer_F198[16];
|
||||
uint8_t buffer_F199[4];
|
||||
uint8_t buffer_F19D[4];
|
||||
uint8_t buffer_DFEF[64];
|
||||
uint8_t buffer_F101[4];
|
||||
uint8_t buffer_F110[8];
|
||||
uint8_t buffer_4F51[16];
|
||||
uint8_t buffer_4F54[16];
|
||||
uint8_t buffer_F18C[24];
|
||||
uint8_t buffer_F18B[4];
|
||||
uint8_t buffer_0200[1];
|
||||
uint8_t buffer_0201[1];
|
||||
uint8_t buffer_F187[10];
|
||||
uint8_t buffer_F189[16];
|
||||
uint8_t buffer_FD01[1];
|
||||
uint8_t buffer_FD02[1];
|
||||
uint8_t buffer_FD03[1];
|
||||
} Uds_DidBuffer;
|
||||
|
||||
/*******************************************************************************
|
||||
* the globals
|
||||
******************************************************************************/
|
||||
|
||||
Uds_DidBuffer udsDidBuf;
|
||||
|
||||
/*******************************************************************************
|
||||
* the constants
|
||||
******************************************************************************/
|
||||
|
||||
static const Uds_ServiceType udsServiceTable[UDS_SERVICE_NUM] = {
|
||||
{0x10, 2, true, UdsService10_SessionControl },
|
||||
{0x11, 2, true, UdsService11_ResetEcu },
|
||||
{0x27, 2, true, UdsService27_SecurityAccess },
|
||||
{0x28, 3, true, UdsService28_CommunicationControl },
|
||||
{0x3E, 2, true, UdsService3E_TesterPresent },
|
||||
{0x85, 2, true, UdsService85_ControlDtcSetting },
|
||||
{0x22, 3, false, UdsService22_ReadDataByIdentifier },
|
||||
{0x2E, 4, false, UdsService2E_WriteDataByIdentifier},
|
||||
{0x14, 4, false, UdsService14_ClearDiagInfo },
|
||||
{0x19, 3, true, UdsService19_ReadDtcInformation },
|
||||
{0x2F, 3, false, UdsService2F_InputOutputCtrlById },
|
||||
{0x31, 4, true, UdsService31_RoutineControl },
|
||||
{0x34, 5, false, UdsService34_RequestDownload },
|
||||
{0x36, 2, false, UdsService36_TransferData },
|
||||
{0x37, 1, false, UdsService37_RequestTransferExit },
|
||||
};
|
||||
|
||||
static const bool udsSecurityTable[UDS_SERVICE_NUM][UDS_SA_LEVEL_NUM] = {
|
||||
{false, false, false}, /* 0x10 */
|
||||
{false, false, false}, /* 0x11 */
|
||||
{false, false, false}, /* 0x27 */
|
||||
{false, false, false}, /* 0x28 */
|
||||
{false, false, false}, /* 0x3E */
|
||||
{false, false, false}, /* 0x85 */
|
||||
{false, false, false}, /* 0x22 */
|
||||
{false, false, false}, /* 0x2E */
|
||||
{false, false, false}, /* 0x14 */
|
||||
{false, false, false}, /* 0x19 */
|
||||
{false, false, false}, /* 0x2F */
|
||||
{false, false, false}, /* 0x31 */
|
||||
{false, false, false}, /* 0x34 */
|
||||
{false, false, false}, /* 0x36 */
|
||||
{false, false, false}, /* 0x37 */
|
||||
};
|
||||
|
||||
Uds_DidType udsDidTable[] = {
|
||||
{0xF113, UDS_DID_TYPE_RAM_RW, UDS_SESSION_DEFAULT, UDS_SA_NONE, udsDidBuf.buffer_F113, BYTES_OF(udsDidBuf.buffer_F113)},
|
||||
{0xF180, UDS_DID_TYPE_RAM_RW, UDS_SESSION_DEFAULT, UDS_SA_NONE, udsDidBuf.buffer_F180, BYTES_OF(udsDidBuf.buffer_F180)},
|
||||
{0xF186, UDS_DID_TYPE_RAM_RW, UDS_SESSION_DEFAULT, UDS_SA_NONE, udsDidBuf.buffer_F186, BYTES_OF(udsDidBuf.buffer_F186)},
|
||||
{0xF18A, UDS_DID_TYPE_RAM_RW, UDS_SESSION_DEFAULT, UDS_SA_NONE, udsDidBuf.buffer_F18A, BYTES_OF(udsDidBuf.buffer_F18A)},
|
||||
{0xF195, UDS_DID_TYPE_RAM_RW, UDS_SESSION_DEFAULT, UDS_SA_NONE, udsDidBuf.buffer_F195, BYTES_OF(udsDidBuf.buffer_F195)},
|
||||
{0xF1A0, UDS_DID_TYPE_RAM_RW, UDS_SESSION_DEFAULT, UDS_SA_NONE, udsDidBuf.buffer_F1A0, BYTES_OF(udsDidBuf.buffer_F1A0)},
|
||||
{0xF1A1, UDS_DID_TYPE_RAM_RW, UDS_SESSION_DEFAULT, UDS_SA_NONE, udsDidBuf.buffer_F1A1, BYTES_OF(udsDidBuf.buffer_F1A1)},
|
||||
{0xF1A2, UDS_DID_TYPE_RAM_RW, UDS_SESSION_DEFAULT, UDS_SA_NONE, udsDidBuf.buffer_F1A2, BYTES_OF(udsDidBuf.buffer_F1A2)},
|
||||
{0xF1A5, UDS_DID_TYPE_RAM_RW, UDS_SESSION_DEFAULT, UDS_SA_NONE, udsDidBuf.buffer_F1A5, BYTES_OF(udsDidBuf.buffer_F1A5)},
|
||||
{0xF1AE, UDS_DID_TYPE_RAM_RW, UDS_SESSION_DEFAULT, UDS_SA_NONE, udsDidBuf.buffer_F1AE, BYTES_OF(udsDidBuf.buffer_F1AE)},
|
||||
{0x4F53, UDS_DID_TYPE_RAM_RW, UDS_SESSION_DEFAULT, UDS_SA_NONE, udsDidBuf.buffer_4F53, BYTES_OF(udsDidBuf.buffer_4F53)},
|
||||
{0x4F80, UDS_DID_TYPE_RAM_RW, UDS_SESSION_DEFAULT, UDS_SA_NONE, udsDidBuf.buffer_4F80, BYTES_OF(udsDidBuf.buffer_4F80)},
|
||||
{0x4F65, UDS_DID_TYPE_RAM_RW, UDS_SESSION_DEFAULT, UDS_SA_NONE, udsDidBuf.buffer_4F65, BYTES_OF(udsDidBuf.buffer_4F65)},
|
||||
{0x4F66, UDS_DID_TYPE_RAM_RW, UDS_SESSION_DEFAULT, UDS_SA_NONE, udsDidBuf.buffer_4F66, BYTES_OF(udsDidBuf.buffer_4F66)},
|
||||
{0x4F67, UDS_DID_TYPE_RAM_RW, UDS_SESSION_DEFAULT, UDS_SA_NONE, udsDidBuf.buffer_4F67, BYTES_OF(udsDidBuf.buffer_4F67)},
|
||||
{0xF19E, UDS_DID_TYPE_RAM_RW, UDS_SESSION_DEFAULT, UDS_SA_NONE, udsDidBuf.buffer_F19E, BYTES_OF(udsDidBuf.buffer_F19E)},
|
||||
{0xF1AA, UDS_DID_TYPE_RAM_RW, UDS_SESSION_DEFAULT, UDS_SA_NONE, udsDidBuf.buffer_F1AA, BYTES_OF(udsDidBuf.buffer_F1AA)},
|
||||
{0xF1AB, UDS_DID_TYPE_RAM_RW, UDS_SESSION_DEFAULT, UDS_SA_NONE, udsDidBuf.buffer_F1AB, BYTES_OF(udsDidBuf.buffer_F1AB)},
|
||||
{0xF112, UDS_DID_TYPE_NVM_RW, UDS_SESSION_EXTENDED, UDS_SA_LEVEL_1, udsDidBuf.buffer_F112, BYTES_OF(udsDidBuf.buffer_F112)},
|
||||
{0xF190, UDS_DID_TYPE_NVM_RW, UDS_SESSION_EXTENDED, UDS_SA_LEVEL_1, udsDidBuf.buffer_F190, BYTES_OF(udsDidBuf.buffer_F190)},
|
||||
{0xF191, UDS_DID_TYPE_NVM_RO, UDS_SESSION_SUPPLIER, UDS_SA_LEVEL_63, udsDidBuf.buffer_F191, BYTES_OF(udsDidBuf.buffer_F191)},
|
||||
{0xF193, UDS_DID_TYPE_NVM_RO, UDS_SESSION_SUPPLIER, UDS_SA_LEVEL_63, udsDidBuf.buffer_F193, BYTES_OF(udsDidBuf.buffer_F193)},
|
||||
{0xF197, UDS_DID_TYPE_NVM_RW, UDS_SESSION_EXTENDED, UDS_SA_LEVEL_1, udsDidBuf.buffer_F197, BYTES_OF(udsDidBuf.buffer_F197)},
|
||||
{0xF198, UDS_DID_TYPE_NVM_RO, UDS_SESSION_SUPPLIER, UDS_SA_LEVEL_63, udsDidBuf.buffer_F198, BYTES_OF(udsDidBuf.buffer_F198)},
|
||||
{0xF199, UDS_DID_TYPE_NVM_RO, UDS_SESSION_SUPPLIER, UDS_SA_LEVEL_63, udsDidBuf.buffer_F199, BYTES_OF(udsDidBuf.buffer_F199)},
|
||||
{0xF19D, UDS_DID_TYPE_NVM_RW, UDS_SESSION_EXTENDED, UDS_SA_LEVEL_1, udsDidBuf.buffer_F19D, BYTES_OF(udsDidBuf.buffer_F19D)},
|
||||
{0xDFEF, UDS_DID_TYPE_NVM_RW, UDS_SESSION_EXTENDED, UDS_SA_LEVEL_1, udsDidBuf.buffer_DFEF, BYTES_OF(udsDidBuf.buffer_DFEF)},
|
||||
{0xF101, UDS_DID_TYPE_NVM_RW, UDS_SESSION_EXTENDED, UDS_SA_LEVEL_1, udsDidBuf.buffer_F101, BYTES_OF(udsDidBuf.buffer_F101)},
|
||||
{0xF110, UDS_DID_TYPE_NVM_RO, UDS_SESSION_EXTENDED, UDS_SA_LEVEL_1, udsDidBuf.buffer_F110, BYTES_OF(udsDidBuf.buffer_F110)},
|
||||
{0x4F51, UDS_DID_TYPE_NVM_WO, UDS_SESSION_EXTENDED, UDS_SA_LEVEL_1, udsDidBuf.buffer_4F51, BYTES_OF(udsDidBuf.buffer_4F51)},
|
||||
{0x4F54, UDS_DID_TYPE_NVM_WO, UDS_SESSION_EXTENDED, UDS_SA_LEVEL_1, udsDidBuf.buffer_4F54, BYTES_OF(udsDidBuf.buffer_4F54)},
|
||||
{0xF18C, UDS_DID_TYPE_NVM_RO, UDS_SESSION_SUPPLIER, UDS_SA_LEVEL_63, udsDidBuf.buffer_F18C, BYTES_OF(udsDidBuf.buffer_F18C)},
|
||||
{0xF18B, UDS_DID_TYPE_NVM_RO, UDS_SESSION_SUPPLIER, UDS_SA_LEVEL_63, udsDidBuf.buffer_F18B, BYTES_OF(udsDidBuf.buffer_F18B)},
|
||||
{0x0200, UDS_DID_TYPE_NVM_RO, UDS_SESSION_EXTENDED, UDS_SA_LEVEL_1, udsDidBuf.buffer_0200, BYTES_OF(udsDidBuf.buffer_0200)},
|
||||
{0x0201, UDS_DID_TYPE_NVM_RO, UDS_SESSION_EXTENDED, UDS_SA_LEVEL_1, udsDidBuf.buffer_0201, BYTES_OF(udsDidBuf.buffer_0201)},
|
||||
{0xF187, UDS_DID_TYPE_NVM_RO, UDS_SESSION_SUPPLIER, UDS_SA_LEVEL_63, udsDidBuf.buffer_F187, BYTES_OF(udsDidBuf.buffer_F187)},
|
||||
{0xF189, UDS_DID_TYPE_NVM_RO, UDS_SESSION_SUPPLIER, UDS_SA_LEVEL_63, udsDidBuf.buffer_F189, BYTES_OF(udsDidBuf.buffer_F189)},
|
||||
{0xFD01, UDS_DID_TYPE_NVM_RO, UDS_SESSION_SUPPLIER, UDS_SA_LEVEL_63, udsDidBuf.buffer_FD01, BYTES_OF(udsDidBuf.buffer_FD01)},
|
||||
{0xFD02, UDS_DID_TYPE_NVM_RO, UDS_SESSION_SUPPLIER, UDS_SA_LEVEL_63, udsDidBuf.buffer_FD02, BYTES_OF(udsDidBuf.buffer_FD02)},
|
||||
{0xFD03, UDS_DID_TYPE_NVM_RO, UDS_SESSION_SUPPLIER, UDS_SA_LEVEL_63, udsDidBuf.buffer_FD03, BYTES_OF(udsDidBuf.buffer_FD03)},
|
||||
};
|
||||
|
||||
/*******************************************************************************
|
||||
* the functions
|
||||
******************************************************************************/
|
||||
|
||||
void Uds_UserInit(UdsType *obj, const Uds_ParamsType *pParams)
|
||||
{
|
||||
Uds_Init(obj, pParams);
|
||||
|
||||
obj->seviceTable = udsServiceTable;
|
||||
obj->securityTable = &udsSecurityTable[0][0];
|
||||
obj->serviceNum = UDS_SERVICE_NUM;
|
||||
obj->didTable = udsDidTable;
|
||||
obj->didNum = sizeof(udsDidTable) / sizeof(Uds_DidType);
|
||||
}
|
@ -1,76 +0,0 @@
|
||||
/*
|
||||
* Copyright (c) 2022, Shenzhen CVA Innovation CO.,LTD
|
||||
* All rights reserved.
|
||||
*
|
||||
* Shenzhen CVA Innovation CO.,LTD (CVA chip) is supplying this file for use
|
||||
* exclusively with CVA's microcontroller products. This file can be freely
|
||||
* distributed within development tools that are supporting such microcontroller
|
||||
* products.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED "AS IS". NO WARRANTIES, WHETHER EXPRESS, IMPLIED
|
||||
* OR STATUTORY, INCLUDING, BUT NOT LIMITED TO, IMPLIED WARRANTIES OF
|
||||
* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE APPLY TO THIS SOFTWARE.
|
||||
* CVA SHALL NOT, IN ANY CIRCUMSTANCES, BE LIABLE FOR SPECIAL, INCIDENTAL,
|
||||
* OR CONSEQUENTIAL DAMAGES, FOR ANY REASON WHATSOEVER.
|
||||
*/
|
||||
|
||||
#ifndef _UDS_USER_H_
|
||||
#define _UDS_USER_H_
|
||||
|
||||
/*! \brief Contains public interface to various functions related
|
||||
* to the user-defined UDS application
|
||||
*/
|
||||
|
||||
/*******************************************************************************
|
||||
* the includes
|
||||
******************************************************************************/
|
||||
|
||||
#include <stdbool.h>
|
||||
#include <stdint.h>
|
||||
#include "../stack/uds.h"
|
||||
#include "uds_service10.h"
|
||||
#include "uds_service11.h"
|
||||
#include "uds_service14.h"
|
||||
#include "uds_service19.h"
|
||||
#include "uds_service22.h"
|
||||
#include "uds_service27.h"
|
||||
#include "uds_service28.h"
|
||||
#include "uds_service2E.h"
|
||||
#include "uds_service2F.h"
|
||||
#include "uds_service31.h"
|
||||
#include "uds_service34.h"
|
||||
#include "uds_service36.h"
|
||||
#include "uds_service37.h"
|
||||
#include "uds_service3E.h"
|
||||
#include "uds_service85.h"
|
||||
#include "uds_dtc.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/*******************************************************************************
|
||||
* the defines
|
||||
******************************************************************************/
|
||||
|
||||
/*******************************************************************************
|
||||
* the typedefs
|
||||
******************************************************************************/
|
||||
|
||||
/*******************************************************************************
|
||||
* the globals
|
||||
******************************************************************************/
|
||||
|
||||
/*******************************************************************************
|
||||
* the function prototypes
|
||||
******************************************************************************/
|
||||
|
||||
/*! \brief Initialize the UDS object
|
||||
*/
|
||||
extern void Uds_UserInit(UdsType *obj, const Uds_ParamsType *pParams);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif /* extern "C" */
|
||||
|
||||
#endif /* _UDS_USER_H_ */
|
@ -64,7 +64,7 @@ void SystemInit(void)
|
||||
|
||||
#ifdef _USE_EXT_OSC_
|
||||
/* Use External oscillator */
|
||||
Scg0Reg_SetOscCtrlRange(SCG0, 3); /* set SOSC frequency range(use max value when SOSC as the clock source of the PLL) */
|
||||
Scg0Reg_SetOscCtrlRange(SCG0, 1); /* set SOSC frequency range(use max value when SOSC as the clock source of the PLL) */
|
||||
Scg0Reg_SetOscCtrlEnSosc(SCG0, 1); /* enable SOSC */
|
||||
while(Scg0Reg_GetStatusSoscRdy(SCG0) == 0)
|
||||
{
|
||||
@ -83,7 +83,7 @@ void SystemInit(void)
|
||||
*/
|
||||
Scg0Reg_SetPllCtrl1PllClkinSel(SCG0, 1);
|
||||
Scg0Reg_SetPllCtrl0PllPreDiv(SCG0, 0);
|
||||
Scg0Reg_SetPllCtrl0PllM(SCG0, 20);
|
||||
Scg0Reg_SetPllCtrl0PllM(SCG0, 40);
|
||||
Scg0Reg_SetPllCtrl0PllOutDiv(SCG0, 1);
|
||||
Scg0Reg_SetPllCtrl0PllPosDiv(SCG0, 2);
|
||||
/* Enable PLL */
|
||||
|
@ -36,7 +36,7 @@ extern "C" {
|
||||
******************************************************************************/
|
||||
|
||||
/* Value of the external crystal or oscillator clock frequency in Hz */
|
||||
#define CPU_XTAL_CLK_HZ (16000000u)
|
||||
#define CPU_XTAL_CLK_HZ (8000000u)
|
||||
#if CPU_XTAL_CLK_HZ > 40000000
|
||||
#error "The external crystal or oscillator clock frequency is out of range."
|
||||
#endif
|
||||
|
@ -41,9 +41,9 @@ define symbol m_interrupts_start = 0x00000000;
|
||||
define symbol m_interrupts_end = 0x000000BF;
|
||||
|
||||
define symbol m_bootinformation_start = 0x000000C0;
|
||||
define symbol m_bootinformation_end = 0x000000C3;
|
||||
define symbol m_bootinformation_end = 0x000000FF;
|
||||
|
||||
define symbol m_text_start = 0x00000C4;
|
||||
define symbol m_text_start = 0x0000100;
|
||||
define symbol m_text_end = 0x0000FFFF;
|
||||
|
||||
/* .data space */
|
||||
|
File diff suppressed because one or more lines are too long
@ -12,9 +12,15 @@
|
||||
<ByteLimit>50</ByteLimit>
|
||||
</Stack>
|
||||
<PlDriver>
|
||||
<FirstRun>0</FirstRun>
|
||||
<MemConfigValue>E:\Program Files\IAR Systems\Embedded Workbench 9.2\arm\config\debugger\CVAChip\CVM0128.ddf</MemConfigValue>
|
||||
</PlDriver>
|
||||
<JLinkDriver>
|
||||
<jlinkResetStyle>12</jlinkResetStyle>
|
||||
<jlinkResetStrategy>0</jlinkResetStrategy>
|
||||
<TraceBufferSize>0x10000</TraceBufferSize>
|
||||
<TraceStallIfFIFOFull>0x0</TraceStallIfFIFOFull>
|
||||
<TracePortSize>0x0</TracePortSize>
|
||||
<LeaveTargetRunning>_ 0</LeaveTargetRunning>
|
||||
<CStepIntDis>_ 0</CStepIntDis>
|
||||
</JLinkDriver>
|
||||
@ -22,6 +28,43 @@
|
||||
<EnableCache>0</EnableCache>
|
||||
<EnforceMemoryConfiguration>1</EnforceMemoryConfiguration>
|
||||
</ArmDriver>
|
||||
<DebugChecksum>
|
||||
<Checksum>3012610226</Checksum>
|
||||
</DebugChecksum>
|
||||
<Disassembly>
|
||||
<MixedMode>1</MixedMode>
|
||||
<InstrCount>0</InstrCount>
|
||||
</Disassembly>
|
||||
<Trace1>
|
||||
<Enabled>0</Enabled>
|
||||
<ShowSource>1</ShowSource>
|
||||
</Trace1>
|
||||
<TerminalIO>
|
||||
<InputSource>1</InputSource>
|
||||
<InputMode>10</InputMode>
|
||||
<Filename>$PROJ_DIR$\TermIOInput.txt</Filename>
|
||||
<InputEcho>1</InputEcho>
|
||||
<ShowReset>0</ShowReset>
|
||||
<InputEncoding>2</InputEncoding>
|
||||
<OutputEncoding>2</OutputEncoding>
|
||||
</TerminalIO>
|
||||
<Exceptions>
|
||||
<StopOnUncaught>_ 0</StopOnUncaught>
|
||||
<StopOnThrow>_ 0</StopOnThrow>
|
||||
</Exceptions>
|
||||
<CallStack>
|
||||
<ShowArgs>0</ShowArgs>
|
||||
</CallStack>
|
||||
<DriverProfiling>
|
||||
<Enabled>0</Enabled>
|
||||
<Mode>1</Mode>
|
||||
<Graph>0</Graph>
|
||||
<Symbiont>0</Symbiont>
|
||||
</DriverProfiling>
|
||||
<Trace2>
|
||||
<Enabled>0</Enabled>
|
||||
<ShowSource>0</ShowSource>
|
||||
</Trace2>
|
||||
<TermIOLog>
|
||||
<LoggingEnabled>_ 0</LoggingEnabled>
|
||||
<LogFile>_ ""</LogFile>
|
||||
|
File diff suppressed because one or more lines are too long
@ -775,9 +775,10 @@ void Bootloader_EventEmergeBootRequest(bool requestEn)
|
||||
*
|
||||
* \return void
|
||||
*/
|
||||
void Bootloader_EventResetRequest(bool requestEn)
|
||||
void Bootloader_EventResetRequest(bool requestEn,uint8_t resetMode)
|
||||
{
|
||||
sBootloader_Cb.resetReqEn = requestEn;
|
||||
sBootloader_Cb.resetReqMode = resetMode;
|
||||
#if BOOTLOADER_CFG_FLS_COPY_AUTO_EN == 0u
|
||||
sBootloader_Cb.flsDrvInfo.flashDriverDownloaded = false;
|
||||
#endif
|
||||
|
@ -190,6 +190,7 @@ typedef struct
|
||||
bool emergeBootReqEn;
|
||||
bool resetReqEn;
|
||||
bool resetActionReady;
|
||||
uint8_t resetReqMode;
|
||||
bool bootActive;
|
||||
#if BOOTLOADER_CFG_FLS_COPY_AUTO_EN == 0u
|
||||
Bootloader_FlsDrvInfoType flsDrvInfo;
|
||||
@ -309,7 +310,7 @@ extern void Bootloader_EventEmergeBootRequest(bool requestEn);
|
||||
*
|
||||
* \return void
|
||||
*/
|
||||
extern void Bootloader_EventResetRequest(bool requestEn);
|
||||
extern void Bootloader_EventResetRequest(bool requestEn,uint8_t resetMode);
|
||||
|
||||
/*! \brief Set the erase information
|
||||
*
|
||||
|
@ -98,11 +98,13 @@ typedef struct
|
||||
|
||||
typedef struct
|
||||
{
|
||||
uint8_t bootVersionGeneration;
|
||||
uint8_t bootVersionMajor;
|
||||
uint8_t bootVersionMinor;
|
||||
uint8_t bootVersionRevision;
|
||||
} Bootloade_CfgInfoType;
|
||||
uint8_t HWVersion[4];
|
||||
uint8_t BLVersion[8];
|
||||
uint8_t bootBuildTime[12];
|
||||
uint8_t bootBuildDate[16];
|
||||
uint8_t ECUName[8];
|
||||
uint8_t Reverse[16];
|
||||
} Bootloade_CfgInfoType;//64 byte
|
||||
|
||||
/*******************************************************************************
|
||||
* the globals
|
||||
|
@ -37,7 +37,7 @@
|
||||
#define UDS_PHYS_RESP_MSG_ID (0x7B2)
|
||||
|
||||
#define UDS_RECV_BUF (1026)
|
||||
#define UDS_SEND_BUF (8)
|
||||
#define UDS_SEND_BUF UDS_RSP_LEN_MAX
|
||||
|
||||
#define CAN_DATA_BUFFER_SIZE (8u)
|
||||
#define CAN_BUFFER_FIFO_SIZE (16u)
|
||||
@ -92,10 +92,14 @@ static uint32_t sBootloader_Req ;
|
||||
|
||||
#pragma location = ".bootloaderInfo"
|
||||
const Bootloade_CfgInfoType sBootloader_Version __attribute__((used, section(".bootloaderInfo"))) = {
|
||||
.bootVersionGeneration = 0,
|
||||
.bootVersionMajor = 0x14,
|
||||
.bootVersionMinor = 0x06,
|
||||
.bootVersionRevision = 0};
|
||||
.HWVersion = "HW01",
|
||||
.BLVersion = "BL0101",
|
||||
.bootBuildDate = __DATE__,
|
||||
.bootBuildTime = __TIME__,
|
||||
.ECUName = "RP-77A",
|
||||
};
|
||||
|
||||
|
||||
|
||||
McuType mcu;
|
||||
volatile uint32_t gSystick1msEvent = 0, gSystick1msCnt = 0, gTestIoEn = 0;
|
||||
@ -832,22 +836,6 @@ int main(void)
|
||||
flexCanCfg.msgCfg = msgCfgObj;
|
||||
FlexCanBoot_Init();
|
||||
|
||||
/* LED */
|
||||
PinsDrv_SetMuxModeSel(&mcu.ptc, 3, PINSDRV_MUX_AS_GPIO);
|
||||
PinsDrv_SetPinDirection(&mcu.ptc, 3, 1);
|
||||
PinsDrv_SetPullSel(&mcu.ptc, 3, PINSDRV_INTERNAL_PULL_UP);
|
||||
PinsDrv_WritePin(&mcu.ptc, 3, 0);
|
||||
|
||||
PinsDrv_SetMuxModeSel(&mcu.ptc, 1, PINSDRV_MUX_AS_GPIO);
|
||||
PinsDrv_SetPinDirection(&mcu.ptc, 1, 1);
|
||||
PinsDrv_SetPullSel(&mcu.ptc, 1, PINSDRV_INTERNAL_PULL_UP);
|
||||
PinsDrv_WritePin(&mcu.ptc, 1, 0);
|
||||
|
||||
PinsDrv_SetMuxModeSel(&mcu.ptc, 2, PINSDRV_MUX_AS_GPIO);
|
||||
PinsDrv_SetPinDirection(&mcu.ptc, 2, 1);
|
||||
PinsDrv_SetPullSel(&mcu.ptc, 2, PINSDRV_INTERNAL_PULL_UP);
|
||||
PinsDrv_WritePin(&mcu.ptc, 2, 0);
|
||||
|
||||
/* UDS init */
|
||||
Uds_UserInit(&udsObj, &udsParam);
|
||||
|
||||
@ -875,40 +863,28 @@ int main(void)
|
||||
if(gTestIoEn == 0)
|
||||
{
|
||||
gTestIoEn = 1;
|
||||
if(resetSource == 1)
|
||||
{
|
||||
PinsDrv_WritePin(&mcu.ptc, 1, 1);
|
||||
PinsDrv_WritePin(&mcu.ptc, 2, 0);
|
||||
PinsDrv_WritePin(&mcu.ptc, 3, 0);
|
||||
}
|
||||
else if(resetSource == 2)
|
||||
{
|
||||
PinsDrv_WritePin(&mcu.ptc, 1, 1);
|
||||
PinsDrv_WritePin(&mcu.ptc, 2, 0);
|
||||
PinsDrv_WritePin(&mcu.ptc, 3, 1);
|
||||
}
|
||||
|
||||
}
|
||||
else
|
||||
{
|
||||
gTestIoEn = 0;
|
||||
PinsDrv_WritePin(&mcu.ptc, 1, 0);
|
||||
PinsDrv_WritePin(&mcu.ptc, 2, 0);
|
||||
PinsDrv_WritePin(&mcu.ptc, 3, 0);
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
/* Handler user routine */
|
||||
if(FlexCanBoot_ReadoutMsg(&rxMsg) == true)
|
||||
{
|
||||
if((rxMsg.id == UDS_PHYS_RECV_MSG_ID) || (rxMsg.id == UDS_FUNC_RECV_MSG_ID))
|
||||
{
|
||||
IsoTp_HandleIncomingCanMsg(&udsObj.isotp, rxMsg.id, rxMsg.data, rxMsg.len);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Bootloader_TimingProcess(1);
|
||||
Uds_Run(&udsObj);
|
||||
Bootloader_StateProc();
|
||||
}
|
||||
/* Handler user routine */
|
||||
if(FlexCanBoot_ReadoutMsg(&rxMsg) == true)
|
||||
{
|
||||
if((rxMsg.id == UDS_PHYS_RECV_MSG_ID) || (rxMsg.id == UDS_FUNC_RECV_MSG_ID))
|
||||
{
|
||||
IsoTp_HandleIncomingCanMsg(&udsObj.isotp, rxMsg.id, rxMsg.data, rxMsg.len);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -119,6 +119,8 @@
|
||||
#define IsoTp_SetFCStmin(byte, STmin) (byte[2] = STmin)
|
||||
#define IsoTp_GetFCStmin(byte) (byte[2])
|
||||
|
||||
#define TP_DUMMY 0xCC
|
||||
|
||||
/*******************************************************************************
|
||||
* the typedefs
|
||||
******************************************************************************/
|
||||
@ -242,8 +244,9 @@ static int8_t IsoTp_SendSingleFrame(IsoTpType *obj)
|
||||
/* All pad with 0 */
|
||||
for(i = 0; i < 7 - obj->sendSize; ++i)
|
||||
{
|
||||
msg.byte[i + obj->sendSize + 1] = 0;
|
||||
msg.byte[i + obj->sendSize + 1] = TP_DUMMY;
|
||||
}
|
||||
|
||||
ret = obj->sendCanMsg(obj->sendArbitrationId, msg.byte, 8);
|
||||
}
|
||||
else
|
||||
@ -306,7 +309,7 @@ static int8_t IsoTp_SendConsecutiveFrame(IsoTpType *obj)
|
||||
uint8_t i = 0;
|
||||
for(i = 0; i < 7 - dataLength; ++i)
|
||||
{
|
||||
msg.byte[i + 1 + dataLength] = 0;
|
||||
msg.byte[i + 1 + dataLength] = TP_DUMMY;
|
||||
}
|
||||
ret = obj->sendCanMsg(obj->sendArbitrationId, msg.byte, 8);
|
||||
}
|
||||
@ -653,17 +656,16 @@ void IsoTp_HandleIncomingCanMsg(IsoTpType *obj, uint32_t id, const uint8_t *data
|
||||
else
|
||||
{
|
||||
/* Send FC when BS reaches limit */
|
||||
if(obj->blockSize > 0)
|
||||
{
|
||||
if(0 == --obj->receiveBlockSizeCount)
|
||||
{
|
||||
|
||||
obj->receiveBlockSizeCount = obj->blockSize;
|
||||
IsoTp_SendFlowControl(obj, ISOTP_PCI_FLOW_STATUS_CONTINUE, obj->receiveBlockSizeCount, ISOTP_DEFAULT_ST_MIN);
|
||||
}
|
||||
}
|
||||
if(obj->blockSize > 0)
|
||||
{
|
||||
if(0 == --obj->receiveBlockSizeCount)
|
||||
{
|
||||
obj->receiveBlockSizeCount = obj->blockSize;
|
||||
IsoTp_SendFlowControl(obj, ISOTP_PCI_FLOW_STATUS_CONTINUE, obj->receiveBlockSizeCount, ISOTP_DEFAULT_ST_MIN);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
break;
|
||||
}
|
||||
|
@ -71,9 +71,7 @@ extern "C" {
|
||||
#define UDS_SA_NONE (0)
|
||||
#define UDS_SA_LEVEL_1 (0x01)
|
||||
#define UDS_SA_LEVEL_3 (0x03)
|
||||
#define UDS_SA_LEVEL_9 (0x09)
|
||||
#define UDS_SA_LEVEL_3 (0x03)
|
||||
#define UDS_SA_LEVEL_11 (0x11)
|
||||
#define UDS_SA_LEVEL_09 (0x09)
|
||||
#define UDS_SA_LEVEL_63 (0x63)
|
||||
|
||||
#define UDS_SESSION_DEFAULT (0x01)
|
||||
|
@ -1,221 +0,0 @@
|
||||
/*
|
||||
* Copyright (c) 2022, Shenzhen CVA Innovation CO.,LTD
|
||||
* All rights reserved.
|
||||
*
|
||||
* Shenzhen CVA Innovation CO.,LTD (CVA chip) is supplying this file for use
|
||||
* exclusively with CVA's microcontroller products. This file can be freely
|
||||
* distributed within development tools that are supporting such microcontroller
|
||||
* products.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED "AS IS". NO WARRANTIES, WHETHER EXPRESS, IMPLIED
|
||||
* OR STATUTORY, INCLUDING, BUT NOT LIMITED TO, IMPLIED WARRANTIES OF
|
||||
* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE APPLY TO THIS SOFTWARE.
|
||||
* CVA SHALL NOT, IN ANY CIRCUMSTANCES, BE LIABLE FOR SPECIAL, INCIDENTAL,
|
||||
* OR CONSEQUENTIAL DAMAGES, FOR ANY REASON WHATSOEVER.
|
||||
*/
|
||||
|
||||
/*******************************************************************************
|
||||
* the includes
|
||||
******************************************************************************/
|
||||
|
||||
#include "uds_dtc.h"
|
||||
|
||||
/*******************************************************************************
|
||||
* the defines
|
||||
******************************************************************************/
|
||||
|
||||
#define DTCG_EMISSION_START (0x00000000ul) /* 24Bit DTC define ISO-15031-6 DTC + ISO-15031-6 Failure Type, ISO14229-1 format */
|
||||
#define DTCG_EMISSION_END (0x000FFFFFul)
|
||||
#define DTCG_POWERTRAIN_START (0x00100000ul)
|
||||
#define DTCG_POWERTRAIN_END (0x003FFFFFul)
|
||||
#define DTCG_CHASSIS_START (0x00400000ul)
|
||||
#define DTCG_CHASSIS_END (0x007FFFFFul)
|
||||
#define DTCG_BODY_START (0x00800000ul)
|
||||
#define DTCG_BODY_END (0x00BFFFFFul)
|
||||
#define DTCG_NETWORK_START (0x00C00000ul)
|
||||
#define DTCG_NETWORK_END (0x00FFFFFFul)
|
||||
|
||||
#define FAULTDT_MAX (127) /* refers to ISO14229-1 D.6 */
|
||||
#define FAULTDT_MIN (-128) /* refers to ISO14229-1 D.6 */
|
||||
#define AGING_MAX (40) /* refers to ISO14229-1 D.7 */
|
||||
|
||||
/*******************************************************************************
|
||||
* the typedefs
|
||||
******************************************************************************/
|
||||
|
||||
/*******************************************************************************
|
||||
* the globals
|
||||
******************************************************************************/
|
||||
|
||||
/* the meaning of UDS DTC value refers to ISO 15031-6 */
|
||||
static Uds_DtcType udsDtcTable[DTC_MAX_COUNT] = {
|
||||
{0x04621A, 0x50, 0x00, 0x00}, /* P0462 fuel level sensor "A" circuit resistance low */
|
||||
{0x04631B, 0x50, 0x00, 0x00}, /* P0463 fuel level sensor "A" circuit resistance high */
|
||||
{0xF00316, 0x50, 0x00, 0x00}, /* U3003 battery voltage low */
|
||||
{0xF00317, 0x50, 0x00, 0x00}, /* U3003 battery voltage high */
|
||||
{0xC07388, 0x50, 0x00, 0x00}, /* U0073 control module communication bus off */
|
||||
{0xC10001, 0x50, 0x00, 0x00}, /* U0100 lost communication with ECM/PCM "A" */
|
||||
{0xC10101, 0x50, 0x00, 0x00}, /* U0101 lost communication with TCM */
|
||||
{0xC12101, 0x50, 0x00, 0x00}, /* U0121 lost communication with ABS control module */
|
||||
{0xC12701, 0x50, 0x00, 0x00}, /* U0127 lost communication with tire pressure monitor module */
|
||||
{0xC12801, 0x50, 0x00, 0x00}, /* U0128 lost communication with park brake control module */
|
||||
{0xC12901, 0x50, 0x00, 0x00}, /* U0129 lost communication with brake system control module */
|
||||
{0xC13101, 0x50, 0x00, 0x00}, /* U0131 lost communication with power sterring control module */
|
||||
{0xC14100, 0x50, 0x00, 0x00}, /* U0141 lost communication with body control module "A" */
|
||||
{0xC15101, 0x50, 0x00, 0x00}, /* U0151 lost communication with restraints control module */
|
||||
{0xC16300, 0x50, 0x00, 0x00}, /* U0163 lost communication with navigation control module */
|
||||
{0xC16900, 0x50, 0x00, 0x00}, /* U0169 lost communication with sunroof control module */
|
||||
{0xC18101, 0x50, 0x00, 0x00}, /* U0181 lost communication with headlamp leveling control module */
|
||||
{0xC23601, 0x50, 0x00, 0x00}, /* U0236 lost communication with column lock module */
|
||||
{0xC16400, 0x50, 0x00, 0x00}, /* U0164 lost communication with HVAC control module */
|
||||
{0xC16700, 0x50, 0x00, 0x00}, /* U0167 lost communication with vehicle immobilizer control module */
|
||||
};
|
||||
|
||||
static bool dtcOffCtrl = false;
|
||||
|
||||
/*******************************************************************************
|
||||
* the constants
|
||||
******************************************************************************/
|
||||
|
||||
/*******************************************************************************
|
||||
* the functions
|
||||
******************************************************************************/
|
||||
|
||||
void Uds_SetDtcOffCtrl(bool val)
|
||||
{
|
||||
dtcOffCtrl = val;
|
||||
}
|
||||
|
||||
bool Uds_GetDtcOffCtrlState(void)
|
||||
{
|
||||
return dtcOffCtrl;
|
||||
}
|
||||
|
||||
void Uds_ClearDtcByDtcIndex(uint16_t dtcIndex)
|
||||
{
|
||||
if(dtcIndex >= DTC_MAX_COUNT)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
udsDtcTable[dtcIndex].dtcStatus.all = 0;
|
||||
udsDtcTable[dtcIndex].dtcStatus.bit.testNcmpSlc = 1;
|
||||
udsDtcTable[dtcIndex].dtcStatus.bit.testNcmpToc = 1;
|
||||
|
||||
udsDtcTable[dtcIndex].faultDtCnt = 0;
|
||||
udsDtcTable[dtcIndex].AgingCnt = 0;
|
||||
}
|
||||
|
||||
void Uds_LoadDtc(void)
|
||||
{
|
||||
/* code implemented by the user */
|
||||
}
|
||||
|
||||
void Uds_SaveDtc(void)
|
||||
{
|
||||
/* code implemented by the user */
|
||||
}
|
||||
|
||||
uint16_t Uds_GetDtcNumberByStatusMask(uint8_t mask)
|
||||
{
|
||||
uint16_t dtcCnt = 0;
|
||||
uint8_t dtcState = 0;
|
||||
uint16_t dtcNum = 0;
|
||||
|
||||
for(dtcCnt = 0; dtcCnt < DTC_MAX_COUNT; dtcCnt++)
|
||||
{
|
||||
dtcState = (udsDtcTable[dtcCnt].dtcStatus.all & DTC_AVAILABILITY_STATUS_MASK);
|
||||
if(0 != (dtcState & mask))
|
||||
{
|
||||
dtcNum++;
|
||||
}
|
||||
}
|
||||
|
||||
return dtcNum;
|
||||
}
|
||||
|
||||
uint16_t Uds_GetDtcByStatusMask(uint8_t *pDtcBuf, uint16_t bufLen, uint8_t mask)
|
||||
{
|
||||
uint16_t dtcCnt = 0;
|
||||
uint8_t dtcState = 0;
|
||||
uint16_t dtcDlc = 0;
|
||||
|
||||
for(dtcCnt = 0; dtcCnt < DTC_MAX_COUNT; dtcCnt++)
|
||||
{
|
||||
dtcState = udsDtcTable[dtcCnt].dtcStatus.all;
|
||||
if(0 != (dtcState & mask))
|
||||
{
|
||||
if((dtcDlc + 4) <= bufLen)
|
||||
{
|
||||
pDtcBuf[dtcDlc++] = (uint8_t)(udsDtcTable[dtcCnt].dtcCode >> 16);
|
||||
pDtcBuf[dtcDlc++] = (uint8_t)(udsDtcTable[dtcCnt].dtcCode >> 8);
|
||||
pDtcBuf[dtcDlc++] = (uint8_t)(udsDtcTable[dtcCnt].dtcCode >> 0);
|
||||
pDtcBuf[dtcDlc++] = (dtcState & DTC_AVAILABILITY_STATUS_MASK);
|
||||
}
|
||||
else
|
||||
{
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return dtcDlc;
|
||||
}
|
||||
|
||||
uint16_t Uds_GetSupportedDtc(uint8_t *pDtcBuf, uint16_t bufLen)
|
||||
{
|
||||
uint16_t dtcCnt = 0;
|
||||
uint8_t dtcState = 0;
|
||||
uint16_t dtcDlc = 0;
|
||||
|
||||
for(dtcCnt = 0; dtcCnt < DTC_MAX_COUNT; dtcCnt++)
|
||||
{
|
||||
dtcState = udsDtcTable[dtcCnt].dtcStatus.all;
|
||||
if((dtcDlc + 4) <= bufLen)
|
||||
{
|
||||
pDtcBuf[dtcDlc++] = (uint8_t)(udsDtcTable[dtcCnt].dtcCode >> 16);
|
||||
pDtcBuf[dtcDlc++] = (uint8_t)(udsDtcTable[dtcCnt].dtcCode >> 8);
|
||||
pDtcBuf[dtcDlc++] = (uint8_t)(udsDtcTable[dtcCnt].dtcCode >> 0);
|
||||
pDtcBuf[dtcDlc++] = (dtcState & DTC_AVAILABILITY_STATUS_MASK);
|
||||
}
|
||||
else
|
||||
{
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
return dtcDlc;
|
||||
}
|
||||
|
||||
void Uds_ClearDtcByGroup(uint32_t group)
|
||||
{
|
||||
uint16_t dtcCnt = 0;
|
||||
|
||||
switch(group)
|
||||
{
|
||||
case EMISSION_SYSTEM_GROUP:
|
||||
for(dtcCnt = 0; dtcCnt < DTC_MAX_COUNT; dtcCnt++)
|
||||
{
|
||||
if(udsDtcTable[dtcCnt].dtcCode <= DTCG_EMISSION_END)
|
||||
{
|
||||
Uds_ClearDtcByDtcIndex(dtcCnt);
|
||||
}
|
||||
}
|
||||
break;
|
||||
case SAFETY_SYSTEM_GROUP:
|
||||
for(dtcCnt = 0; dtcCnt < DTC_MAX_COUNT; dtcCnt++)
|
||||
{
|
||||
if((udsDtcTable[dtcCnt].dtcCode >= DTCG_CHASSIS_START) && (udsDtcTable[dtcCnt].dtcCode <= DTCG_CHASSIS_END))
|
||||
{
|
||||
Uds_ClearDtcByDtcIndex(dtcCnt);
|
||||
}
|
||||
}
|
||||
break;
|
||||
case ALL_FUNC_SYSTEM_GROUP:
|
||||
for(dtcCnt = 0; dtcCnt < DTC_MAX_COUNT; dtcCnt++)
|
||||
{
|
||||
Uds_ClearDtcByDtcIndex(dtcCnt);
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
@ -1,175 +0,0 @@
|
||||
/*
|
||||
* Copyright (c) 2022, Shenzhen CVA Innovation CO.,LTD
|
||||
* All rights reserved.
|
||||
*
|
||||
* Shenzhen CVA Innovation CO.,LTD (CVA chip) is supplying this file for use
|
||||
* exclusively with CVA's microcontroller products. This file can be freely
|
||||
* distributed within development tools that are supporting such microcontroller
|
||||
* products.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED "AS IS". NO WARRANTIES, WHETHER EXPRESS, IMPLIED
|
||||
* OR STATUTORY, INCLUDING, BUT NOT LIMITED TO, IMPLIED WARRANTIES OF
|
||||
* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE APPLY TO THIS SOFTWARE.
|
||||
* CVA SHALL NOT, IN ANY CIRCUMSTANCES, BE LIABLE FOR SPECIAL, INCIDENTAL,
|
||||
* OR CONSEQUENTIAL DAMAGES, FOR ANY REASON WHATSOEVER.
|
||||
*/
|
||||
|
||||
#ifndef _UDS_DTC_H_
|
||||
#define _UDS_DTC_H_
|
||||
|
||||
/*! \brief Contains public interface to various functions related
|
||||
* to the user-defined UDS application
|
||||
*/
|
||||
|
||||
/*******************************************************************************
|
||||
* the includes
|
||||
******************************************************************************/
|
||||
|
||||
#include <stdbool.h>
|
||||
#include <stdint.h>
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/*******************************************************************************
|
||||
* the defines
|
||||
******************************************************************************/
|
||||
|
||||
#define EMISSION_SYSTEM_GROUP (0x00FFFF33)
|
||||
#define SAFETY_SYSTEM_GROUP (0x00FFFFD0)
|
||||
#define ALL_FUNC_SYSTEM_GROUP (0x00FFFFFF)
|
||||
|
||||
#define REPORT_DTC_NUMBER_BY_STATUS_MASK (0x01)
|
||||
#define REPORT_DTC_BY_STATUS_MASK (0x02)
|
||||
#define REPORT_DTC_SNOPSHOT_IDENTIFICATION (0x03)
|
||||
#define REPORT_DTC_SNOPSHOT_RECORD_BY_DTC_NUMBER (0x04)
|
||||
#define REPORT_DTC_STORE_DATA_BY_RECORD_NUMBER (0x05)
|
||||
#define REPORT_DTC_EXT_DATA_RECORD_BY_DTC_NUMBER (0x06)
|
||||
#define REPORT_DTC_NUMBER_BY_SEVERITY_MASK_RECORD (0x07)
|
||||
#define REPORT_DTC_BY_SEVERITY_MASK_RECORD (0x08)
|
||||
#define REPORT_SUPPORTED_DTC (0x0a)
|
||||
|
||||
#define DTC_FORMAT_15031 (0x00)
|
||||
#define DTC_FORMAT_14229 (0x01)
|
||||
#define DTC_FORMAT_J1939 (0x02)
|
||||
#define DTC_FORMAT_11992 (0x03)
|
||||
|
||||
#define DTC_AVAILABILITY_STATUS_MASK (0x7F)
|
||||
|
||||
/*******************************************************************************
|
||||
* the typedefs
|
||||
******************************************************************************/
|
||||
|
||||
/*! \brief The DTC Index name of UDS supported
|
||||
*/
|
||||
typedef enum _Uds_DtcIndexNameType_
|
||||
{
|
||||
DTC_FUEL_SENSOR_BELOW = 0,
|
||||
DTC_FUEL_SENSOR_ABOVE,
|
||||
DTC_BATT_VOLTAG_BELOW,
|
||||
DTC_BATT_VOLTAG_ABOVE,
|
||||
DTC_CAN_BUS_OFF,
|
||||
DTC_COM_LOST_EMS,
|
||||
DTC_COM_LOST_TCU,
|
||||
DTC_COM_LOST_ABS,
|
||||
DTC_COM_LOST_TPMS,
|
||||
DTC_COM_LOST_EPB,
|
||||
DTC_COM_LOST_ESP,
|
||||
DTC_COM_LOST_EPS,
|
||||
DTC_COM_LOST_BCM,
|
||||
DTC_COM_LOST_SRS,
|
||||
DTC_COM_LOST_DVD,
|
||||
DTC_COM_LOST_PDC,
|
||||
DTC_COM_LOST_ALS,
|
||||
DTC_COM_LOST_PEPS,
|
||||
DTC_COM_LOST_AC,
|
||||
DTC_COM_LOST_AVM,
|
||||
DTC_MAX_COUNT
|
||||
} Uds_DtcIndexNameType;
|
||||
|
||||
/*! \brief The DTC status definition refers to ISO14229-1 D.2.4
|
||||
* \note Bit 0, testFailed, clear by test pass or ClearDiagnosticInformation
|
||||
* Bit 1, testFailedThisOperationCycle, clear by new OC or ClearDiagnosticInformation
|
||||
* Bit 2, latch, pendingDTC, clear by fault never happened in cur OC or ClearDiagnosticInformation, if test not completed, must hold.
|
||||
* Bit 3, latch, confirmedDTC, clear by ClearDiagnosticInformation, one(only by normal fault) or 40 OC not detect any fault.
|
||||
* Bit 4, latch, testNotCompletedSinceLastClear, set by a new OC start or ClearDiagnosticInformation
|
||||
* Bit 5, latch, testFailedSinceLastClear, clear by ClearDiagnosticInformation
|
||||
* Bit 6, testNotCompletedThisOperationCycle
|
||||
* Bit 7, warningIndicatorRequested(unsupported)
|
||||
*/
|
||||
typedef union _Uds_DtcStatusType_
|
||||
{
|
||||
uint8_t all;
|
||||
struct
|
||||
{
|
||||
uint8_t testFailed : 1;
|
||||
uint8_t testFailToc : 1;
|
||||
uint8_t pending : 1;
|
||||
uint8_t confirmed : 1;
|
||||
uint8_t testNcmpSlc : 1;
|
||||
uint8_t testFailSlc : 1;
|
||||
uint8_t testNcmpToc : 1;
|
||||
uint8_t wnIndreq : 1;
|
||||
} bit;
|
||||
} Uds_DtcStatusType;
|
||||
|
||||
/*! \brief The DTC definition of UDS
|
||||
*/
|
||||
typedef struct _Uds_DtcType_
|
||||
{
|
||||
uint32_t dtcCode;
|
||||
Uds_DtcStatusType dtcStatus;
|
||||
int16_t faultDtCnt; /* refers to ISO14229-1 D.6 */
|
||||
uint8_t AgingCnt; /* refers to ISO14229-1 D.7 */
|
||||
} Uds_DtcType;
|
||||
|
||||
/*******************************************************************************
|
||||
* the globals
|
||||
******************************************************************************/
|
||||
|
||||
/*******************************************************************************
|
||||
* the function prototypes
|
||||
******************************************************************************/
|
||||
|
||||
/*! \brief control DTC status updata stop and start
|
||||
*/
|
||||
extern void Uds_SetDtcOffCtrl(bool val);
|
||||
|
||||
/*! \brief get control DTC status
|
||||
*/
|
||||
extern bool Uds_GetDtcOffCtrlState(void);
|
||||
|
||||
/*! \brief clear DTC by dtc index
|
||||
*/
|
||||
extern void Uds_ClearDtcByDtcIndex(uint16_t dtcIndex);
|
||||
|
||||
/*! \brief load dtc data from EEPROM
|
||||
*/
|
||||
extern void Uds_LoadDtc(void);
|
||||
|
||||
/*! \brief save dtc data to EEPROM
|
||||
*/
|
||||
extern void Uds_SaveDtc(void);
|
||||
|
||||
/*! \brief get DTC counter by dtc status mask
|
||||
*/
|
||||
extern uint16_t Uds_GetDtcNumberByStatusMask(uint8_t mask);
|
||||
|
||||
/*! \brief get DTC data by dtc status mask
|
||||
*/
|
||||
extern uint16_t Uds_GetDtcByStatusMask(uint8_t *pDtcBuf, uint16_t bufLen, uint8_t mask);
|
||||
|
||||
/*! \brief get all supported DTC data
|
||||
*/
|
||||
extern uint16_t Uds_GetSupportedDtc(uint8_t *pDtcBuf, uint16_t bufLen);
|
||||
|
||||
/*! \brief clear DTC by dtc group
|
||||
*/
|
||||
extern void Uds_ClearDtcByGroup(uint32_t group);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif /* extern "C" */
|
||||
|
||||
#endif /* _UDS_DTC_H_ */
|
@ -1,76 +0,0 @@
|
||||
/*
|
||||
* Copyright (c) 2022, Shenzhen CVA Innovation CO.,LTD
|
||||
* All rights reserved.
|
||||
*
|
||||
* Shenzhen CVA Innovation CO.,LTD (CVA chip) is supplying this file for use
|
||||
* exclusively with CVA's microcontroller products. This file can be freely
|
||||
* distributed within development tools that are supporting such microcontroller
|
||||
* products.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED "AS IS". NO WARRANTIES, WHETHER EXPRESS, IMPLIED
|
||||
* OR STATUTORY, INCLUDING, BUT NOT LIMITED TO, IMPLIED WARRANTIES OF
|
||||
* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE APPLY TO THIS SOFTWARE.
|
||||
* CVA SHALL NOT, IN ANY CIRCUMSTANCES, BE LIABLE FOR SPECIAL, INCIDENTAL,
|
||||
* OR CONSEQUENTIAL DAMAGES, FOR ANY REASON WHATSOEVER.
|
||||
*/
|
||||
|
||||
/*******************************************************************************
|
||||
* the includes
|
||||
******************************************************************************/
|
||||
|
||||
#include "uds_service14.h"
|
||||
#include "uds_dtc.h"
|
||||
|
||||
/*******************************************************************************
|
||||
* the defines
|
||||
******************************************************************************/
|
||||
|
||||
/*******************************************************************************
|
||||
* the typedefs
|
||||
******************************************************************************/
|
||||
|
||||
/*******************************************************************************
|
||||
* the globals
|
||||
******************************************************************************/
|
||||
|
||||
/*******************************************************************************
|
||||
* the constants
|
||||
******************************************************************************/
|
||||
|
||||
/*******************************************************************************
|
||||
* the functions
|
||||
******************************************************************************/
|
||||
|
||||
void UdsService14_ClearDiagInfo(UdsType *obj, const uint8_t msgBuf[], uint16_t msgLen)
|
||||
{
|
||||
uint32_t dtcGroup = 0;
|
||||
uint8_t rspBuffer[8] = {0};
|
||||
|
||||
if(msgLen != obj->seviceTable[obj->curServiceIdx].minLen)
|
||||
{
|
||||
Uds_NegativeResponse(obj, 0x14, NRC_INVALID_MESSAGE_LENGTH_OR_FORMAT);
|
||||
return;
|
||||
}
|
||||
|
||||
dtcGroup |= ((uint32_t)msgBuf[1]) << 16;
|
||||
dtcGroup |= ((uint32_t)msgBuf[2]) << 8;
|
||||
dtcGroup |= ((uint32_t)msgBuf[3]) << 0;
|
||||
|
||||
rspBuffer[0] = UDS_GET_POSITIVE_RSP(0x14);
|
||||
|
||||
switch(dtcGroup)
|
||||
{
|
||||
case EMISSION_SYSTEM_GROUP:
|
||||
case SAFETY_SYSTEM_GROUP:
|
||||
case ALL_FUNC_SYSTEM_GROUP:
|
||||
Uds_ClearDtcByGroup(dtcGroup);
|
||||
Uds_PositiveResponse(obj, rspBuffer, 1);
|
||||
break;
|
||||
default:
|
||||
Uds_NegativeResponse(obj, 0x14, NRC_REQUEST_OUT_OF_RANGE);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
@ -1,60 +0,0 @@
|
||||
/*
|
||||
* Copyright (c) 2022, Shenzhen CVA Innovation CO.,LTD
|
||||
* All rights reserved.
|
||||
*
|
||||
* Shenzhen CVA Innovation CO.,LTD (CVA chip) is supplying this file for use
|
||||
* exclusively with CVA's microcontroller products. This file can be freely
|
||||
* distributed within development tools that are supporting such microcontroller
|
||||
* products.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED "AS IS". NO WARRANTIES, WHETHER EXPRESS, IMPLIED
|
||||
* OR STATUTORY, INCLUDING, BUT NOT LIMITED TO, IMPLIED WARRANTIES OF
|
||||
* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE APPLY TO THIS SOFTWARE.
|
||||
* CVA SHALL NOT, IN ANY CIRCUMSTANCES, BE LIABLE FOR SPECIAL, INCIDENTAL,
|
||||
* OR CONSEQUENTIAL DAMAGES, FOR ANY REASON WHATSOEVER.
|
||||
*/
|
||||
|
||||
#ifndef _UDS_SERVICE14_H_
|
||||
#define _UDS_SERVICE14_H_
|
||||
|
||||
/*! \brief Contains public interface to various functions related
|
||||
* to the user-defined UDS service 14
|
||||
*/
|
||||
|
||||
/*******************************************************************************
|
||||
* the includes
|
||||
******************************************************************************/
|
||||
|
||||
#include <stdbool.h>
|
||||
#include <stdint.h>
|
||||
#include "../stack/uds.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/*******************************************************************************
|
||||
* the defines
|
||||
******************************************************************************/
|
||||
|
||||
/*******************************************************************************
|
||||
* the typedefs
|
||||
******************************************************************************/
|
||||
|
||||
/*******************************************************************************
|
||||
* the globals
|
||||
******************************************************************************/
|
||||
|
||||
/*******************************************************************************
|
||||
* the function prototypes
|
||||
******************************************************************************/
|
||||
|
||||
/*! \brief Uds Service 14 processing
|
||||
*/
|
||||
extern void UdsService14_ClearDiagInfo(UdsType *obj, const uint8_t msgBuf[], uint16_t msgLen);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif /* extern "C" */
|
||||
|
||||
#endif /* _UDS_SERVICE14_H_ */
|
@ -1,163 +0,0 @@
|
||||
/*
|
||||
* Copyright (c) 2022, Shenzhen CVA Innovation CO.,LTD
|
||||
* All rights reserved.
|
||||
*
|
||||
* Shenzhen CVA Innovation CO.,LTD (CVA chip) is supplying this file for use
|
||||
* exclusively with CVA's microcontroller products. This file can be freely
|
||||
* distributed within development tools that are supporting such microcontroller
|
||||
* products.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED "AS IS". NO WARRANTIES, WHETHER EXPRESS, IMPLIED
|
||||
* OR STATUTORY, INCLUDING, BUT NOT LIMITED TO, IMPLIED WARRANTIES OF
|
||||
* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE APPLY TO THIS SOFTWARE.
|
||||
* CVA SHALL NOT, IN ANY CIRCUMSTANCES, BE LIABLE FOR SPECIAL, INCIDENTAL,
|
||||
* OR CONSEQUENTIAL DAMAGES, FOR ANY REASON WHATSOEVER.
|
||||
*/
|
||||
|
||||
/*******************************************************************************
|
||||
* the includes
|
||||
******************************************************************************/
|
||||
|
||||
#include "uds_service19.h"
|
||||
#include "uds_dtc.h"
|
||||
|
||||
|
||||
|
||||
/*******************************************************************************
|
||||
* the defines
|
||||
******************************************************************************/
|
||||
|
||||
/*******************************************************************************
|
||||
* the typedefs
|
||||
******************************************************************************/
|
||||
|
||||
/*******************************************************************************
|
||||
* the globals
|
||||
******************************************************************************/
|
||||
|
||||
/*******************************************************************************
|
||||
* the constants
|
||||
******************************************************************************/
|
||||
|
||||
/*******************************************************************************
|
||||
* the functions
|
||||
******************************************************************************/
|
||||
|
||||
void UdsService19_ReadDtcInformation(UdsType *obj, const uint8_t msgBuf[], uint16_t msgLen)
|
||||
{
|
||||
uint8_t subFunction = 0;
|
||||
uint8_t dtcStatusMask = 0;
|
||||
uint16_t dtcCount = 0;
|
||||
uint16_t dtcDlc = 0;
|
||||
uint8_t rspBuffer[UDS_RSP_LEN_MAX] = {0};
|
||||
|
||||
if(msgLen < obj->seviceTable[obj->curServiceIdx].minLen)
|
||||
{
|
||||
Uds_NegativeResponse(obj, 0x19, NRC_INVALID_MESSAGE_LENGTH_OR_FORMAT);
|
||||
return;
|
||||
}
|
||||
|
||||
subFunction = UDS_GET_SUB_FUNCTION (msgBuf[1]);
|
||||
rspBuffer[0] = UDS_GET_POSITIVE_RSP(0x19);
|
||||
rspBuffer[1] = subFunction;
|
||||
switch(subFunction)
|
||||
{
|
||||
case REPORT_DTC_NUMBER_BY_STATUS_MASK:
|
||||
if(msgLen != 3)
|
||||
{
|
||||
Uds_NegativeResponse(obj, 0x19, NRC_INVALID_MESSAGE_LENGTH_OR_FORMAT);
|
||||
return;
|
||||
}
|
||||
|
||||
dtcStatusMask = msgBuf[2];
|
||||
dtcCount = Uds_GetDtcNumberByStatusMask(dtcStatusMask);
|
||||
rspBuffer[2] = DTC_AVAILABILITY_STATUS_MASK;
|
||||
rspBuffer[3] = DTC_FORMAT_14229;
|
||||
rspBuffer[4] = (dtcCount >> 8) & 0xFF;
|
||||
rspBuffer[5] = (dtcCount >> 0) & 0xFF;
|
||||
Uds_PositiveResponse(obj, rspBuffer, 6);
|
||||
break;
|
||||
case REPORT_DTC_BY_STATUS_MASK:
|
||||
if(msgLen != 3)
|
||||
{
|
||||
Uds_NegativeResponse(obj, 0x19, NRC_INVALID_MESSAGE_LENGTH_OR_FORMAT);
|
||||
return;
|
||||
}
|
||||
dtcStatusMask = msgBuf[2];
|
||||
rspBuffer[2] = DTC_AVAILABILITY_STATUS_MASK;
|
||||
dtcDlc = Uds_GetDtcByStatusMask(&rspBuffer[3], UDS_RSP_LEN_MAX - 3, dtcStatusMask);
|
||||
Uds_PositiveResponse(obj, rspBuffer, dtcDlc + 3);
|
||||
break;
|
||||
#if 0
|
||||
case REPORT_DTC_SNOPSHOT_IDENTIFICATION:
|
||||
if(msgLen != 6)
|
||||
{
|
||||
UDS_negativeResponse(obj, 0x19, NRC_INVALID_MESSAGE_LENGTH_OR_FORMAT);
|
||||
return;
|
||||
}
|
||||
/* add user code */
|
||||
|
||||
break;
|
||||
case REPORT_DTC_SNOPSHOT_RECORD_BY_DTC_NUMBER:
|
||||
if(msgLen != 6)
|
||||
{
|
||||
UDS_negativeResponse(obj, 0x19, NRC_INVALID_MESSAGE_LENGTH_OR_FORMAT);
|
||||
return;
|
||||
}
|
||||
/* add user code */
|
||||
|
||||
break;
|
||||
case REPORT_DTC_STORE_DATA_BY_RECORD_NUMBER:
|
||||
if(msgLen != 3)
|
||||
{
|
||||
UDS_negativeResponse(obj, 0x19, NRC_INVALID_MESSAGE_LENGTH_OR_FORMAT);
|
||||
return;
|
||||
}
|
||||
/* add user code */
|
||||
|
||||
break;
|
||||
case REPORT_DTC_EXT_DATA_RECORD_BY_DTC_NUMBER:
|
||||
if(msgLen != 6)
|
||||
{
|
||||
UDS_negativeResponse(obj, 0x19, NRC_INVALID_MESSAGE_LENGTH_OR_FORMAT);
|
||||
return;
|
||||
}
|
||||
/* add user code */
|
||||
|
||||
break;
|
||||
case REPORT_DTC_NUMBER_BY_SEVERITY_MASK_RECORD:
|
||||
if(msgLen != 4)
|
||||
{
|
||||
UDS_negativeResponse(obj, 0x19, NRC_INVALID_MESSAGE_LENGTH_OR_FORMAT);
|
||||
return;
|
||||
}
|
||||
/* add user code */
|
||||
|
||||
break;
|
||||
case REPORT_DTC_BY_SEVERITY_MASK_RECORD:
|
||||
if(msgLen != 4)
|
||||
{
|
||||
UDS_negativeResponse(obj, 0x19, NRC_INVALID_MESSAGE_LENGTH_OR_FORMAT);
|
||||
return;
|
||||
}
|
||||
/* add user code */
|
||||
|
||||
break;
|
||||
#endif
|
||||
case REPORT_SUPPORTED_DTC:
|
||||
if(msgLen != 2)
|
||||
{
|
||||
Uds_NegativeResponse(obj, 0x19, NRC_INVALID_MESSAGE_LENGTH_OR_FORMAT);
|
||||
return;
|
||||
}
|
||||
|
||||
dtcDlc = Uds_GetSupportedDtc(&rspBuffer[3], UDS_RSP_LEN_MAX - 3);
|
||||
Uds_PositiveResponse(obj, rspBuffer, dtcDlc + 3);
|
||||
break;
|
||||
default:
|
||||
Uds_NegativeResponse(obj, 0x19, NRC_SUBFUNCTION_NOT_SUPPORTED);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1,60 +0,0 @@
|
||||
/*
|
||||
* Copyright (c) 2022, Shenzhen CVA Innovation CO.,LTD
|
||||
* All rights reserved.
|
||||
*
|
||||
* Shenzhen CVA Innovation CO.,LTD (CVA chip) is supplying this file for use
|
||||
* exclusively with CVA's microcontroller products. This file can be freely
|
||||
* distributed within development tools that are supporting such microcontroller
|
||||
* products.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED "AS IS". NO WARRANTIES, WHETHER EXPRESS, IMPLIED
|
||||
* OR STATUTORY, INCLUDING, BUT NOT LIMITED TO, IMPLIED WARRANTIES OF
|
||||
* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE APPLY TO THIS SOFTWARE.
|
||||
* CVA SHALL NOT, IN ANY CIRCUMSTANCES, BE LIABLE FOR SPECIAL, INCIDENTAL,
|
||||
* OR CONSEQUENTIAL DAMAGES, FOR ANY REASON WHATSOEVER.
|
||||
*/
|
||||
|
||||
#ifndef _UDS_SERVICE19_H_
|
||||
#define _UDS_SERVICE19_H_
|
||||
|
||||
/*! \brief Contains public interface to various functions related
|
||||
* to the user-defined UDS service 19
|
||||
*/
|
||||
|
||||
/*******************************************************************************
|
||||
* the includes
|
||||
******************************************************************************/
|
||||
|
||||
#include <stdbool.h>
|
||||
#include <stdint.h>
|
||||
#include "../stack/uds.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/*******************************************************************************
|
||||
* the defines
|
||||
******************************************************************************/
|
||||
|
||||
/*******************************************************************************
|
||||
* the typedefs
|
||||
******************************************************************************/
|
||||
|
||||
/*******************************************************************************
|
||||
* the globals
|
||||
******************************************************************************/
|
||||
|
||||
/*******************************************************************************
|
||||
* the function prototypes
|
||||
******************************************************************************/
|
||||
|
||||
/*! \brief Uds Service 19 processing
|
||||
*/
|
||||
extern void UdsService19_ReadDtcInformation(UdsType *obj, const uint8_t msgBuf[], uint16_t msgLen);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif /* extern "C" */
|
||||
|
||||
#endif /* _UDS_SERVICE19_H_ */
|
@ -1,126 +0,0 @@
|
||||
/*
|
||||
* Copyright (c) 2022, Shenzhen CVA Innovation CO.,LTD
|
||||
* All rights reserved.
|
||||
*
|
||||
* Shenzhen CVA Innovation CO.,LTD (CVA chip) is supplying this file for use
|
||||
* exclusively with CVA's microcontroller products. This file can be freely
|
||||
* distributed within development tools that are supporting such microcontroller
|
||||
* products.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED "AS IS". NO WARRANTIES, WHETHER EXPRESS, IMPLIED
|
||||
* OR STATUTORY, INCLUDING, BUT NOT LIMITED TO, IMPLIED WARRANTIES OF
|
||||
* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE APPLY TO THIS SOFTWARE.
|
||||
* CVA SHALL NOT, IN ANY CIRCUMSTANCES, BE LIABLE FOR SPECIAL, INCIDENTAL,
|
||||
* OR CONSEQUENTIAL DAMAGES, FOR ANY REASON WHATSOEVER.
|
||||
*/
|
||||
|
||||
/*******************************************************************************
|
||||
* the includes
|
||||
******************************************************************************/
|
||||
#include <string.h>
|
||||
#include "uds_service22.h"
|
||||
|
||||
|
||||
/*******************************************************************************
|
||||
* the defines
|
||||
******************************************************************************/
|
||||
|
||||
/*******************************************************************************
|
||||
* the typedefs
|
||||
******************************************************************************/
|
||||
|
||||
/*******************************************************************************
|
||||
* the globals
|
||||
******************************************************************************/
|
||||
|
||||
/*******************************************************************************
|
||||
* the constants
|
||||
******************************************************************************/
|
||||
|
||||
/*******************************************************************************
|
||||
* the functions
|
||||
******************************************************************************/
|
||||
|
||||
void UdsService22_ReadDataByIdentifier(UdsType *obj, const uint8_t msgBuf[], uint16_t msgLen)
|
||||
{
|
||||
uint16_t didNum = 0;
|
||||
uint16_t didValue = 0;
|
||||
uint16_t rspLen = 0;
|
||||
uint16_t msgPos = 0, didIdx = 0;
|
||||
bool findDid = false;
|
||||
uint8_t rspBuffer[UDS_RSP_LEN_MAX] = {0};
|
||||
|
||||
if(msgLen < obj->seviceTable[obj->curServiceIdx].minLen)
|
||||
{
|
||||
Uds_NegativeResponse(obj, 0x22, NRC_INVALID_MESSAGE_LENGTH_OR_FORMAT);
|
||||
return;
|
||||
}
|
||||
|
||||
if(0 != (msgLen - 1) % sizeof(uint16_t))
|
||||
{
|
||||
Uds_NegativeResponse(obj, 0x22, NRC_INVALID_MESSAGE_LENGTH_OR_FORMAT);
|
||||
return;
|
||||
}
|
||||
|
||||
didNum = msgLen / sizeof(uint16_t);
|
||||
if(0 == didNum)
|
||||
{
|
||||
Uds_NegativeResponse(obj, 0x22, NRC_INVALID_MESSAGE_LENGTH_OR_FORMAT);
|
||||
return;
|
||||
}
|
||||
|
||||
rspBuffer[rspLen++] = UDS_GET_POSITIVE_RSP(0x22);
|
||||
|
||||
for(msgPos = 1; msgPos < msgLen; msgPos += 2)
|
||||
{
|
||||
didValue = ((uint16_t)msgBuf[msgPos]) << 8;
|
||||
didValue |= msgBuf[msgPos + 1];
|
||||
|
||||
findDid = false;
|
||||
for(didIdx = 0; didIdx < obj->didNum; didIdx++)
|
||||
{
|
||||
if(obj->didTable[didIdx].did == didValue)
|
||||
{
|
||||
if(obj->securityLevel != obj->didTable[didIdx].securityLevel)
|
||||
{
|
||||
Uds_NegativeResponse(obj, 0x22, NRC_SECURITY_ACCESS_DENIED);
|
||||
return;
|
||||
}
|
||||
else if((rspLen + 2 + obj->didTable[didIdx].length) > UDS_RSP_LEN_MAX)
|
||||
{
|
||||
Uds_NegativeResponse(obj, 0x22, NRC_RESPONSE_TOO_LONG);
|
||||
return;
|
||||
}
|
||||
|
||||
if((UDS_DID_TYPE_NVM_WO == obj->didTable[didIdx].type) || (obj->session < obj->didTable[didIdx].sessionLevel))
|
||||
{
|
||||
Uds_NegativeResponse(obj, 0x22, NRC_CONDITIONS_NOT_CORRECT);
|
||||
return;
|
||||
}
|
||||
|
||||
findDid = true;
|
||||
rspBuffer[rspLen++] = msgBuf[msgPos];
|
||||
rspBuffer[rspLen++] = msgBuf[msgPos + 1];
|
||||
memcpy(&rspBuffer[rspLen], obj->didTable[didIdx].pBytes, obj->didTable[didIdx].length);
|
||||
rspLen += obj->didTable[didIdx].length;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if(false == findDid)
|
||||
{
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if(true == findDid)
|
||||
{
|
||||
Uds_PositiveResponse(obj, rspBuffer, rspLen);
|
||||
}
|
||||
else
|
||||
{
|
||||
Uds_NegativeResponse(obj, 0x22, NRC_REQUEST_OUT_OF_RANGE);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
@ -1,60 +0,0 @@
|
||||
/*
|
||||
* Copyright (c) 2022, Shenzhen CVA Innovation CO.,LTD
|
||||
* All rights reserved.
|
||||
*
|
||||
* Shenzhen CVA Innovation CO.,LTD (CVA chip) is supplying this file for use
|
||||
* exclusively with CVA's microcontroller products. This file can be freely
|
||||
* distributed within development tools that are supporting such microcontroller
|
||||
* products.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED "AS IS". NO WARRANTIES, WHETHER EXPRESS, IMPLIED
|
||||
* OR STATUTORY, INCLUDING, BUT NOT LIMITED TO, IMPLIED WARRANTIES OF
|
||||
* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE APPLY TO THIS SOFTWARE.
|
||||
* CVA SHALL NOT, IN ANY CIRCUMSTANCES, BE LIABLE FOR SPECIAL, INCIDENTAL,
|
||||
* OR CONSEQUENTIAL DAMAGES, FOR ANY REASON WHATSOEVER.
|
||||
*/
|
||||
|
||||
#ifndef _UDS_SERVICE22_H_
|
||||
#define _UDS_SERVICE22_H_
|
||||
|
||||
/*! \brief Contains public interface to various functions related
|
||||
* to the user-defined UDS service 22
|
||||
*/
|
||||
|
||||
/*******************************************************************************
|
||||
* the includes
|
||||
******************************************************************************/
|
||||
|
||||
#include <stdbool.h>
|
||||
#include <stdint.h>
|
||||
#include "../stack/uds.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/*******************************************************************************
|
||||
* the defines
|
||||
******************************************************************************/
|
||||
|
||||
/*******************************************************************************
|
||||
* the typedefs
|
||||
******************************************************************************/
|
||||
|
||||
/*******************************************************************************
|
||||
* the globals
|
||||
******************************************************************************/
|
||||
|
||||
/*******************************************************************************
|
||||
* the function prototypes
|
||||
******************************************************************************/
|
||||
|
||||
/*! \brief Uds Service 22 processing
|
||||
*/
|
||||
extern void UdsService22_ReadDataByIdentifier(UdsType *obj, const uint8_t msgBuf[], uint16_t msgLen);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif /* extern "C" */
|
||||
|
||||
#endif /* _UDS_SERVICE22_H_ */
|
@ -25,9 +25,9 @@
|
||||
* the defines
|
||||
******************************************************************************/
|
||||
|
||||
#define SUPPORT_LEVEL_NUM 4 /* supported security level number */
|
||||
#define SUPPORT_LEVEL_NUM 2 /* supported security level number */
|
||||
|
||||
#define MAX_ALLOW_ERROR_NUM 3 /* the max allow number of key error */
|
||||
#define MAX_ALLOW_ERROR_NUM 5 /* the max allow number of key error */
|
||||
|
||||
#define STARTUP_DELAY_MS 2000 /* the service allow access time delay after UDS start */
|
||||
#define ERR_EXCEED_DELAY_MS 10000 /* the service allow access time delay after error number exceed */
|
||||
@ -49,15 +49,18 @@ typedef struct _SecurityLevel_Param_
|
||||
******************************************************************************/
|
||||
|
||||
SecurityLevel_Param scrtParam[SUPPORT_LEVEL_NUM] = {
|
||||
{UDS_SA_LEVEL_9, 0, MAX_ALLOW_ERROR_NUM, 0},
|
||||
{UDS_SA_LEVEL_3, 0, MAX_ALLOW_ERROR_NUM, 0},
|
||||
{UDS_SA_LEVEL_11, 0, MAX_ALLOW_ERROR_NUM, 0},
|
||||
{UDS_SA_LEVEL_63, 0, MAX_ALLOW_ERROR_NUM, 0}
|
||||
{UDS_SA_LEVEL_1, 0, MAX_ALLOW_ERROR_NUM, 0},
|
||||
//{UDS_SA_LEVEL_3, 0, MAX_ALLOW_ERROR_NUM, 0},
|
||||
{UDS_SA_LEVEL_09, 0, MAX_ALLOW_ERROR_NUM, 0},
|
||||
//{UDS_SA_LEVEL_63, 0, MAX_ALLOW_ERROR_NUM, 0},
|
||||
};
|
||||
|
||||
extern uint32_t gSystick1msEvent;
|
||||
/*******************************************************************************
|
||||
* the constants
|
||||
******************************************************************************/
|
||||
static const uint8_t DMxorArray[4] = {0x4D,0x53,0x57,0x51};
|
||||
|
||||
|
||||
/*******************************************************************************
|
||||
* the functions
|
||||
@ -66,7 +69,12 @@ SecurityLevel_Param scrtParam[SUPPORT_LEVEL_NUM] = {
|
||||
static void UdsSecurityAccess_GenerateSeed(UdsType *obj, uint8_t newLevel, uint8_t *outData, uint8_t outBufsize, uint16_t *outLen)
|
||||
{
|
||||
/* seed is defined by user, It's usually a random value */
|
||||
uint8_t seed[4] = {0, 0, 0, 0};
|
||||
uint8_t seed[4] = {1, 2, 3, 4};
|
||||
uint32_t timeseed = (uint32_t)(obj->timeStamp_ms);
|
||||
seed[0] = (uint8_t)(timeseed & 0xFF);
|
||||
seed[1] = (uint8_t)((timeseed>>8) & 0xFF);
|
||||
seed[2] = (uint8_t)((timeseed>>16) & 0xFF)+(seed[1]*7);
|
||||
seed[3] = (uint8_t)((timeseed>>24) & 0xFF)+(seed[0]*3);
|
||||
|
||||
if(outBufsize < sizeof(seed))
|
||||
{
|
||||
@ -80,44 +88,53 @@ static void UdsSecurityAccess_GenerateSeed(UdsType *obj, uint8_t newLevel, uint8
|
||||
}
|
||||
else
|
||||
{
|
||||
seed[0] = obj->timeStamp_ms & 0xFF;
|
||||
seed[1] = ((obj->timeStamp_ms >> 8) & 0xFF) + 1;
|
||||
seed[2] = (~seed[0]) + seed[1] + 1;
|
||||
seed[3] = (~seed[2]) + seed[0] + 2;
|
||||
|
||||
memcpy(outData, seed, sizeof(seed));
|
||||
}
|
||||
}
|
||||
|
||||
static bool UdsSecurityAccess_ValidateKey(uint8_t seedLevel, const uint8_t *seed, uint16_t seedLen, const uint8_t *key, uint16_t keyLen)
|
||||
{
|
||||
bool ret = true;
|
||||
/* TODO: make sure to define the value */
|
||||
uint8_t xor [4] = {0xC4, 0xA7, 0x96, 0xE5};
|
||||
uint8_t i = 0;
|
||||
uint8_t cal[4] = {0, 0, 0, 0};
|
||||
uint8_t calKey[4] = {0, 0, 0, 0};
|
||||
|
||||
for(i = 0; i < seedLen; i++)
|
||||
/* The encryption algorithm is provided by the vehicle manufacturer */
|
||||
uint8_t cal[4],calc_key[8];
|
||||
switch (seedLevel)
|
||||
{
|
||||
cal[i] = seed[i] ^ xor[i];
|
||||
}
|
||||
case UDS_SA_LEVEL_1:
|
||||
cal[0] = seed[0]^DMxorArray[0];
|
||||
cal[1] = seed[1]^DMxorArray[1];
|
||||
cal[2] = seed[2]^DMxorArray[2];
|
||||
cal[3] = seed[3]^DMxorArray[3];
|
||||
|
||||
calKey[0] = ((cal[0] & 0x0F) << 4) | (cal[1] & 0x0F);
|
||||
calKey[1] = ((cal[1] & 0xF0) >> 4) | ((cal[2] & 0x0F) << 4);
|
||||
calKey[2] = ((cal[2] & 0xF0) >> 4) | (cal[3] & 0xF0);
|
||||
calKey[3] = (cal[3] & 0x0F) | ((cal[0] & 0xF0) >> 4);
|
||||
|
||||
for (i = 0; i< keyLen; i++)
|
||||
{
|
||||
if(calKey[i] != key[i])
|
||||
calc_key[0] = ((cal[2]&0xF0)<<4)|(cal[3]&0xF0);
|
||||
calc_key[1] = ((cal[3]&0x2F)<<2)|(cal[1]&0x03);
|
||||
calc_key[2] = ((cal[1]&0xFC)>>2)|(cal[0]&0xC0);
|
||||
calc_key[3] = ((cal[0]&0x0F)<<4)|(cal[2]&0x0F);
|
||||
if (calc_key[0]!=key[0] || calc_key[1]!=key[1] || calc_key[2]!=key[2] || calc_key[3]!=key[3])
|
||||
{
|
||||
ret = false;
|
||||
break;
|
||||
//TxTestMsg(calc_key);
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
case UDS_SA_LEVEL_09:
|
||||
cal[0] = seed[0]^DMxorArray[0];
|
||||
cal[1] = seed[1]^DMxorArray[1];
|
||||
cal[2] = seed[2]^DMxorArray[2];
|
||||
cal[3] = seed[3]^DMxorArray[3];
|
||||
|
||||
calc_key[0] = ((cal[1]&0x7F)<<2)|(cal[2]&0xF0);
|
||||
calc_key[1] = ((cal[0]&0xEC)>>2)|(cal[1]&0x7E);
|
||||
calc_key[2] = ((cal[3]&0xF0)>>4)|(cal[0]&0x2C);
|
||||
calc_key[3] = ((cal[2]&0x0F)<<4)|(cal[3]&0x7D);
|
||||
if (calc_key[0]!=key[0] || calc_key[1]!=key[1] || calc_key[2]!=key[2] || calc_key[3]!=key[3])
|
||||
{
|
||||
//TxTestMsg(calc_key);
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
default:
|
||||
return false;
|
||||
}
|
||||
|
||||
return ret;
|
||||
return false;
|
||||
}
|
||||
|
||||
void UdsService27_SecurityAccess(UdsType *obj, const uint8_t msgBuf[], uint16_t msgLen)
|
||||
|
@ -1,147 +0,0 @@
|
||||
/*
|
||||
* Copyright (c) 2022, Shenzhen CVA Innovation CO.,LTD
|
||||
* All rights reserved.
|
||||
*
|
||||
* Shenzhen CVA Innovation CO.,LTD (CVA chip) is supplying this file for use
|
||||
* exclusively with CVA's microcontroller products. This file can be freely
|
||||
* distributed within development tools that are supporting such microcontroller
|
||||
* products.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED "AS IS". NO WARRANTIES, WHETHER EXPRESS, IMPLIED
|
||||
* OR STATUTORY, INCLUDING, BUT NOT LIMITED TO, IMPLIED WARRANTIES OF
|
||||
* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE APPLY TO THIS SOFTWARE.
|
||||
* CVA SHALL NOT, IN ANY CIRCUMSTANCES, BE LIABLE FOR SPECIAL, INCIDENTAL,
|
||||
* OR CONSEQUENTIAL DAMAGES, FOR ANY REASON WHATSOEVER.
|
||||
*/
|
||||
|
||||
/*******************************************************************************
|
||||
* the includes
|
||||
******************************************************************************/
|
||||
|
||||
#include "uds_service28.h"
|
||||
|
||||
/*******************************************************************************
|
||||
* the defines
|
||||
******************************************************************************/
|
||||
|
||||
/*******************************************************************************
|
||||
* the typedefs
|
||||
******************************************************************************/
|
||||
|
||||
/*! \brief The uds communication type definition of UDS
|
||||
*/
|
||||
typedef enum _UdsComType_
|
||||
{
|
||||
UDS_CC_TYPE_NONE = 0,
|
||||
UDS_CC_TYPE_NORMAL, /* normal message */
|
||||
UDS_CC_TYPE_NM, /* network management */
|
||||
UDS_CC_TYPE_NOR_NM, /* normal and network management message */
|
||||
} UdsComType;
|
||||
|
||||
/*! \brief The uds communication control mode definition of UDS
|
||||
*/
|
||||
typedef enum _UdsComCtrlMode_
|
||||
{
|
||||
UDS_CC_MODE_RX_TX = 0,
|
||||
UDS_CC_MODE_RX_NO,
|
||||
UDS_CC_MODE_NO_TX,
|
||||
UDS_CC_MODE_NO_NO
|
||||
} UdsComCtrMode;
|
||||
|
||||
/*******************************************************************************
|
||||
* the globals
|
||||
******************************************************************************/
|
||||
|
||||
static uint8_t udsComCtrlType = 0;
|
||||
|
||||
/*******************************************************************************
|
||||
* the constants
|
||||
******************************************************************************/
|
||||
|
||||
/*******************************************************************************
|
||||
* the functions
|
||||
******************************************************************************/
|
||||
|
||||
uint8_t Uds_GetCommunicationControlMode(void)
|
||||
{
|
||||
return udsComCtrlType;
|
||||
}
|
||||
|
||||
void UdsService28_CommunicationControl(UdsType *obj, const uint8_t msgBuf[], uint16_t msgLen)
|
||||
{
|
||||
uint8_t subFunction;
|
||||
uint8_t rspBuffer[8] = {0}; /* polyspace DEFECT:PARTIALLY_ACCESSED_ARRAY [No action planned:Low] "Still keep default though member2~7 is not written" */
|
||||
uint8_t ccType = 0;
|
||||
|
||||
if(msgLen < obj->seviceTable[obj->curServiceIdx].minLen)
|
||||
{
|
||||
Uds_NegativeResponse(obj, 0x28, NRC_INVALID_MESSAGE_LENGTH_OR_FORMAT);
|
||||
return;
|
||||
}
|
||||
|
||||
if(obj->session == UDS_SESSION_DEFAULT)
|
||||
{
|
||||
Uds_NegativeResponse(obj, 0x28, NRC_CONDITIONS_NOT_CORRECT);
|
||||
return;
|
||||
}
|
||||
|
||||
subFunction = UDS_GET_SUB_FUNCTION(msgBuf[1]);
|
||||
ccType = msgBuf[2];
|
||||
|
||||
rspBuffer[0] = UDS_GET_POSITIVE_RSP(0x28);
|
||||
rspBuffer[1] = subFunction;
|
||||
switch(subFunction)
|
||||
{
|
||||
case UDS_CC_MODE_RX_TX:
|
||||
if(ccType == UDS_CC_TYPE_NORMAL || ccType == UDS_CC_TYPE_NM || ccType == UDS_CC_TYPE_NOR_NM)
|
||||
{
|
||||
udsComCtrlType = UDS_CC_MODE_RX_TX;
|
||||
|
||||
Uds_PositiveResponse(obj, rspBuffer, 2);
|
||||
}
|
||||
else
|
||||
{
|
||||
Uds_NegativeResponse(obj, 0x28, NRC_REQUEST_OUT_OF_RANGE);
|
||||
}
|
||||
break;
|
||||
case UDS_CC_MODE_RX_NO:
|
||||
if(ccType == UDS_CC_TYPE_NORMAL || ccType == UDS_CC_TYPE_NM || ccType == UDS_CC_TYPE_NOR_NM)
|
||||
{
|
||||
udsComCtrlType = UDS_CC_MODE_RX_NO;
|
||||
|
||||
Uds_PositiveResponse(obj, rspBuffer, 2);
|
||||
}
|
||||
else
|
||||
{
|
||||
Uds_NegativeResponse(obj, 0x28, NRC_REQUEST_OUT_OF_RANGE);
|
||||
}
|
||||
break;
|
||||
case UDS_CC_MODE_NO_TX:
|
||||
if(ccType == UDS_CC_TYPE_NORMAL || ccType == UDS_CC_TYPE_NM || ccType == UDS_CC_TYPE_NOR_NM)
|
||||
{
|
||||
udsComCtrlType = UDS_CC_MODE_NO_TX;
|
||||
|
||||
Uds_PositiveResponse(obj, rspBuffer, 2);
|
||||
}
|
||||
else
|
||||
{
|
||||
Uds_NegativeResponse(obj, 0x28, NRC_REQUEST_OUT_OF_RANGE);
|
||||
}
|
||||
break;
|
||||
case UDS_CC_MODE_NO_NO:
|
||||
if(ccType == UDS_CC_TYPE_NORMAL || ccType == UDS_CC_TYPE_NM || ccType == UDS_CC_TYPE_NOR_NM)
|
||||
{
|
||||
udsComCtrlType = UDS_CC_MODE_NO_NO;
|
||||
|
||||
Uds_PositiveResponse(obj, rspBuffer, 2);
|
||||
}
|
||||
else
|
||||
{
|
||||
Uds_NegativeResponse(obj, 0x28, NRC_REQUEST_OUT_OF_RANGE);
|
||||
}
|
||||
break;
|
||||
default:
|
||||
Uds_NegativeResponse(obj, 0x28, NRC_SUBFUNCTION_NOT_SUPPORTED);
|
||||
break;
|
||||
}
|
||||
}
|
@ -1,64 +0,0 @@
|
||||
/*
|
||||
* Copyright (c) 2022, Shenzhen CVA Innovation CO.,LTD
|
||||
* All rights reserved.
|
||||
*
|
||||
* Shenzhen CVA Innovation CO.,LTD (CVA chip) is supplying this file for use
|
||||
* exclusively with CVA's microcontroller products. This file can be freely
|
||||
* distributed within development tools that are supporting such microcontroller
|
||||
* products.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED "AS IS". NO WARRANTIES, WHETHER EXPRESS, IMPLIED
|
||||
* OR STATUTORY, INCLUDING, BUT NOT LIMITED TO, IMPLIED WARRANTIES OF
|
||||
* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE APPLY TO THIS SOFTWARE.
|
||||
* CVA SHALL NOT, IN ANY CIRCUMSTANCES, BE LIABLE FOR SPECIAL, INCIDENTAL,
|
||||
* OR CONSEQUENTIAL DAMAGES, FOR ANY REASON WHATSOEVER.
|
||||
*/
|
||||
|
||||
#ifndef _UDS_SERVICE28_H_
|
||||
#define _UDS_SERVICE28_H_
|
||||
|
||||
/*! \brief Contains public interface to various functions related
|
||||
* to the user-defined UDS service 28
|
||||
*/
|
||||
|
||||
/*******************************************************************************
|
||||
* the includes
|
||||
******************************************************************************/
|
||||
|
||||
#include <stdbool.h>
|
||||
#include <stdint.h>
|
||||
#include "../stack/uds.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/*******************************************************************************
|
||||
* the defines
|
||||
******************************************************************************/
|
||||
|
||||
/*******************************************************************************
|
||||
* the typedefs
|
||||
******************************************************************************/
|
||||
|
||||
/*******************************************************************************
|
||||
* the globals
|
||||
******************************************************************************/
|
||||
|
||||
/*******************************************************************************
|
||||
* the function prototypes
|
||||
******************************************************************************/
|
||||
|
||||
/*! \brief Get Communication Control Mode
|
||||
*/
|
||||
uint8_t Uds_GetCommunicationControlMode(void);
|
||||
|
||||
/*! \brief Uds Service 28 processing
|
||||
*/
|
||||
extern void UdsService28_CommunicationControl(UdsType *obj, const uint8_t msgBuf[], uint16_t msgLen);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif /* extern "C" */
|
||||
|
||||
#endif /* _UDS_SERVICE28_H_ */
|
@ -1,116 +0,0 @@
|
||||
/*
|
||||
* Copyright (c) 2022, Shenzhen CVA Innovation CO.,LTD
|
||||
* All rights reserved.
|
||||
*
|
||||
* Shenzhen CVA Innovation CO.,LTD (CVA chip) is supplying this file for use
|
||||
* exclusively with CVA's microcontroller products. This file can be freely
|
||||
* distributed within development tools that are supporting such microcontroller
|
||||
* products.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED "AS IS". NO WARRANTIES, WHETHER EXPRESS, IMPLIED
|
||||
* OR STATUTORY, INCLUDING, BUT NOT LIMITED TO, IMPLIED WARRANTIES OF
|
||||
* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE APPLY TO THIS SOFTWARE.
|
||||
* CVA SHALL NOT, IN ANY CIRCUMSTANCES, BE LIABLE FOR SPECIAL, INCIDENTAL,
|
||||
* OR CONSEQUENTIAL DAMAGES, FOR ANY REASON WHATSOEVER.
|
||||
*/
|
||||
|
||||
/*******************************************************************************
|
||||
* the includes
|
||||
******************************************************************************/
|
||||
|
||||
#include <string.h>
|
||||
#include "uds_service2E.h"
|
||||
|
||||
/*******************************************************************************
|
||||
* the defines
|
||||
******************************************************************************/
|
||||
|
||||
|
||||
/*******************************************************************************
|
||||
* the typedefs
|
||||
******************************************************************************/
|
||||
|
||||
/*******************************************************************************
|
||||
* the globals
|
||||
******************************************************************************/
|
||||
|
||||
/*******************************************************************************
|
||||
* the constants
|
||||
******************************************************************************/
|
||||
|
||||
/*******************************************************************************
|
||||
* the functions
|
||||
******************************************************************************/
|
||||
|
||||
void UdsService2E_WriteDataByIdentifier(UdsType *obj, const uint8_t msgBuf[], uint16_t msgLen)
|
||||
{
|
||||
uint16_t didValue = 0;
|
||||
uint16_t didIdx = 0;
|
||||
uint8_t rspBuffer[8] = {0};
|
||||
bool writeResult = false;
|
||||
|
||||
if(msgLen < obj->seviceTable[obj->curServiceIdx].minLen)
|
||||
{
|
||||
Uds_NegativeResponse(obj, 0x2E, NRC_INVALID_MESSAGE_LENGTH_OR_FORMAT);
|
||||
return;
|
||||
}
|
||||
|
||||
didValue = ((uint16_t)msgBuf[1]) << 8;
|
||||
didValue |= msgBuf[2];
|
||||
|
||||
rspBuffer[0] = UDS_GET_POSITIVE_RSP(0x2E);
|
||||
rspBuffer[1] = msgBuf[1];
|
||||
rspBuffer[2] = msgBuf[2];
|
||||
for(didIdx = 0; didIdx < obj->didNum; didIdx++)
|
||||
{
|
||||
if(obj->didTable[didIdx].did == didValue)
|
||||
{
|
||||
if((obj->didTable[didIdx].securityLevel != UDS_SA_NONE) && (obj->securityLevel != obj->didTable[didIdx].securityLevel))
|
||||
{
|
||||
Uds_NegativeResponse(obj, 0x22, NRC_SECURITY_ACCESS_DENIED);
|
||||
return;
|
||||
}
|
||||
else if((msgLen - 3) != obj->didTable[didIdx].length)
|
||||
{
|
||||
Uds_NegativeResponse(obj, 0x2E, NRC_INVALID_MESSAGE_LENGTH_OR_FORMAT);
|
||||
return;
|
||||
}
|
||||
|
||||
if((UDS_DID_TYPE_NVM_RO == obj->didTable[didIdx].type) || (obj->session < obj->didTable[didIdx].sessionLevel))
|
||||
{
|
||||
Uds_NegativeResponse(obj, 0x2E, NRC_CONDITIONS_NOT_CORRECT);
|
||||
return;
|
||||
}
|
||||
|
||||
memcpy(obj->didTable[didIdx].pBytes, &msgBuf[3], obj->didTable[didIdx].length);
|
||||
/* add user code to save data */
|
||||
switch(didValue)
|
||||
{
|
||||
case UDS_USER_DID_PRINT_FOOT:
|
||||
/* TODO: write data to eeprom */
|
||||
|
||||
writeResult = true;
|
||||
break;
|
||||
}
|
||||
|
||||
/* check save data success */
|
||||
/* polyspace-begin DEFECT:DEAD_CODE [No action planned:Low] "Still reserve though it's maybe unreachable" */
|
||||
if(writeResult == true)
|
||||
{
|
||||
Uds_PositiveResponse(obj, rspBuffer, 3);
|
||||
return;
|
||||
}
|
||||
else
|
||||
{
|
||||
Uds_NegativeResponse(obj, 0x2E, NRC_GENERAL_PROGRAMMING_FAILURE);
|
||||
return;
|
||||
}
|
||||
/* polyspace-end DEFECT:DEAD_CODE [No action planned:Low] "Still reserve though it's maybe unreachable" */
|
||||
}
|
||||
}
|
||||
|
||||
Uds_NegativeResponse(obj, 0x2E, NRC_REQUEST_OUT_OF_RANGE);
|
||||
}
|
||||
|
||||
|
||||
|
@ -1,62 +0,0 @@
|
||||
/*
|
||||
* Copyright (c) 2022, Shenzhen CVA Innovation CO.,LTD
|
||||
* All rights reserved.
|
||||
*
|
||||
* Shenzhen CVA Innovation CO.,LTD (CVA chip) is supplying this file for use
|
||||
* exclusively with CVA's microcontroller products. This file can be freely
|
||||
* distributed within development tools that are supporting such microcontroller
|
||||
* products.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED "AS IS". NO WARRANTIES, WHETHER EXPRESS, IMPLIED
|
||||
* OR STATUTORY, INCLUDING, BUT NOT LIMITED TO, IMPLIED WARRANTIES OF
|
||||
* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE APPLY TO THIS SOFTWARE.
|
||||
* CVA SHALL NOT, IN ANY CIRCUMSTANCES, BE LIABLE FOR SPECIAL, INCIDENTAL,
|
||||
* OR CONSEQUENTIAL DAMAGES, FOR ANY REASON WHATSOEVER.
|
||||
*/
|
||||
|
||||
#ifndef _UDS_SERVICE2E_H_
|
||||
#define _UDS_SERVICE2E_H_
|
||||
|
||||
/*! \brief Contains public interface to various functions related
|
||||
* to the user-defined UDS service 2E
|
||||
*/
|
||||
|
||||
/*******************************************************************************
|
||||
* the includes
|
||||
******************************************************************************/
|
||||
|
||||
#include <stdbool.h>
|
||||
#include <stdint.h>
|
||||
#include "../stack/uds.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/*******************************************************************************
|
||||
* the defines
|
||||
******************************************************************************/
|
||||
#define UDS_USER_DID_PRINT_FOOT (0xF184)
|
||||
#define UDS_USER_DID_PRINT_FOOT_DATA_LEN (9)
|
||||
|
||||
/*******************************************************************************
|
||||
* the typedefs
|
||||
******************************************************************************/
|
||||
|
||||
/*******************************************************************************
|
||||
* the globals
|
||||
******************************************************************************/
|
||||
|
||||
/*******************************************************************************
|
||||
* the function prototypes
|
||||
******************************************************************************/
|
||||
|
||||
/*! \brief Uds Service 2E processing
|
||||
*/
|
||||
extern void UdsService2E_WriteDataByIdentifier(UdsType *obj, const uint8_t msgBuf[], uint16_t msgLen);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif /* extern "C" */
|
||||
|
||||
#endif /* _UDS_SERVICE2E_H_ */
|
@ -1,189 +0,0 @@
|
||||
/*
|
||||
* Copyright (c) 2022, Shenzhen CVA Innovation CO.,LTD
|
||||
* All rights reserved.
|
||||
*
|
||||
* Shenzhen CVA Innovation CO.,LTD (CVA chip) is supplying this file for use
|
||||
* exclusively with CVA's microcontroller products. This file can be freely
|
||||
* distributed within development tools that are supporting such microcontroller
|
||||
* products.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED "AS IS". NO WARRANTIES, WHETHER EXPRESS, IMPLIED
|
||||
* OR STATUTORY, INCLUDING, BUT NOT LIMITED TO, IMPLIED WARRANTIES OF
|
||||
* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE APPLY TO THIS SOFTWARE.
|
||||
* CVA SHALL NOT, IN ANY CIRCUMSTANCES, BE LIABLE FOR SPECIAL, INCIDENTAL,
|
||||
* OR CONSEQUENTIAL DAMAGES, FOR ANY REASON WHATSOEVER.
|
||||
*/
|
||||
|
||||
/*******************************************************************************
|
||||
* the includes
|
||||
******************************************************************************/
|
||||
|
||||
#include <stddef.h>
|
||||
#include <string.h>
|
||||
#include "uds_service2F.h"
|
||||
|
||||
/*******************************************************************************
|
||||
* the defines
|
||||
******************************************************************************/
|
||||
|
||||
/*******************************************************************************
|
||||
* the typedefs
|
||||
******************************************************************************/
|
||||
|
||||
/*! \brief The Uds IO control type
|
||||
*/
|
||||
typedef enum _UdsIoCtrlType_
|
||||
{
|
||||
UDS_IOCTRL_RETURN_TO_ECU = 0x00,
|
||||
UDS_IOCTRL_RETSET_TO_DEFAULT = 0x01,
|
||||
UDS_IOCTRL_FREEZE_CURRENT_STATE = 0x02,
|
||||
UDS_IOCTRL_SHORT_ADJUSTMENT = 0x03
|
||||
} UdsIoCtrlType;
|
||||
|
||||
/*! \brief The Uds IO control struct
|
||||
*/
|
||||
typedef struct _Uds_IoCtrl_
|
||||
{
|
||||
uint16_t did;
|
||||
uint8_t securityLevel;
|
||||
uint8_t *pData;
|
||||
uint8_t dataLen;
|
||||
uint8_t defaultValue;
|
||||
uint8_t step;
|
||||
bool enable;
|
||||
void (*IoCtrl_Init)(void);
|
||||
void (*IoCtrl_Stop)(void);
|
||||
} Uds_IoCtrl;
|
||||
|
||||
/*! \brief The IoControl-by-ID definition of UDS
|
||||
*/
|
||||
typedef struct _Uds_IoCtrlBuf_
|
||||
{
|
||||
uint8_t backlightLevel[2];
|
||||
uint8_t buzzer[2];
|
||||
} Uds_IoCtrlBuf;
|
||||
|
||||
/*******************************************************************************
|
||||
* the constants
|
||||
******************************************************************************/
|
||||
|
||||
static void IoCtrl_InitBackLight(void);
|
||||
static void IoCtrl_StopBacklight(void);
|
||||
static void IoCtrl_InitBuzzer(void);
|
||||
static void IoCtrl_StopBuzzer(void);
|
||||
|
||||
/*******************************************************************************
|
||||
* the globals
|
||||
******************************************************************************/
|
||||
|
||||
Uds_IoCtrlBuf udsIoCtrlBuffer;
|
||||
|
||||
Uds_IoCtrl udsIoCtrlTable[] = {
|
||||
{0xF092, UDS_SA_NONE, udsIoCtrlBuffer.backlightLevel, 2, 0, 0, 0, &IoCtrl_InitBackLight, &IoCtrl_StopBacklight},
|
||||
{0xF020, UDS_SA_NONE, udsIoCtrlBuffer.buzzer, 2, 0, 0, 0, &IoCtrl_InitBuzzer, &IoCtrl_StopBuzzer },
|
||||
};
|
||||
|
||||
/*******************************************************************************
|
||||
* the functions
|
||||
******************************************************************************/
|
||||
|
||||
static void IoCtrl_InitBackLight(void)
|
||||
{
|
||||
/* user add back light control code */
|
||||
}
|
||||
|
||||
static void IoCtrl_StopBacklight(void)
|
||||
{
|
||||
/* user add back light stop code */
|
||||
}
|
||||
|
||||
static void IoCtrl_InitBuzzer(void)
|
||||
{
|
||||
/* user add buzzer control code */
|
||||
}
|
||||
|
||||
static void IoCtrl_StopBuzzer(void)
|
||||
{
|
||||
/* user add buzzer stop code */
|
||||
}
|
||||
|
||||
void UdsService2F_InputOutputCtrlById(UdsType *obj, const uint8_t msgBuf[], uint16_t msgLen)
|
||||
{
|
||||
uint16_t ioCtrlId = 0;
|
||||
uint8_t ioCtrlParam = 0;
|
||||
uint8_t ioCtrlIndex = 0;
|
||||
uint8_t ioCtrlNum = sizeof(udsIoCtrlTable) / sizeof(udsIoCtrlTable[0]);
|
||||
uint8_t rspBuffer[UDS_RSP_LEN_MAX] = {0};
|
||||
|
||||
if(msgLen < obj->seviceTable[obj->curServiceIdx].minLen)
|
||||
{
|
||||
Uds_NegativeResponse(obj, 0x2F, NRC_INVALID_MESSAGE_LENGTH_OR_FORMAT);
|
||||
return;
|
||||
}
|
||||
|
||||
if(obj->session == UDS_SESSION_DEFAULT)
|
||||
{
|
||||
Uds_NegativeResponse(obj, 0x2F, NRC_CONDITIONS_NOT_CORRECT);
|
||||
return;
|
||||
}
|
||||
|
||||
ioCtrlId = ((uint16_t)msgBuf[1] << 8) + msgBuf[2];
|
||||
ioCtrlParam = msgBuf[3];
|
||||
|
||||
for(ioCtrlIndex = 0; ioCtrlIndex < ioCtrlNum; ioCtrlIndex++)
|
||||
{
|
||||
if(udsIoCtrlTable[ioCtrlIndex].did == ioCtrlId)
|
||||
{
|
||||
if((udsIoCtrlTable[ioCtrlIndex].securityLevel != UDS_SA_NONE) && (udsIoCtrlTable[ioCtrlIndex].securityLevel != obj->securityLevel))
|
||||
{
|
||||
Uds_NegativeResponse(obj, 0x2F, NRC_SECURITY_ACCESS_DENIED);
|
||||
return;
|
||||
}
|
||||
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if(ioCtrlIndex >= ioCtrlNum)
|
||||
{
|
||||
Uds_NegativeResponse(obj, 0x2F, NRC_REQUEST_OUT_OF_RANGE);
|
||||
return;
|
||||
}
|
||||
|
||||
rspBuffer[0] = UDS_GET_POSITIVE_RSP(0x2F);
|
||||
rspBuffer[1] = msgBuf[1];
|
||||
rspBuffer[2] = msgBuf[2];
|
||||
rspBuffer[3] = msgBuf[3];
|
||||
switch(ioCtrlParam)
|
||||
{
|
||||
case UDS_IOCTRL_RETURN_TO_ECU:
|
||||
/* add user code */
|
||||
udsIoCtrlTable[ioCtrlIndex].enable = false;
|
||||
if(udsIoCtrlTable[ioCtrlIndex].IoCtrl_Stop != NULL)
|
||||
{
|
||||
udsIoCtrlTable[ioCtrlIndex].IoCtrl_Stop();
|
||||
Uds_PositiveResponse(obj, rspBuffer, 4);
|
||||
}
|
||||
|
||||
break;
|
||||
case UDS_IOCTRL_SHORT_ADJUSTMENT:
|
||||
/* add user code */
|
||||
if(msgLen < (udsIoCtrlTable[ioCtrlIndex].dataLen + 4))
|
||||
{
|
||||
Uds_NegativeResponse(obj, 0x2F, NRC_CONDITIONS_NOT_CORRECT);
|
||||
return;
|
||||
}
|
||||
|
||||
udsIoCtrlTable[ioCtrlIndex].enable = true;
|
||||
memcpy(udsIoCtrlTable[ioCtrlIndex].pData, &msgBuf[4], udsIoCtrlTable[ioCtrlIndex].dataLen);
|
||||
if(udsIoCtrlTable[ioCtrlIndex].IoCtrl_Init != NULL)
|
||||
{
|
||||
udsIoCtrlTable[ioCtrlIndex].IoCtrl_Init();
|
||||
Uds_PositiveResponse(obj, rspBuffer, 4);
|
||||
}
|
||||
break;
|
||||
default:
|
||||
Uds_NegativeResponse(obj, 0x2F, NRC_REQUEST_OUT_OF_RANGE);
|
||||
break;
|
||||
}
|
||||
}
|
@ -1,60 +0,0 @@
|
||||
/*
|
||||
* Copyright (c) 2022, Shenzhen CVA Innovation CO.,LTD
|
||||
* All rights reserved.
|
||||
*
|
||||
* Shenzhen CVA Innovation CO.,LTD (CVA chip) is supplying this file for use
|
||||
* exclusively with CVA's microcontroller products. This file can be freely
|
||||
* distributed within development tools that are supporting such microcontroller
|
||||
* products.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED "AS IS". NO WARRANTIES, WHETHER EXPRESS, IMPLIED
|
||||
* OR STATUTORY, INCLUDING, BUT NOT LIMITED TO, IMPLIED WARRANTIES OF
|
||||
* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE APPLY TO THIS SOFTWARE.
|
||||
* CVA SHALL NOT, IN ANY CIRCUMSTANCES, BE LIABLE FOR SPECIAL, INCIDENTAL,
|
||||
* OR CONSEQUENTIAL DAMAGES, FOR ANY REASON WHATSOEVER.
|
||||
*/
|
||||
|
||||
#ifndef _UDS_SERVICE2F_H_
|
||||
#define _UDS_SERVICE2F_H_
|
||||
|
||||
/*! \brief Contains public interface to various functions related
|
||||
* to the user-defined UDS service 2F
|
||||
*/
|
||||
|
||||
/*******************************************************************************
|
||||
* the includes
|
||||
******************************************************************************/
|
||||
|
||||
#include <stdbool.h>
|
||||
#include <stdint.h>
|
||||
#include "../stack/uds.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/*******************************************************************************
|
||||
* the defines
|
||||
******************************************************************************/
|
||||
|
||||
/*******************************************************************************
|
||||
* the typedefs
|
||||
******************************************************************************/
|
||||
|
||||
/*******************************************************************************
|
||||
* the globals
|
||||
******************************************************************************/
|
||||
|
||||
/*******************************************************************************
|
||||
* the function prototypes
|
||||
******************************************************************************/
|
||||
|
||||
/*! \brief Uds Service 2F processing
|
||||
*/
|
||||
extern void UdsService2F_InputOutputCtrlById(UdsType *obj, const uint8_t msgBuf[], uint16_t msgLen);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif /* extern "C" */
|
||||
|
||||
#endif /* _UDS_SERVICE2F_H_ */
|
@ -91,10 +91,10 @@ static void Routine_ResultVerifyCompatibility(const uint8_t *pdata, uint16_t len
|
||||
******************************************************************************/
|
||||
|
||||
Uds_RtnCtrl udsRtnCtrlTable[] = {
|
||||
{RID_ERASE_MEMORY, UDS_SESSION_PROGRAMMING, UDS_SA_LEVEL_9, UDS_RTN_ST_IDLE, &Routine_StartEreaseMemory, &Routine_StopEreaseMemory, &Routine_ResultEreaseMemory },
|
||||
{RID_ERASE_MEMORY, UDS_SESSION_PROGRAMMING, UDS_SA_LEVEL_09, UDS_RTN_ST_IDLE, &Routine_StartEreaseMemory, &Routine_StopEreaseMemory, &Routine_ResultEreaseMemory },
|
||||
{RID_PGM_CONDITION_CHECK, UDS_SESSION_PROGRAMMING | UDS_SESSION_EXTENDED, UDS_SA_NONE, UDS_RTN_ST_IDLE, &Routine_StartCheckPgmCondition, &Routine_StopCheckPgmCondition, &Routine_ResultCheckPgmCondition },
|
||||
{RID_CRC_CHECK, UDS_SESSION_PROGRAMMING, UDS_SA_LEVEL_9, UDS_RTN_ST_IDLE, &Routine_StartCheckCrc, &Routine_StopCheckCrc, &Routine_ResultCheckCrc },
|
||||
{RID_COMPATIBILITY, UDS_SESSION_PROGRAMMING, UDS_SA_LEVEL_9, UDS_RTN_ST_IDLE, &Routine_StartVerifyCompatibility, &Routine_StopVerifyCompatibility, &Routine_ResultVerifyCompatibility},
|
||||
{RID_CRC_CHECK, UDS_SESSION_PROGRAMMING, UDS_SA_LEVEL_09, UDS_RTN_ST_IDLE, &Routine_StartCheckCrc, &Routine_StopCheckCrc, &Routine_ResultCheckCrc },
|
||||
{RID_COMPATIBILITY, UDS_SESSION_PROGRAMMING, UDS_SA_LEVEL_09, UDS_RTN_ST_IDLE, &Routine_StartVerifyCompatibility, &Routine_StopVerifyCompatibility, &Routine_ResultVerifyCompatibility},
|
||||
};
|
||||
|
||||
/*******************************************************************************
|
||||
|
@ -1,95 +0,0 @@
|
||||
/*
|
||||
* Copyright (c) 2022, Shenzhen CVA Innovation CO.,LTD
|
||||
* All rights reserved.
|
||||
*
|
||||
* Shenzhen CVA Innovation CO.,LTD (CVA chip) is supplying this file for use
|
||||
* exclusively with CVA's microcontroller products. This file can be freely
|
||||
* distributed within development tools that are supporting such microcontroller
|
||||
* products.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED "AS IS". NO WARRANTIES, WHETHER EXPRESS, IMPLIED
|
||||
* OR STATUTORY, INCLUDING, BUT NOT LIMITED TO, IMPLIED WARRANTIES OF
|
||||
* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE APPLY TO THIS SOFTWARE.
|
||||
* CVA SHALL NOT, IN ANY CIRCUMSTANCES, BE LIABLE FOR SPECIAL, INCIDENTAL,
|
||||
* OR CONSEQUENTIAL DAMAGES, FOR ANY REASON WHATSOEVER.
|
||||
*/
|
||||
|
||||
/*******************************************************************************
|
||||
* the includes
|
||||
******************************************************************************/
|
||||
#include "uds_service36.h"
|
||||
#include "uds_service37.h"
|
||||
|
||||
|
||||
/*******************************************************************************
|
||||
* the defines
|
||||
******************************************************************************/
|
||||
|
||||
/*******************************************************************************
|
||||
* the typedefs
|
||||
******************************************************************************/
|
||||
|
||||
/*******************************************************************************
|
||||
* the globals
|
||||
******************************************************************************/
|
||||
|
||||
/*******************************************************************************
|
||||
* the constants
|
||||
******************************************************************************/
|
||||
|
||||
/*******************************************************************************
|
||||
* the functions
|
||||
******************************************************************************/
|
||||
|
||||
void UdsService37_RequestTransferExit(UdsType *obj, const uint8_t msgBuf[], uint16_t msgLen)
|
||||
{
|
||||
uint16_t rspLen = 0;
|
||||
uint8_t rspBuffer[8] ={0}; /* polyspace DEFECT:PARTIALLY_ACCESSED_ARRAY [No action planned:Low] "Still reserve though member1~7 is not written" */
|
||||
|
||||
if(obj->session == UDS_SESSION_DEFAULT)
|
||||
{
|
||||
Uds_NegativeResponse(obj, 0x37, NRC_CONDITIONS_NOT_CORRECT);
|
||||
return;
|
||||
}
|
||||
|
||||
if(msgLen < obj->seviceTable[obj->curServiceIdx].minLen)
|
||||
{
|
||||
Uds_NegativeResponse(obj, 0x37, NRC_INVALID_MESSAGE_LENGTH_OR_FORMAT);
|
||||
return;
|
||||
}
|
||||
|
||||
rspBuffer[rspLen++] = UDS_GET_POSITIVE_RSP(0x37);
|
||||
switch(Uds_GetDataTransferDirect())
|
||||
{
|
||||
case UDS_TRANSFER_DIR_DOWNLOAD:
|
||||
if(Uds_GetRcvDataTotalLen() != Uds_GetMemSize())
|
||||
{
|
||||
Uds_NegativeResponse(obj, 0x37, NRC_INVALID_MESSAGE_LENGTH_OR_FORMAT);
|
||||
break;
|
||||
}
|
||||
|
||||
/* user add process code, example data CRC */
|
||||
/* polyspace-begin DEFECT:DEAD_CODE [No action planned:Low] "Still reserve though it's maybe unreachable" */
|
||||
if(1) /* result check correct */
|
||||
{
|
||||
Uds_PositiveResponse(obj, rspBuffer, rspLen);
|
||||
}
|
||||
else
|
||||
{
|
||||
Uds_NegativeResponse(obj, 0x37, NRC_GENERAL_PROGRAMMING_FAILURE);
|
||||
}
|
||||
/* polyspace-end DEFECT:DEAD_CODE [No action planned:Low] "Still reserve though it's maybe unreachable" */
|
||||
break;
|
||||
case UDS_TRANSFER_DIR_UPLOAD:
|
||||
Uds_NegativeResponse(obj, 0x37, NRC_REQUEST_OUT_OF_RANGE);
|
||||
break;
|
||||
default:
|
||||
Uds_NegativeResponse(obj, 0x37, NRC_REQUEST_SEQUENCE_ERROR);
|
||||
break;
|
||||
}
|
||||
|
||||
Uds_SetDataTransferDirect(UDS_TRANSFER_DIR_NONE);
|
||||
}
|
||||
|
||||
|
||||
|
@ -1,60 +0,0 @@
|
||||
/*
|
||||
* Copyright (c) 2022, Shenzhen CVA Innovation CO.,LTD
|
||||
* All rights reserved.
|
||||
*
|
||||
* Shenzhen CVA Innovation CO.,LTD (CVA chip) is supplying this file for use
|
||||
* exclusively with CVA's microcontroller products. This file can be freely
|
||||
* distributed within development tools that are supporting such microcontroller
|
||||
* products.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED "AS IS". NO WARRANTIES, WHETHER EXPRESS, IMPLIED
|
||||
* OR STATUTORY, INCLUDING, BUT NOT LIMITED TO, IMPLIED WARRANTIES OF
|
||||
* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE APPLY TO THIS SOFTWARE.
|
||||
* CVA SHALL NOT, IN ANY CIRCUMSTANCES, BE LIABLE FOR SPECIAL, INCIDENTAL,
|
||||
* OR CONSEQUENTIAL DAMAGES, FOR ANY REASON WHATSOEVER.
|
||||
*/
|
||||
|
||||
#ifndef _UDS_SERVICE37_H_
|
||||
#define _UDS_SERVICE37_H_
|
||||
|
||||
/*! \brief Contains public interface to various functions related
|
||||
* to the user-defined UDS service 37
|
||||
*/
|
||||
|
||||
/*******************************************************************************
|
||||
* the includes
|
||||
******************************************************************************/
|
||||
|
||||
#include <stdbool.h>
|
||||
#include <stdint.h>
|
||||
#include "../stack/uds.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/*******************************************************************************
|
||||
* the defines
|
||||
******************************************************************************/
|
||||
|
||||
/*******************************************************************************
|
||||
* the typedefs
|
||||
******************************************************************************/
|
||||
|
||||
/*******************************************************************************
|
||||
* the globals
|
||||
******************************************************************************/
|
||||
|
||||
/*******************************************************************************
|
||||
* the function prototypes
|
||||
******************************************************************************/
|
||||
|
||||
/*! \brief Uds Service 37 processing
|
||||
*/
|
||||
void UdsService37_RequestTransferExit(UdsType *obj, const uint8_t msgBuf[], uint16_t msgLen);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif /* extern "C" */
|
||||
|
||||
#endif /* _UDS_SERVICE37_H_ */
|
@ -1,70 +0,0 @@
|
||||
/*
|
||||
* Copyright (c) 2022, Shenzhen CVA Innovation CO.,LTD
|
||||
* All rights reserved.
|
||||
*
|
||||
* Shenzhen CVA Innovation CO.,LTD (CVA chip) is supplying this file for use
|
||||
* exclusively with CVA's microcontroller products. This file can be freely
|
||||
* distributed within development tools that are supporting such microcontroller
|
||||
* products.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED "AS IS". NO WARRANTIES, WHETHER EXPRESS, IMPLIED
|
||||
* OR STATUTORY, INCLUDING, BUT NOT LIMITED TO, IMPLIED WARRANTIES OF
|
||||
* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE APPLY TO THIS SOFTWARE.
|
||||
* CVA SHALL NOT, IN ANY CIRCUMSTANCES, BE LIABLE FOR SPECIAL, INCIDENTAL,
|
||||
* OR CONSEQUENTIAL DAMAGES, FOR ANY REASON WHATSOEVER.
|
||||
*/
|
||||
|
||||
/*******************************************************************************
|
||||
* the includes
|
||||
******************************************************************************/
|
||||
|
||||
#include "uds_service3E.h"
|
||||
|
||||
|
||||
/*******************************************************************************
|
||||
* the defines
|
||||
******************************************************************************/
|
||||
|
||||
/*******************************************************************************
|
||||
* the typedefs
|
||||
******************************************************************************/
|
||||
|
||||
/*******************************************************************************
|
||||
* the globals
|
||||
******************************************************************************/
|
||||
|
||||
/*******************************************************************************
|
||||
* the constants
|
||||
******************************************************************************/
|
||||
|
||||
/*******************************************************************************
|
||||
* the functions
|
||||
******************************************************************************/
|
||||
|
||||
void UdsService3E_TesterPresent(UdsType *obj, const uint8_t msgBuf[], uint16_t msgLen)
|
||||
{
|
||||
uint8_t subFunction;
|
||||
uint8_t rspBuffer[8] = {0}; /* polyspace DEFECT:PARTIALLY_ACCESSED_ARRAY [No action planned:Low] "Still keep default though member2~7 is not written" */
|
||||
|
||||
if(msgLen != obj->seviceTable[obj->curServiceIdx].minLen)
|
||||
{
|
||||
Uds_NegativeResponse(obj, 0x3E, NRC_INVALID_MESSAGE_LENGTH_OR_FORMAT);
|
||||
return;
|
||||
}
|
||||
|
||||
subFunction = UDS_GET_SUB_FUNCTION (msgBuf[1]);
|
||||
|
||||
if(subFunction == 0)
|
||||
{
|
||||
rspBuffer[0] = UDS_GET_POSITIVE_RSP(0x3E);
|
||||
rspBuffer[1] = subFunction;
|
||||
Uds_PositiveResponse(obj, rspBuffer, 2);
|
||||
}
|
||||
else
|
||||
{
|
||||
Uds_NegativeResponse(obj, 0x3E, NRC_SUBFUNCTION_NOT_SUPPORTED);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
@ -1,60 +0,0 @@
|
||||
/*
|
||||
* Copyright (c) 2022, Shenzhen CVA Innovation CO.,LTD
|
||||
* All rights reserved.
|
||||
*
|
||||
* Shenzhen CVA Innovation CO.,LTD (CVA chip) is supplying this file for use
|
||||
* exclusively with CVA's microcontroller products. This file can be freely
|
||||
* distributed within development tools that are supporting such microcontroller
|
||||
* products.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED "AS IS". NO WARRANTIES, WHETHER EXPRESS, IMPLIED
|
||||
* OR STATUTORY, INCLUDING, BUT NOT LIMITED TO, IMPLIED WARRANTIES OF
|
||||
* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE APPLY TO THIS SOFTWARE.
|
||||
* CVA SHALL NOT, IN ANY CIRCUMSTANCES, BE LIABLE FOR SPECIAL, INCIDENTAL,
|
||||
* OR CONSEQUENTIAL DAMAGES, FOR ANY REASON WHATSOEVER.
|
||||
*/
|
||||
|
||||
#ifndef _UDS_SERVICE3E_H_
|
||||
#define _UDS_SERVICE3E_H_
|
||||
|
||||
/*! \brief Contains public interface to various functions related
|
||||
* to the user-defined UDS service 3E
|
||||
*/
|
||||
|
||||
/*******************************************************************************
|
||||
* the includes
|
||||
******************************************************************************/
|
||||
|
||||
#include <stdbool.h>
|
||||
#include <stdint.h>
|
||||
#include "../stack/uds.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/*******************************************************************************
|
||||
* the defines
|
||||
******************************************************************************/
|
||||
|
||||
/*******************************************************************************
|
||||
* the typedefs
|
||||
******************************************************************************/
|
||||
|
||||
/*******************************************************************************
|
||||
* the globals
|
||||
******************************************************************************/
|
||||
|
||||
/*******************************************************************************
|
||||
* the function prototypes
|
||||
******************************************************************************/
|
||||
|
||||
/*! \brief Uds Service 3E processing
|
||||
*/
|
||||
extern void UdsService3E_TesterPresent(UdsType *obj, const uint8_t msgBuf[], uint16_t msgLen);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif /* extern "C" */
|
||||
|
||||
#endif /* _UDS_SERVICE3E_H_ */
|
@ -1,81 +0,0 @@
|
||||
/*
|
||||
* Copyright (c) 2022, Shenzhen CVA Innovation CO.,LTD
|
||||
* All rights reserved.
|
||||
*
|
||||
* Shenzhen CVA Innovation CO.,LTD (CVA chip) is supplying this file for use
|
||||
* exclusively with CVA's microcontroller products. This file can be freely
|
||||
* distributed within development tools that are supporting such microcontroller
|
||||
* products.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED "AS IS". NO WARRANTIES, WHETHER EXPRESS, IMPLIED
|
||||
* OR STATUTORY, INCLUDING, BUT NOT LIMITED TO, IMPLIED WARRANTIES OF
|
||||
* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE APPLY TO THIS SOFTWARE.
|
||||
* CVA SHALL NOT, IN ANY CIRCUMSTANCES, BE LIABLE FOR SPECIAL, INCIDENTAL,
|
||||
* OR CONSEQUENTIAL DAMAGES, FOR ANY REASON WHATSOEVER.
|
||||
*/
|
||||
|
||||
/*******************************************************************************
|
||||
* the includes
|
||||
******************************************************************************/
|
||||
|
||||
#include "uds_service85.h"
|
||||
#include "uds_dtc.h"
|
||||
|
||||
|
||||
|
||||
/*******************************************************************************
|
||||
* the defines
|
||||
******************************************************************************/
|
||||
|
||||
/*******************************************************************************
|
||||
* the typedefs
|
||||
******************************************************************************/
|
||||
|
||||
/*******************************************************************************
|
||||
* the globals
|
||||
******************************************************************************/
|
||||
|
||||
/*******************************************************************************
|
||||
* the constants
|
||||
******************************************************************************/
|
||||
|
||||
/*******************************************************************************
|
||||
* the functions
|
||||
******************************************************************************/
|
||||
|
||||
void UdsService85_ControlDtcSetting(UdsType *obj, const uint8_t msgBuf[], uint16_t msgLen)
|
||||
{
|
||||
uint8_t subFunction;
|
||||
uint8_t rspBuffer[8] = {0}; /* polyspace DEFECT:PARTIALLY_ACCESSED_ARRAY [No action planned:Low] "Still keep default though member2~7 is not written" */
|
||||
|
||||
if(msgLen < obj->seviceTable[obj->curServiceIdx].minLen)
|
||||
{
|
||||
Uds_NegativeResponse(obj, 0x85, NRC_INVALID_MESSAGE_LENGTH_OR_FORMAT);
|
||||
return;
|
||||
}
|
||||
|
||||
if(obj->session == UDS_SESSION_DEFAULT)
|
||||
{
|
||||
Uds_NegativeResponse(obj, 0x85, NRC_CONDITIONS_NOT_CORRECT);
|
||||
return;
|
||||
}
|
||||
|
||||
subFunction = UDS_GET_SUB_FUNCTION (msgBuf[1]);
|
||||
rspBuffer[0] = UDS_GET_POSITIVE_RSP(0x85);
|
||||
rspBuffer[1] = subFunction;
|
||||
switch(subFunction)
|
||||
{
|
||||
case 1:
|
||||
Uds_SetDtcOffCtrl(true);
|
||||
Uds_PositiveResponse(obj, rspBuffer, 2);
|
||||
break;
|
||||
case 2:
|
||||
Uds_SetDtcOffCtrl(false);
|
||||
Uds_PositiveResponse(obj, rspBuffer, 2);
|
||||
break;
|
||||
default:
|
||||
Uds_NegativeResponse(obj, 0x85, NRC_SUBFUNCTION_NOT_SUPPORTED);
|
||||
break;
|
||||
}
|
||||
|
||||
}
|
@ -1,60 +0,0 @@
|
||||
/*
|
||||
* Copyright (c) 2022, Shenzhen CVA Innovation CO.,LTD
|
||||
* All rights reserved.
|
||||
*
|
||||
* Shenzhen CVA Innovation CO.,LTD (CVA chip) is supplying this file for use
|
||||
* exclusively with CVA's microcontroller products. This file can be freely
|
||||
* distributed within development tools that are supporting such microcontroller
|
||||
* products.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED "AS IS". NO WARRANTIES, WHETHER EXPRESS, IMPLIED
|
||||
* OR STATUTORY, INCLUDING, BUT NOT LIMITED TO, IMPLIED WARRANTIES OF
|
||||
* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE APPLY TO THIS SOFTWARE.
|
||||
* CVA SHALL NOT, IN ANY CIRCUMSTANCES, BE LIABLE FOR SPECIAL, INCIDENTAL,
|
||||
* OR CONSEQUENTIAL DAMAGES, FOR ANY REASON WHATSOEVER.
|
||||
*/
|
||||
|
||||
#ifndef _UDS_SERVICE85_H_
|
||||
#define _UDS_SERVICE85_H_
|
||||
|
||||
/*! \brief Contains public interface to various functions related
|
||||
* to the user-defined UDS service 85
|
||||
*/
|
||||
|
||||
/*******************************************************************************
|
||||
* the includes
|
||||
******************************************************************************/
|
||||
|
||||
#include <stdbool.h>
|
||||
#include <stdint.h>
|
||||
#include "../stack/uds.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/*******************************************************************************
|
||||
* the defines
|
||||
******************************************************************************/
|
||||
|
||||
/*******************************************************************************
|
||||
* the typedefs
|
||||
******************************************************************************/
|
||||
|
||||
/*******************************************************************************
|
||||
* the globals
|
||||
******************************************************************************/
|
||||
|
||||
/*******************************************************************************
|
||||
* the function prototypes
|
||||
******************************************************************************/
|
||||
|
||||
/*! \brief Uds Service 85 processing
|
||||
*/
|
||||
extern void UdsService85_ControlDtcSetting(UdsType *obj, const uint8_t msgBuf[], uint16_t msgLen);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif /* extern "C" */
|
||||
|
||||
#endif /* _UDS_SERVICE85_H_ */
|
@ -19,7 +19,7 @@
|
||||
******************************************************************************/
|
||||
|
||||
#include "uds_user.h"
|
||||
|
||||
#include "bootloader_cfg.h"
|
||||
/*******************************************************************************
|
||||
* the defines
|
||||
******************************************************************************/
|
||||
|
Loading…
x
Reference in New Issue
Block a user