Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
H
haoJin750TFT
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
时昊
haoJin750TFT
Commits
f958e54b
Commit
f958e54b
authored
Aug 16, 2024
by
李延凯
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
feat: 添加周期检测Flash中的MCU信息, 删除不使用的诊断服务
parent
74f41343
Changes
9
Hide whitespace changes
Inline
Side-by-side
Showing
9 changed files
with
138 additions
and
810 deletions
+138
-810
BackLight.h
Firmware/Source/Application/BackLight.h
+1
-1
AMT630H.h
Firmware/Source/Component/AMT630H/AMT630H.h
+1
-1
GraphicsFunc.c
Firmware/Source/Component/AMT630H/GraphicsFunc.c
+117
-0
Menu.h
Firmware/Source/Component/Menu/Menu.h
+1
-1
flash.h
...Device/Cmsemicon/BAT32A279/Library/Driver/include/flash.h
+5
-5
flash.c
...rce/Device/Cmsemicon/BAT32A279/Library/Driver/src/flash.c
+2
-3
Sys_Task_List.c
Firmware/Source/System/Sys_Task_List.c
+1
-0
UDS_ISO14229_Services.c
Firmware/Source/UDS/UDS_ISO14229_Services.c
+4
-752
UDS_ISO14229_Services.h
Firmware/Source/UDS/UDS_ISO14229_Services.h
+6
-47
No files found.
Firmware/Source/Application/BackLight.h
View file @
f958e54b
...
@@ -27,4 +27,4 @@ void BackLight_Process(void);
...
@@ -27,4 +27,4 @@ void BackLight_Process(void);
#endif
#endif
\ No newline at end of file
Firmware/Source/Component/AMT630H/AMT630H.h
View file @
f958e54b
...
@@ -39,4 +39,4 @@ void AMT630H_Main(void);
...
@@ -39,4 +39,4 @@ void AMT630H_Main(void);
unsigned
char
AMT630H_isInitFinish
(
void
);
unsigned
char
AMT630H_isInitFinish
(
void
);
extern
uint32_t
Amt630hInitTimerCnts
;
extern
uint32_t
Amt630hInitTimerCnts
;
#endif
#endif
\ No newline at end of file
Firmware/Source/Component/AMT630H/GraphicsFunc.c
View file @
f958e54b
#include "UartProtocol.h"
#include "UartProtocol.h"
#include "PicBin.h"
#include "PicBin.h"
#include <stdint.h>
#include <stdint.h>
#include "UDS_ISO14229_Services.h"
#define NULL 0
#define NULL 0
#define READ_MCU_DATA_MAX 0x400
extern
uint8_t
UartRevBuff
[
0x1000
];
extern
uint8_t
UartRevBuff
[
0x1000
];
extern
uint32_t
UartRevCnts
;
extern
uint32_t
UartRevCnts
;
uint8_t
ReadDataBuf
[
READ_MCU_DATA_MAX
];
/* 读取缓存 */
uint32_t
NeedWriteSize
;
/* 需要写入文件的长度 */
uint32_t
FactOffset
;
/* 绝对地址 */
uint32_t
ReadOffset
;
/* 630中读取偏移量 */
uint32_t
AppOffset
;
uint32_t
Check_Upgrade_Cnt
;
uint8_t
*
GetUartRecvData
(
uint32_t
*
UartRecvBufLen
,
uint32_t
*
UartRecvPos
)
uint8_t
*
GetUartRecvData
(
uint32_t
*
UartRecvBufLen
,
uint32_t
*
UartRecvPos
)
{
{
*
UartRecvBufLen
=
0x1000
;
*
UartRecvBufLen
=
0x1000
;
...
@@ -345,3 +355,110 @@ void TestWrite630Backup(void)
...
@@ -345,3 +355,110 @@ void TestWrite630Backup(void)
}
}
}
}
/* Test end */
/* Test end */
void
GetReadInfo
(
READ_ARK630_CMD
type
)
{
static
uint8_t
readSt
=
0
;
static
uint16_t
getStRetryCnts
=
0
;
uint32_t
tmpRet
;
if
(
NeedWriteSize
==
0
)
{
if
(
readSt
==
0
)
{
readSt
=
1
;
ProcMcuOrBackupData
(
type
,
0
,
0
,
0
);
/* 获取偏移地址 */
getStRetryCnts
=
500
;
}
else
{
tmpRet
=
ProcMcuOrBackupData
(
GET_STATUS
,
0
,
0
,
0
);
if
((
tmpRet
!=
2
)
||
(
--
getStRetryCnts
==
0
))
/* 非零值为获得的程序地址 */
{
if
(
tmpRet
!=
2
)
{
NeedWriteSize
=
32
;
/* 此时的NeedWriteSize不重要, 只要跳出循环就行 */
if
(
type
==
GET_APP_DATA_OFFSET
)
{
FactOffset
=
0
;
/* USB按相对地址获取数据 */
}
else
{
FactOffset
=
tmpRet
;
/* 备份程序按绝对地址获取数据 */
}
AppOffset
=
0x00
;
}
readSt
=
0
;
}
}
}
}
/**
* @brief 检查Flash中的MCU程序信息, 是否与当前运行的MCU_APP信息相同, 若不同, 则进入升级模式
*/
void
Check_MCU_in_Flash
(
READ_ARK630_CMD
type
)
{
static
uint8_t
readSt
=
0
;
static
uint16_t
getStRetryCnts
=
0
;
uint32_t
tmpLen
;
uint32_t
writeLen
;
uint8_t
saveVersion
[
16
];
uint8_t
readVersion
[
16
];
if
(
NeedWriteSize
!=
0
)
{
if
(
readSt
==
0
)
{
readSt
=
1
;
(
void
)
memset
(
ReadDataBuf
,
0xFFU
,
sizeof
(
ReadDataBuf
));
/* 初始化buffer */
ProcMcuOrBackupData
(
REQ_DATA
,
FactOffset
+
ReadOffset
,
READ_MCU_DATA_MAX
,
ReadDataBuf
);
// 按地址获取程序数据
getStRetryCnts
=
500
;
ReadOffset
+=
READ_MCU_DATA_MAX
;
}
else
{
tmpLen
=
ProcMcuOrBackupData
(
GET_STATUS
,
0
,
0
,
0
);
/* 获取读取状态 */
if
(
FactOffset
+
ReadOffset
==
tmpLen
)
/* 当返回值为目标位置时为数据获取成功 */
{
if
(
AppOffset
==
0
)
/* 首个数据块内解析文件信息 */
{
if
(
type
==
GET_APP_DATA_OFFSET
)
/* 从 MCU_APP 升级文件 */
{
flash_read
(
FLASH_630H_UPDATE_INFO
,
sizeof
(
saveVersion
),
saveVersion
);
/* 读取630H升级记录 */
memcpy
(
readVersion
,
&
ReadDataBuf
[
16
],
16
);
/* 630中读出的版本信息 */
if
(
memcmp
(
&
ReadDataBuf
[
16
],
saveVersion
,
16
)
!=
0
)
/* 对比版本不同才更新 */
{
Get_Into_630H_Update_MCU_Mode
();
}
else
{
/* 信息相同, 重置状态 */
NeedWriteSize
=
0
;
readSt
=
0
;
}
}
}
}
if
(
--
getStRetryCnts
==
0
)
{
/* 读信息超时, 重置状态 */
ReadOffset
-=
READ_MCU_DATA_MAX
;
readSt
=
0
;
}
}
}
}
void
Check_MCU_Info_in_630H
(
void
)
{
Check_Upgrade_Cnt
+=
100U
;
if
(
Check_Upgrade_Cnt
>=
5000U
)
/* 每5秒检查一次Flash中的MCU程序信息 */
{
Check_Upgrade_Cnt
=
0U
;
GetReadInfo
(
GET_APP_DATA_OFFSET
);
Check_MCU_in_Flash
(
GET_APP_DATA_OFFSET
);
}
}
Firmware/Source/Component/Menu/Menu.h
View file @
f958e54b
...
@@ -426,4 +426,4 @@ void Menu_User_WAKEUP(void);
...
@@ -426,4 +426,4 @@ void Menu_User_WAKEUP(void);
/*-----------------------------------------------------------------------------------*/
/*-----------------------------------------------------------------------------------*/
/*-----------------------------------------------------------------------------------*/
/*-----------------------------------------------------------------------------------*/
/*-----------------------------------------------------------------------------------*/
/*-----------------------------------------------------------------------------------*/
#endif
#endif
\ No newline at end of file
Firmware/Source/Device/Cmsemicon/BAT32A279/Library/Driver/include/flash.h
View file @
f958e54b
...
@@ -15,10 +15,10 @@ typedef enum
...
@@ -15,10 +15,10 @@ typedef enum
extern
uint32_t
flash_protect_flag
;
extern
uint32_t
flash_protect_flag
;
int
EraseChip
(
uint32_t
adr
);
extern
int
EraseChip
(
uint32_t
adr
);
int
EraseSector
(
uint32_t
adr
);
extern
int
EraseSector
(
uint32_t
adr
);
int
ProgramPage
(
uint32_t
adr
,
uint32_t
sz
,
uint8_t
*
buf
);
extern
int
ProgramPage
(
uint32_t
adr
,
uint32_t
sz
,
uint8_t
*
buf
);
FLASH_STATUS
flash_write
(
uint32_t
adr
,
uint32_t
sz
,
uint8_t
*
buf
);
extern
FLASH_STATUS
flash_write
(
uint32_t
adr
,
uint32_t
sz
,
uint8_t
*
buf
);
void
flashRead
(
uint8_t
*
read_address
,
uint16_t
size
,
uint8_t
*
readbuf
);
extern
void
flash_read
(
uint32_t
read_address
,
uint16_t
size
,
uint8_t
*
readbuf
);
#endif
#endif
Firmware/Source/Device/Cmsemicon/BAT32A279/Library/Driver/src/flash.c
View file @
f958e54b
...
@@ -255,16 +255,15 @@ FLASH_STATUS flash_write(uint32_t adr, uint32_t sz, uint8_t *buf)
...
@@ -255,16 +255,15 @@ FLASH_STATUS flash_write(uint32_t adr, uint32_t sz, uint8_t *buf)
return
(
status
);
return
(
status
);
}
}
void
flash
Read
(
uint8_t
*
read_address
,
uint16_t
size
,
uint8_t
*
readbuf
)
void
flash
_read
(
uint32_t
read_address
,
uint16_t
size
,
uint8_t
*
readbuf
)
{
{
uint8_t
*
w_ptr
;
uint8_t
*
w_ptr
;
uint32_t
i
;
uint32_t
i
;
w_ptr
=
(
uint8_t
*
)
read_address
;
w_ptr
=
(
uint8_t
*
)
read_address
;
for
(
i
=
0
;
i
<
size
;
i
++
)
for
(
i
=
0
;
i
<
size
;
i
++
)
{
{
*
readbuf
=
*
w_ptr
++
;
*
readbuf
=
*
w_ptr
++
;
readbuf
++
;
readbuf
++
;
}
}
}
}
...
...
Firmware/Source/System/Sys_Task_List.c
View file @
f958e54b
...
@@ -77,6 +77,7 @@ void Sys_100ms_Tasks(void)
...
@@ -77,6 +77,7 @@ void Sys_100ms_Tasks(void)
ODOtest
=
Data_ODO_Read
();
ODOtest
=
Data_ODO_Read
();
Triptest
=
Data_Read_Trip
(
0
);
Triptest
=
Data_Read_Trip
(
0
);
S3_ServerCNTT
();
S3_ServerCNTT
();
Check_MCU_Info_in_630H
();
Get_DisTime_Service
();
Get_DisTime_Service
();
Fuel_Cal_Sevice
(
100u
);
Fuel_Cal_Sevice
(
100u
);
Coolant_Cal_Sevice
(
100u
);
Coolant_Cal_Sevice
(
100u
);
...
...
Firmware/Source/UDS/UDS_ISO14229_Services.c
View file @
f958e54b
...
@@ -5,6 +5,7 @@
...
@@ -5,6 +5,7 @@
�� ��;V1.0
�� ��;V1.0
�� ��;2016.11.1
�� ��;2016.11.1
******************************************************************************/
******************************************************************************/
#include <string.h>
#include "UDS_ISO14229_Services.h"
#include "UDS_ISO14229_Services.h"
#include "UDS_ISO14229_Server.h"
#include "UDS_ISO14229_Server.h"
#include "flash.h"
#include "flash.h"
...
@@ -32,28 +33,13 @@ extern const project_info_t project_info __attribute__((section(".ARM.__at_0x000
...
@@ -32,28 +33,13 @@ extern const project_info_t project_info __attribute__((section(".ARM.__at_0x000
DiagSendDataNeg
NegRes
;
DiagSendDataNeg
NegRes
;
uint8_t
UDS_ISO14229_Transfer
[
250
];
uint8_t
UDS_ISO14229_Transfer
[
250
];
DiagDFlashData
DiagDataForDFlash
;
Ser2EDFlashData
Ser2EDataForDFlash
;
DiagFlag
DiagDataForFlag
;
DiagFlag
DiagDataForFlag
;
Ser27_FlowCtrlCntUnion
Ser27_FlowCtrlCnt
;
uint8_t
FlashDriverCheckSum
=
0
;
uint8_t
BlocKCnt
=
0
;
/****************S3Timer********************/
/****************S3Timer********************/
uint8_t
S3_ServerEN
=
0
;
uint8_t
S3_ServerEN
=
0
;
uint8_t
S3_ServerCnt
=
0
;
uint8_t
S3_ServerCnt
=
0
;
uint8_t
S3_Server_refresh
=
0
;
uint8_t
S3_Server_refresh
=
0
;
/****************DiagnosticSession*****************/
/****************DiagnosticSession*****************/
uint8_t
SessionType
=
0x01
;
uint8_t
SessionType
=
0x01
;
/****************Ser28*********************/
uint8_t
ControlType
;
uint8_t
CommunicationType
;
/****************Ser27*********************/
uint8_t
wait10cnt
=
0
;
uint8_t
Wait10sFlag
=
0
;
uint8_t
DiagLockFlag
=
0
;
uint8_t
Seed
[
4
];
uint32_t
ValidSeedKey
;
uint8_t
Services27_01_Requested
;
/******************************************************************************
/******************************************************************************
The service access point of the diagnostics application layer provides a number
The service access point of the diagnostics application layer provides a number
of services that all have the same general structure. For each service, three
of services that all have the same general structure. For each service, three
...
@@ -102,109 +88,18 @@ const uint8_t DID_1024[13] =
...
@@ -102,109 +88,18 @@ const uint8_t DID_1024[13] =
((
internal_date
%
10UL
)
+
0x30
)
((
internal_date
%
10UL
)
+
0x30
)
};
};
void
Data_Set_DiagPara
(
void
)
{
uint8_t
i
;
//获取DID的值,等待写入DFlash
for
(
i
=
0
;
i
<
6
;
i
++
)
{
DiagDataForDFlash
.
DID_F180
[
i
]
=
MCU_FBLversion
[
i
];
}
for
(
i
=
0
;
i
<
16
;
i
++
)
{
DiagDataForDFlash
.
DID_F187
[
i
]
=
MCU_PartNumber
[
i
];
}
for
(
i
=
0
;
i
<
6
;
i
++
)
{
DiagDataForDFlash
.
DID_F193
[
i
]
=
MCU_HWversion
[
i
];
}
for
(
i
=
0
;
i
<
6
;
i
++
)
{
DiagDataForDFlash
.
DID_F195
[
i
]
=
MCU_SWversion
[
i
];
}
for
(
i
=
0
;
i
<
2
;
i
++
)
{
DiagDataForDFlash
.
Filldata
[
i
]
=
0u
;
}
}
/*写App有效性标志*/
/*写App有效性标志*/
void
Write_App_InValid
(
uint32_t
m32
)
void
Write_App_InValid
(
uint32_t
m32
)
{
{
//设置App状态值
//设置App状态值
DiagDataForFlag
.
Flag
=
0xA77A5AA5u
;
DiagDataForFlag
.
Flag
=
0xA77A5AA5u
;
DiagDataForFlag
.
APP_STATUS
=
m32
;
DiagDataForFlag
.
APP_STATUS
=
m32
;
//擦除扇区
EraseSector
(
FLASH_APP_STATUS_INFO
);
EraseSector
(
APP_STATUS_ADDR
);
ProgramPage
(
FLASH_APP_STATUS_INFO
,
8U
,
(
uint8_t
*
)(
&
DiagDataForFlag
));
//App程序状态和22服务数据全写进去
ProgramPage
(
APP_STATUS_ADDR
,
8U
,
(
uint8_t
*
)(
&
DiagDataForFlag
));
}
}
/*写22服务数据*/
void
DFlash_init
(
void
)
{
}
void
Data_Read_DiagPara
(
void
)
{
uint8_t
i
;
Ser2EDFlashData
*
ReadSer2EDataForDFlash
=
(
Ser2EDFlashData
*
)
APP_DATA_WRITE
;
DiagDFlashData
*
ReadDiagDataForDFlash
=
(
DiagDFlashData
*
)
APP_DATA_INFO
;
if
(
(
ReadDiagDataForDFlash
->
Flag
!=
0x5AA5A77Au
)
||
(
0
!=
memcmp
(
ReadDiagDataForDFlash
->
DID_F180
,
MCU_FBLversion
,
sizeof
(
MCU_FBLversion
)))
||
(
0
!=
memcmp
(
ReadDiagDataForDFlash
->
DID_F187
,
MCU_PartNumber
,
sizeof
(
MCU_PartNumber
)))
||
(
0
!=
memcmp
(
ReadDiagDataForDFlash
->
DID_F193
,
MCU_HWversion
,
sizeof
(
MCU_HWversion
)))
||
(
0
!=
memcmp
(
ReadDiagDataForDFlash
->
DID_F195
,
MCU_SWversion
,
sizeof
(
MCU_SWversion
)))
)
{
Data_Set_DiagPara
();
DiagDataForDFlash
.
Flag
=
0x5AA5A77Au
;
//擦除扇区
EraseSector
(
APP_DATA_INFO
);
//App程序状态和22服务数据全写进去
ProgramPage
(
APP_DATA_INFO
,
sizeof
(
DiagDataForDFlash
),
(
uint8_t
*
)(
&
DiagDataForDFlash
));
}
else
{
memcpy
(
&
DiagDataForDFlash
,
ReadDiagDataForDFlash
,
sizeof
(
DiagDFlashData
));
}
if
(
ReadSer2EDataForDFlash
->
Flag
!=
0x5AA5A77Au
)
{
memset
(
&
Ser2EDataForDFlash
.
DID_F184
[
0
],
0
,
sizeof
(
Ser2EDataForDFlash
.
DID_F184
));
EraseSector
(
APP_DATA_WRITE
);
ProgramPage
(
APP_DATA_WRITE
,
sizeof
(
DiagDataForDFlash
),
(
uint8_t
*
)(
&
DiagDataForDFlash
));
}
else
{
for
(
i
=
0
;
i
<
sizeof
(
Ser2EDataForDFlash
.
DID_F184
);
i
++
)
{
Ser2EDataForDFlash
.
DID_F184
[
i
]
=
ReadSer2EDataForDFlash
->
DID_F184
[
i
];
}
}
}
void
S3_ServerCNTT
(
void
)
void
S3_ServerCNTT
(
void
)
{
{
if
(
Wait10sFlag
==
1
)
{
if
(
wait10cnt
>=
100
)
{
Ser27_FlowCtrlCnt
.
RequestSeedCnt
=
2
;
Ser27_FlowCtrlCnt
.
Attemptcnt
=
2
;
// WriteDFlashData(0x02u, ( uint32_t * )&Ser27_FlowCtrlCnt.Flag, sizeof(Ser27_FlowCtrlCnt) / 4u, NoNeedWait);
wait10cnt
=
0
;
Wait10sFlag
=
0
;
}
else
{
++
wait10cnt
;
}
}
if
(
S3_ServerEN
==
1
)
if
(
S3_ServerEN
==
1
)
{
{
if
(
S3_Server_refresh
==
1
)
if
(
S3_Server_refresh
==
1
)
...
@@ -216,8 +111,6 @@ void S3_ServerCNTT(void)
...
@@ -216,8 +111,6 @@ void S3_ServerCNTT(void)
if
(
S3_ServerCnt
>=
S3_SERVER
)
if
(
S3_ServerCnt
>=
S3_SERVER
)
{
{
DIAG_InitParameter
(
);
DIAG_InitParameter
(
);
CAN_RX_SetEnable
(
&
CAN_CH0_CanMsgOp
,
CAN_N_RX_Enable
);
CAN_TX_SetEnable
(
&
CAN_CH0_CanMsgTxOp
,
CAN_N_TX_Enable
);
//S3超时解除
}
}
else
else
{
{
...
@@ -226,16 +119,6 @@ void S3_ServerCNTT(void)
...
@@ -226,16 +119,6 @@ void S3_ServerCNTT(void)
}
}
}
}
uint32_t
RANDOM
=
0xA77A
;
void
Randomcnt
(
void
)
{
RANDOM
++
;
if
(
RANDOM
>=
0xFF0F00F0
)
{
RANDOM
=
0x363
;
}
}
uint8_t
SerXXNRC12Filter
(
uint8_t
insub
,
const
uint8_t
*
supportsub
,
uint8_t
size
,
uint8_t
*
index
)
uint8_t
SerXXNRC12Filter
(
uint8_t
insub
,
const
uint8_t
*
supportsub
,
uint8_t
size
,
uint8_t
*
index
)
{
{
uint8_t
sub
=
insub
;
uint8_t
sub
=
insub
;
...
@@ -333,21 +216,6 @@ uint8_t SerXXNRC31DIDFilter(uint16_t inDID, const uint16_t *DIDList, uint8_t siz
...
@@ -333,21 +216,6 @@ uint8_t SerXXNRC31DIDFilter(uint16_t inDID, const uint16_t *DIDList, uint8_t siz
return
nrccode
;
return
nrccode
;
}
}
uint8_t
SerXXNRC33Filter
(
const
uint8_t
*
levelList
,
uint8_t
index
)
{
uint8_t
nrccode
;
nrccode
=
0
;
if
(
NoNeed
!=
levelList
[
index
]
)
{
if
(
DiagLockFlag
!=
levelList
[
index
]
)
{
nrccode
=
securityAccessDenied
;
}
}
return
nrccode
;
}
uint8_t
SerXXNRC7EFilter
(
const
uint8_t
*
SubSupportSession
,
uint8_t
index
)
uint8_t
SerXXNRC7EFilter
(
const
uint8_t
*
SubSupportSession
,
uint8_t
index
)
{
{
uint8_t
nrccode
;
uint8_t
nrccode
;
...
@@ -402,7 +270,6 @@ static const uint8_t Ser10BanResponse = AbleResponseType;
...
@@ -402,7 +270,6 @@ static const uint8_t Ser10BanResponse = AbleResponseType;
static
const
uint8_t
Ser10Sub
[]
=
{
DefaultSession
,
ProgrammingSession
,
ExtendedDiagnosticSession
};
static
const
uint8_t
Ser10Sub
[]
=
{
DefaultSession
,
ProgrammingSession
,
ExtendedDiagnosticSession
};
static
const
uint8_t
Ser10MinLen
[]
=
{
1
};
static
const
uint8_t
Ser10MinLen
[]
=
{
1
};
static
const
uint8_t
Ser10SubLen
[]
=
{
1
,
1
,
1
};
static
const
uint8_t
Ser10SubLen
[]
=
{
1
,
1
,
1
};
static
const
uint8_t
Ser10UnlockLevel
[]
=
{
NoNeed
,
NoNeed
,
NoNeed
};
static
const
uint8_t
Ser10SupportSession
=
DefaultMode
|
ProgrammingMode
|
ExtendedDiagnosticMode
;
static
const
uint8_t
Ser10SupportSession
=
DefaultMode
|
ProgrammingMode
|
ExtendedDiagnosticMode
;
static
const
uint8_t
Ser10SubSupportSession
[]
=
{
DefaultMode
|
ProgrammingMode
|
ExtendedDiagnosticMode
,
ProgrammingMode
|
ExtendedDiagnosticMode
,
static
const
uint8_t
Ser10SubSupportSession
[]
=
{
DefaultMode
|
ProgrammingMode
|
ExtendedDiagnosticMode
,
ProgrammingMode
|
ExtendedDiagnosticMode
,
DefaultMode
|
ExtendedDiagnosticMode
};
DefaultMode
|
ExtendedDiagnosticMode
};
...
@@ -449,11 +316,6 @@ void UDS_Service_10_Indication(uint16_t A_TA_type, uint16_t A_Length, uint8_t *A
...
@@ -449,11 +316,6 @@ void UDS_Service_10_Indication(uint16_t A_TA_type, uint16_t A_Length, uint8_t *A
NrcCode
=
subFunctionNotSupported
;
NrcCode
=
subFunctionNotSupported
;
}
}
if
(
0
==
NrcCode
&&
Index
<
sizeof
(
Ser10UnlockLevel
))
{
NrcCode
=
SerXXNRC33Filter
(
Ser10UnlockLevel
,
Index
);
}
if
(
0
==
NrcCode
&&
(
Index
<
sizeof
(
Ser10SubSupportSession
)))
if
(
0
==
NrcCode
&&
(
Index
<
sizeof
(
Ser10SubSupportSession
)))
{
{
NrcCode
=
SerXXNRC7EFilter
(
Ser10SubSupportSession
,
Index
);
NrcCode
=
SerXXNRC7EFilter
(
Ser10SubSupportSession
,
Index
);
...
@@ -501,8 +363,6 @@ void UDS_Service_10_Indication(uint16_t A_TA_type, uint16_t A_Length, uint8_t *A
...
@@ -501,8 +363,6 @@ void UDS_Service_10_Indication(uint16_t A_TA_type, uint16_t A_Length, uint8_t *A
S3_ServerEN
=
1
;
S3_ServerEN
=
1
;
S3_Server_refresh
=
1
;
S3_Server_refresh
=
1
;
SessionType
=
ProgrammingSession
;
SessionType
=
ProgrammingSession
;
Services27_01_Requested
=
0
;
DiagLockFlag
=
0
;
if
(
AbleResponseType
==
Ser10BanResponse
)
if
(
AbleResponseType
==
Ser10BanResponse
)
{
{
...
@@ -546,8 +406,6 @@ void UDS_Service_10_Indication(uint16_t A_TA_type, uint16_t A_Length, uint8_t *A
...
@@ -546,8 +406,6 @@ void UDS_Service_10_Indication(uint16_t A_TA_type, uint16_t A_Length, uint8_t *A
S3_ServerEN
=
1
;
S3_ServerEN
=
1
;
S3_Server_refresh
=
1
;
S3_Server_refresh
=
1
;
SessionType
=
ExtendedDiagnosticSession
;
SessionType
=
ExtendedDiagnosticSession
;
Services27_01_Requested
=
0
;
DiagLockFlag
=
0
;
if
(
AbleResponseType
==
Ser10BanResponse
)
if
(
AbleResponseType
==
Ser10BanResponse
)
{
{
...
@@ -589,7 +447,6 @@ static const uint8_t Ser11BanResponse = AbleResponseType;
...
@@ -589,7 +447,6 @@ static const uint8_t Ser11BanResponse = AbleResponseType;
static
const
uint8_t
Ser11Sub
[]
=
{
HardReset
};
static
const
uint8_t
Ser11Sub
[]
=
{
HardReset
};
static
const
uint8_t
Ser11MinLen
[]
=
{
1
};
static
const
uint8_t
Ser11MinLen
[]
=
{
1
};
static
const
uint8_t
Ser11SubLen
[]
=
{
1
};
static
const
uint8_t
Ser11SubLen
[]
=
{
1
};
static
const
uint8_t
Ser11UnlockLevel
[]
=
{
NoNeed
};
static
const
uint8_t
Ser11SupportSession
=
ProgrammingMode
|
ExtendedDiagnosticMode
;
static
const
uint8_t
Ser11SupportSession
=
ProgrammingMode
|
ExtendedDiagnosticMode
;
static
const
uint8_t
Ser11SubSupportSession
[]
=
{
ProgrammingMode
|
ExtendedDiagnosticMode
};
static
const
uint8_t
Ser11SubSupportSession
[]
=
{
ProgrammingMode
|
ExtendedDiagnosticMode
};
void
UDS_Service_11_Indication
(
uint16_t
A_TA_type
,
uint16_t
A_Length
,
uint8_t
*
A_Data
)
void
UDS_Service_11_Indication
(
uint16_t
A_TA_type
,
uint16_t
A_Length
,
uint8_t
*
A_Data
)
...
@@ -635,11 +492,6 @@ void UDS_Service_11_Indication(uint16_t A_TA_type, uint16_t A_Length, uint8_t *A
...
@@ -635,11 +492,6 @@ void UDS_Service_11_Indication(uint16_t A_TA_type, uint16_t A_Length, uint8_t *A
NrcCode
=
SerXXNRC12Filter
(
SubFunction
,
Ser11Sub
,
sizeof
(
Ser11Sub
),
&
Index
);
NrcCode
=
SerXXNRC12Filter
(
SubFunction
,
Ser11Sub
,
sizeof
(
Ser11Sub
),
&
Index
);
}
}
if
(
0
==
NrcCode
&&
Index
<
sizeof
(
Ser11UnlockLevel
))
{
NrcCode
=
SerXXNRC33Filter
(
Ser11UnlockLevel
,
Index
);
}
if
(
0
==
NrcCode
&&
(
Index
<
sizeof
(
Ser11SubSupportSession
)))
if
(
0
==
NrcCode
&&
(
Index
<
sizeof
(
Ser11SubSupportSession
)))
{
{
NrcCode
=
SerXXNRC7EFilter
(
Ser11SubSupportSession
,
Index
);
NrcCode
=
SerXXNRC7EFilter
(
Ser11SubSupportSession
,
Index
);
...
@@ -706,7 +558,6 @@ static const uint8_t Ser22Sub [] = {0xFF};
...
@@ -706,7 +558,6 @@ static const uint8_t Ser22Sub [] = {0xFF};
static
const
uint8_t
Ser22MinLen
[]
=
{
2
};
static
const
uint8_t
Ser22MinLen
[]
=
{
2
};
static
const
uint8_t
Ser22SubLen
[]
=
{
2
};
static
const
uint8_t
Ser22SubLen
[]
=
{
2
};
static
const
uint16_t
Ser22DIDList
[]
=
{
0xF195
,
0xF193
,
0xF180
,
0xF187
,
0x1024
,
0x1028
,
0xF184
,
/*0x2024*/
};
static
const
uint16_t
Ser22DIDList
[]
=
{
0xF195
,
0xF193
,
0xF180
,
0xF187
,
0x1024
,
0x1028
,
0xF184
,
/*0x2024*/
};
static
const
uint8_t
Ser22UnlockLevel
[]
=
{
NoNeed
};
static
const
uint8_t
Ser22SupportSession
=
DefaultMode
|
ProgrammingMode
|
ExtendedDiagnosticMode
;
static
const
uint8_t
Ser22SupportSession
=
DefaultMode
|
ProgrammingMode
|
ExtendedDiagnosticMode
;
static
const
uint8_t
Ser22SubSupportSession
[]
=
{
DefaultMode
|
ProgrammingMode
|
ExtendedDiagnosticMode
};
static
const
uint8_t
Ser22SubSupportSession
[]
=
{
DefaultMode
|
ProgrammingMode
|
ExtendedDiagnosticMode
};
void
UDS_Service_22_Indication
(
uint16_t
A_TA_type
,
uint16_t
A_Length
,
uint8_t
*
A_Data
)
void
UDS_Service_22_Indication
(
uint16_t
A_TA_type
,
uint16_t
A_Length
,
uint8_t
*
A_Data
)
...
@@ -753,11 +604,6 @@ void UDS_Service_22_Indication(uint16_t A_TA_type, uint16_t A_Length, uint8_t *A
...
@@ -753,11 +604,6 @@ void UDS_Service_22_Indication(uint16_t A_TA_type, uint16_t A_Length, uint8_t *A
NrcCode
=
SerXXNRC12Filter
(
SubFunction
,
Ser22Sub
,
0
,
&
Index
);
NrcCode
=
SerXXNRC12Filter
(
SubFunction
,
Ser22Sub
,
0
,
&
Index
);
}
}
if
(
0
==
NrcCode
&&
Index
<
sizeof
(
Ser22UnlockLevel
))
{
NrcCode
=
SerXXNRC33Filter
(
Ser22UnlockLevel
,
Index
);
}
if
(
0
==
NrcCode
&&
(
Index
<
sizeof
(
Ser22SubSupportSession
)))
if
(
0
==
NrcCode
&&
(
Index
<
sizeof
(
Ser22SubSupportSession
)))
{
{
NrcCode
=
SerXXNRC7EFilter
(
Ser22SubSupportSession
,
Index
);
NrcCode
=
SerXXNRC7EFilter
(
Ser22SubSupportSession
,
Index
);
...
@@ -819,14 +665,6 @@ void UDS_Service_22_Indication(uint16_t A_TA_type, uint16_t A_Length, uint8_t *A
...
@@ -819,14 +665,6 @@ void UDS_Service_22_Indication(uint16_t A_TA_type, uint16_t A_Length, uint8_t *A
UDS_Service_Response
(
si
,
POSITIVE_RSP
,
DIAG_ID_Tx
,
2
+
sizeof
(
DID_1024
),
UDS_ISO14229_Transfer
);
UDS_Service_Response
(
si
,
POSITIVE_RSP
,
DIAG_ID_Tx
,
2
+
sizeof
(
DID_1024
),
UDS_ISO14229_Transfer
);
break
;
break
;
case
0xF184
:
// UUID
for
(
i
=
0
;
i
<
32
;
i
++
)
{
UDS_ISO14229_Transfer
[
i
+
2
]
=
Ser2EDataForDFlash
.
DID_F184
[
i
];
}
UDS_Service_Response
(
0x22
,
POSITIVE_RSP
,
DIAG_ID_Tx
,
2
+
32
,
UDS_ISO14229_Transfer
);
break
;
// case 0x2024: // ESP32内部版本号
// case 0x2024: // ESP32内部版本号
// UDS_ISO14229_Transfer[3] = BlueTooth.ESP32_SWV;
// UDS_ISO14229_Transfer[3] = BlueTooth.ESP32_SWV;
// UDS_Service_Response(0x22, POSITIVE_RSP, DIAG_ID_Tx, 2 + 1, UDS_ISO14229_Transfer);
// UDS_Service_Response(0x22, POSITIVE_RSP, DIAG_ID_Tx, 2 + 1, UDS_ISO14229_Transfer);
...
@@ -862,472 +700,6 @@ void UDS_Service_22_Indication(uint16_t A_TA_type, uint16_t A_Length, uint8_t *A
...
@@ -862,472 +700,6 @@ void UDS_Service_22_Indication(uint16_t A_TA_type, uint16_t A_Length, uint8_t *A
}
}
}
}
void
UDS_Service_2E_Indication
(
uint16_t
A_TA_type
,
uint16_t
A_Length
,
uint8_t
*
A_Data
)
{
uint16_t
i
;
uint16_t
DID
;
uint8_t
Data
[
8
];
uint8_t
Service2EDiagDataLength
;
uint16_t
FunorPhy
=
0
;
Service2EDiagDataLength
=
A_Length
;
S3_ServerCnt
=
0
;
FunorPhy
=
A_TA_type
;
for
(
i
=
0
;
i
<
Service2EDiagDataLength
;
++
i
)
{
UDS_ISO14229_Transfer
[
i
]
=
*
(
A_Data
+
i
);
}
if
(
FunorPhy
==
0X7DF
)
return
;
if
(
DiagLockFlag
==
0x00
)
{
NegRes
.
code
=
securityAccessDenied
;
//NRC33
UDS_Service_Response
(
0x2E
,
NEGATIVE_RSP
,
DIAG_ID_Tx
,
1
,
(
uint8_t
*
)
(
&
NegRes
.
code
)
);
return
;
}
if
(
Service2EDiagDataLength
<
3
)
{
NegRes
.
code
=
incorrectMessageLength
;
//NRC13
UDS_Service_Response
(
0x2E
,
NEGATIVE_RSP
,
DIAG_ID_Tx
,
1
,
(
uint8_t
*
)
(
&
NegRes
.
code
)
);
return
;
}
if
(
(
SessionType
==
DefaultSession
)
||
(
SessionType
==
ProgrammingSession
))
{
NegRes
.
code
=
serviceNotSupportedInActiveSession
;
//NRC7F
UDS_Service_Response
(
0x2E
,
NEGATIVE_RSP
,
DIAG_ID_Tx
,
1
,
(
uint8_t
*
)
(
&
NegRes
.
code
)
);
return
;
}
DID
=
((
uint16_t
)
UDS_ISO14229_Transfer
[
0
]
<<
8
)
|
((
uint16_t
)
UDS_ISO14229_Transfer
[
1
]);
switch
(
DID
)
{
case
0xF184
:
// 读指纹数据标识符
for
(
i
=
0
;
i
<
33
;
i
++
)
{
Data
[
i
]
=
UDS_ISO14229_Transfer
[
i
+
2
];
}
for
(
i
=
0
;
i
<
(
sizeof
(
Ser2EDataForDFlash
.
DID_F184
));
i
++
)
{
Ser2EDataForDFlash
.
DID_F184
[
i
]
=
Data
[
i
];
}
Ser2EDataForDFlash
.
Flag
=
0x5AA5A77Au
;
// memcpy(Ser2EDataForDFlash.DID_F184, Data, sizeof(Ser2EDataForDFlash.DID_F184));
//擦除扇区
EraseSector
(
APP_DATA_WRITE
);
//App程序状态和22服务数据全写进去
ProgramPage
(
APP_DATA_WRITE
,
sizeof
(
Ser2EDataForDFlash
),
(
uint8_t
*
)(
&
Ser2EDataForDFlash
));
UDS_Service_Response
(
0x2E
,
POSITIVE_RSP
,
DIAG_ID_Tx
,
2
,
UDS_ISO14229_Transfer
);
break
;
default:
if
(
FunorPhy
==
0x7df
)
{
return
;
}
NegRes
.
code
=
requestOutOfRange
;
UDS_Service_Response
(
0x2E
,
NEGATIVE_RSP
,
DIAG_ID_Tx
,
1
,
(
uint8_t
*
)
(
&
NegRes
.
code
)
);
break
;
}
}
void
GetSeed
(
void
)
{
uint8_t
SeedHigh
;
uint8_t
SeedLow
;
uint16_t
tempbuffer
;
tempbuffer
=
(
uint16_t
)(
RANDOM
);
SeedHigh
=
(
uint8_t
)(
tempbuffer
>>
8
);
SeedLow
=
(
uint8_t
)(
tempbuffer
&
0xff
);
Seed
[
0
]
=
0x31
+
~
SeedHigh
;
Seed
[
1
]
=
0x23
+
~
SeedLow
;
Seed
[
2
]
=
0x56
+
SeedHigh
;
Seed
[
3
]
=
0x71
+
SeedLow
;
}
const
uint32_t
KeyK
=
0x00000201
;
void
CalculateKey
(
void
)
{
uint32_t
SaccSeed
;
uint32_t
KeyResult
;
SaccSeed
=
((
uint32_t
)
Seed
[
0
])
<<
24
|
((
uint32_t
)
Seed
[
1
])
<<
16
|
((
uint32_t
)
Seed
[
2
])
<<
8
|
((
uint32_t
)
Seed
[
3
]);
KeyResult
=
(((
SaccSeed
>>
1
)
^
SaccSeed
)
<<
3
)
^
(
SaccSeed
>>
2
);
KeyResult
=
KeyResult
^
KeyK
;
ValidSeedKey
=
KeyResult
;
}
void
CalculateKeyLv11
(
void
)
{
uint32_t
SaccSeed
;
uint32_t
KeyResult
;
SaccSeed
=
((
uint32_t
)
Seed
[
0
])
<<
24
|
((
uint32_t
)
Seed
[
1
])
<<
16
|
((
uint32_t
)
Seed
[
2
])
<<
8
|
((
uint32_t
)
Seed
[
3
]);
KeyResult
=
(((
SaccSeed
>>
1
)
^
SaccSeed
)
<<
3
)
^
(
SaccSeed
>>
2
);
KeyResult
=
KeyResult
^
KeyK
;
ValidSeedKey
=
KeyResult
;
}
/******************************************************************************
27# - SecurityAccess
******************************************************************************/
static
const
uint8_t
Ser27BanResponse
=
DisableResponseType
;
static
const
uint8_t
Ser27Sub
[]
=
{
requestSeed_LV1
,
sendKey_LV1
};
static
const
uint8_t
Ser27MinLen
[]
=
{
1
};
static
const
uint8_t
Ser27SubLen
[]
=
{
1
,
5
};
static
const
uint8_t
Ser27UnlockLevel
[]
=
{
NoNeed
,
NoNeed
};
static
const
uint8_t
Ser27SupportSession
=
ProgrammingMode
|
ExtendedDiagnosticMode
;
static
const
uint8_t
Ser27SubSupportSession
[]
=
{
ProgrammingMode
|
ExtendedDiagnosticMode
,
ProgrammingMode
|
ExtendedDiagnosticMode
};
void
UDS_Service_27_Indication
(
uint16_t
A_TA_type
,
uint16_t
A_Length
,
uint8_t
*
A_Data
)
{
uint8_t
i
;
uint8_t
si
=
SecurityAccess
;
uint8_t
NrcCode
=
0
;
uint8_t
Index
=
0
;
uint8_t
SubFunction
=
0
;
uint16_t
FunorPhy
=
A_TA_type
;
uint16_t
Service27DiagDataLength
=
A_Length
;
uint32_t
KeyReceive
;
for
(
i
=
0
;
i
<
Service27DiagDataLength
;
++
i
)
{
UDS_ISO14229_Transfer
[
i
]
=
*
(
A_Data
+
i
);
}
if
((
0
==
NrcCode
)
&&
(
DIAG_ID_Rx_FUN
==
FunorPhy
))
{
NrcCode
=
serviceNotSupported
;
}
if
(
0
==
NrcCode
)
{
NrcCode
=
SerXXNRC7FFilter
(
Ser27SupportSession
);
}
if
(
0
==
NrcCode
)
{
NrcCode
=
SerXXNRC13Filter
(
MinLengthType
,
Service27DiagDataLength
,
Ser27MinLen
,
Index
);
}
if
(
0
==
NrcCode
)
{
if
(
AbleResponseType
==
Ser27BanResponse
)
{
SubFunction
=
UDS_ISO14229_Transfer
[
0
]
&
0x7F
;
}
else
{
SubFunction
=
UDS_ISO14229_Transfer
[
0
];
}
NrcCode
=
SerXXNRC12Filter
(
SubFunction
,
Ser27Sub
,
sizeof
(
Ser27Sub
),
&
Index
);
}
if
(
0
==
NrcCode
&&
Index
<
sizeof
(
Ser27UnlockLevel
))
{
NrcCode
=
SerXXNRC33Filter
(
Ser27UnlockLevel
,
Index
);
}
if
(
0
==
NrcCode
&&
(
Index
<
sizeof
(
Ser27SubSupportSession
)))
{
NrcCode
=
SerXXNRC7EFilter
(
Ser27SubSupportSession
,
Index
);
}
if
(
0
==
NrcCode
&&
(
Index
<
sizeof
(
Ser27SubLen
)))
{
NrcCode
=
SerXXNRC13Filter
(
SubLengthType
,
Service27DiagDataLength
,
Ser27SubLen
,
Index
);
}
if
(
0
==
NrcCode
)
{
NrcCode
=
SerXXNRC22Filter
();
}
if
(
0
==
NrcCode
)
{
if
(
1
==
Wait10sFlag
)
{
NrcCode
=
requiredTimeDelayNotExpired
;
}
}
if
(
0
==
NrcCode
)
{
if
(
0
==
Services27_01_Requested
&&
sendKey_LV1
==
SubFunction
)
{
NrcCode
=
requestSequenceError
;
}
}
if
(
0
==
NrcCode
)
{
KeyReceive
=
((
uint32_t
)
UDS_ISO14229_Transfer
[
1
]
<<
24
)
|
((
uint32_t
)
UDS_ISO14229_Transfer
[
2
]
<<
16
)
|
((
uint16_t
)
UDS_ISO14229_Transfer
[
3
]
<<
8
)
|
UDS_ISO14229_Transfer
[
4
];
if
(
sendKey_LV1
==
SubFunction
&&
(
KeyReceive
==
0x00000000
||
KeyReceive
==
0xFFFFFFFF
))
{
NrcCode
=
requestOutOfRange
;
}
}
if
(
0
==
NrcCode
)
{
if
(
sendKey_LV1
==
SubFunction
&&
KeyReceive
!=
ValidSeedKey
)
{
Services27_01_Requested
=
0
;
Ser27_FlowCtrlCnt
.
Attemptcnt
++
;
// WriteDFlashData(0x02u, (uint32_t *)&Ser27_FlowCtrlCnt.Flag, sizeof(Ser27_FlowCtrlCnt) / 4u, NeedWait);
NrcCode
=
invalidKey
;
}
}
if
(
0
==
NrcCode
||
invalidKey
==
NrcCode
)
{
if
(
sendKey_LV1
==
SubFunction
)
{
if
(
AttemptMaxCnt
<=
Ser27_FlowCtrlCnt
.
Attemptcnt
)
{
Wait10sFlag
=
1
;
NrcCode
=
exceedNumberOfAttempts
;
}
}
if
(
requestSeed_LV1
==
SubFunction
)
{
Ser27_FlowCtrlCnt
.
Attemptcnt
=
Ser27_FlowCtrlCnt
.
RequestSeedCnt
;
Ser27_FlowCtrlCnt
.
RequestSeedCnt
++
;
// WriteDFlashData(0x02u, (uint32_t *)&Ser27_FlowCtrlCnt.Flag, sizeof(Ser27_FlowCtrlCnt) / 4u, NeedWait);
if
(
RequestSeedMaxCnt
<=
Ser27_FlowCtrlCnt
.
RequestSeedCnt
)
{
Wait10sFlag
=
1
;
NrcCode
=
exceedNumberOfAttempts
;
}
}
}
if
(
0
==
NrcCode
)
{
if
(
requestSeed_LV1
==
SubFunction
)
{
if
(
NormalKeyLock
==
DiagLockFlag
)
{
Services27_01_Requested
=
1
;
do
{
GetSeed
();
}
while
(
Seed
[
0
]
==
0
&&
Seed
[
1
]
==
0
&&
Seed
[
2
]
==
0
&&
Seed
[
3
]
==
0
);
UDS_ISO14229_Transfer
[
1
]
=
Seed
[
0
];
UDS_ISO14229_Transfer
[
2
]
=
Seed
[
1
];
UDS_ISO14229_Transfer
[
3
]
=
Seed
[
2
];
UDS_ISO14229_Transfer
[
4
]
=
Seed
[
3
];
if
(
AbleResponseType
==
Ser27BanResponse
)
{
if
(
bit_is_clear
(
UDS_ISO14229_Transfer
[
0
],
7
))
{
UDS_Service_Response
(
si
,
POSITIVE_RSP
,
DIAG_ID_Tx
,
5
,
UDS_ISO14229_Transfer
);
}
}
else
{
UDS_Service_Response
(
si
,
POSITIVE_RSP
,
DIAG_ID_Tx
,
5
,
UDS_ISO14229_Transfer
);
}
CalculateKey
();
}
else
if
(
NormalKeyUnlock
==
DiagLockFlag
)
{
UDS_ISO14229_Transfer
[
1
]
=
0
;
UDS_ISO14229_Transfer
[
2
]
=
0
;
UDS_ISO14229_Transfer
[
3
]
=
0
;
UDS_ISO14229_Transfer
[
4
]
=
0
;
if
(
AbleResponseType
==
Ser27BanResponse
)
{
if
(
bit_is_clear
(
UDS_ISO14229_Transfer
[
0
],
7
))
{
UDS_Service_Response
(
si
,
POSITIVE_RSP
,
DIAG_ID_Tx
,
5
,
UDS_ISO14229_Transfer
);
}
}
else
{
UDS_Service_Response
(
si
,
POSITIVE_RSP
,
DIAG_ID_Tx
,
5
,
UDS_ISO14229_Transfer
);
}
}
}
else
if
(
sendKey_LV1
==
SubFunction
)
{
Services27_01_Requested
=
0
;
Ser27_FlowCtrlCnt
.
RequestSeedCnt
=
0
;
Ser27_FlowCtrlCnt
.
Attemptcnt
=
0
;
DiagLockFlag
=
NormalKeyUnlock
;
if
(
AbleResponseType
==
Ser27BanResponse
)
{
if
(
bit_is_clear
(
UDS_ISO14229_Transfer
[
0
],
7
))
{
UDS_Service_Response
(
si
,
POSITIVE_RSP
,
DIAG_ID_Tx
,
1
,
UDS_ISO14229_Transfer
);
}
}
else
{
UDS_Service_Response
(
si
,
POSITIVE_RSP
,
DIAG_ID_Tx
,
1
,
UDS_ISO14229_Transfer
);
}
// WriteDFlashData(0x02u, (uint32_t *)&Ser27_FlowCtrlCnt.Flag, sizeof(Ser27_FlowCtrlCnt) / 4u, NeedWait);
}
}
else
{
if
(
DIAG_ID_Rx_FUN
==
FunorPhy
)
{
if
((
NrcCode
!=
0x11
)
&&
(
NrcCode
!=
0x12
)
&&
(
NrcCode
!=
0x13
)
&&
(
NrcCode
!=
0x7E
)
&&
(
NrcCode
!=
0x7F
)
&&
(
NrcCode
!=
0x31
))
{
NegRes
.
code
=
NrcCode
;
UDS_Service_Response
(
si
,
NEGATIVE_RSP
,
DIAG_ID_Tx
,
1
,
(
uint8_t
*
)(
&
NegRes
.
code
));
return
;
}
}
else
{
NegRes
.
code
=
NrcCode
;
UDS_Service_Response
(
si
,
NEGATIVE_RSP
,
DIAG_ID_Tx
,
1
,
(
uint8_t
*
)(
&
NegRes
.
code
));
return
;
}
}
}
/******************************************************************************
28# - CommunicationControl
******************************************************************************/
static
const
uint8_t
Ser28BanResponse
=
AbleResponseType
;
static
const
uint8_t
Ser28Sub
[]
=
{
enableRxAndTx
,
/*enableRxAndDisableTx, disableRxAndEnableTx, */
disableRxAndTx
};
static
const
uint8_t
Ser28MinLen
[]
=
{
2
};
static
const
uint8_t
Ser28SubLen
[]
=
{
2
,
/*2, 2,*/
2
};
static
const
uint8_t
Ser28UnlockLevel
[]
=
{
NoNeed
,
NoNeed
,
NoNeed
,
NoNeed
};
static
const
uint8_t
Ser28SupportSession
=
ProgrammingMode
|
ExtendedDiagnosticMode
;
static
const
uint8_t
Ser28SubSupportSession
[]
=
{
ProgrammingMode
|
ExtendedDiagnosticMode
,
ProgrammingMode
|
ExtendedDiagnosticMode
,
ProgrammingMode
|
ExtendedDiagnosticMode
,
ProgrammingMode
|
ExtendedDiagnosticMode
};
void
UDS_Service_28_Indication
(
uint16_t
A_TA_type
,
uint16_t
A_Length
,
uint8_t
*
A_Data
)
{
uint8_t
i
;
uint8_t
si
=
CommunicationControl
;
uint8_t
NrcCode
=
0
;
uint8_t
Index
=
0
;
uint8_t
SubFunction
=
0
;
uint16_t
FunorPhy
=
A_TA_type
;
uint16_t
Service28DiagDataLength
=
A_Length
;
for
(
i
=
0
;
i
<
Service28DiagDataLength
;
++
i
)
{
UDS_ISO14229_Transfer
[
i
]
=
*
(
A_Data
+
i
);
}
if
(
0
==
NrcCode
)
{
NrcCode
=
SerXXNRC7FFilter
(
Ser28SupportSession
);
}
if
(
0
==
NrcCode
)
{
NrcCode
=
SerXXNRC13Filter
(
MinLengthType
,
Service28DiagDataLength
,
Ser28MinLen
,
Index
);
}
if
(
0
==
NrcCode
)
{
if
(
AbleResponseType
==
Ser28BanResponse
)
{
SubFunction
=
UDS_ISO14229_Transfer
[
0
]
&
0x7F
;
}
else
{
SubFunction
=
UDS_ISO14229_Transfer
[
0
];
}
NrcCode
=
SerXXNRC12Filter
(
SubFunction
,
Ser28Sub
,
sizeof
(
Ser28Sub
),
&
Index
);
}
if
(
0
==
NrcCode
&&
Index
<
sizeof
(
Ser28UnlockLevel
))
{
NrcCode
=
SerXXNRC33Filter
(
Ser28UnlockLevel
,
Index
);
}
if
(
0
==
NrcCode
&&
(
Index
<
sizeof
(
Ser28SubSupportSession
)))
{
NrcCode
=
SerXXNRC7EFilter
(
Ser28SubSupportSession
,
Index
);
}
if
(
0
==
NrcCode
&&
(
Index
<
sizeof
(
Ser28SubLen
)))
{
NrcCode
=
SerXXNRC13Filter
(
SubLengthType
,
Service28DiagDataLength
,
Ser28SubLen
,
Index
);
}
if
(
0
==
NrcCode
)
{
NrcCode
=
SerXXNRC22Filter
();
}
// if (0 == NrcCode)
// {
// if (normalCommunicationMessages != UDS_ISO14229_Transfer[1])
// {
// NrcCode = requestOutOfRange;
// }
// }
if
(
0
==
NrcCode
)
{
if
(
enableRxAndTx
==
SubFunction
)
{
if
(
UDS_ISO14229_Transfer
[
1
]
&
normalCommunicationMessages
)
{
CAN_RX_SetEnable
(
&
CAN_CH0_CanMsgOp
,
CAN_N_RX_Enable
);
CAN_TX_SetEnable
(
&
CAN_CH0_CanMsgTxOp
,
CAN_N_TX_Enable
);
}
if
(
UDS_ISO14229_Transfer
[
1
]
&
networkManagementCommunicationMessages
)
{
}
}
else
if
(
disableRxAndTx
==
SubFunction
)
{
if
(
UDS_ISO14229_Transfer
[
1
]
&
normalCommunicationMessages
)
{
CAN_RX_SetEnable
(
&
CAN_CH0_CanMsgOp
,
CAN_N_RX_Disable
);
CAN_TX_SetEnable
(
&
CAN_CH0_CanMsgTxOp
,
CAN_N_TX_Disable
);
}
if
(
UDS_ISO14229_Transfer
[
1
]
&
networkManagementCommunicationMessages
)
{
}
if
(
UDS_ISO14229_Transfer
[
1
]
&
networkManagementCommunicationMessagesnormalCommunicationMessages
)
{
}
}
if
(
AbleResponseType
==
Ser28BanResponse
)
{
if
(
bit_is_clear
(
UDS_ISO14229_Transfer
[
0
],
7
))
{
UDS_Service_Response
(
si
,
POSITIVE_RSP
,
DIAG_ID_Tx
,
1
,
UDS_ISO14229_Transfer
);
}
}
else
{
UDS_Service_Response
(
si
,
POSITIVE_RSP
,
DIAG_ID_Tx
,
1
,
UDS_ISO14229_Transfer
);
}
}
else
{
if
(
DIAG_ID_Rx_FUN
==
FunorPhy
)
{
if
((
NrcCode
!=
0x11
)
&&
(
NrcCode
!=
0x12
)
&&
(
NrcCode
!=
0x13
)
&&
(
NrcCode
!=
0x7E
)
&&
(
NrcCode
!=
0x7F
)
&&
(
NrcCode
!=
0x31
))
{
NegRes
.
code
=
NrcCode
;
UDS_Service_Response
(
si
,
NEGATIVE_RSP
,
DIAG_ID_Tx
,
1
,
(
uint8_t
*
)(
&
NegRes
.
code
));
return
;
}
}
else
{
NegRes
.
code
=
NrcCode
;
UDS_Service_Response
(
si
,
NEGATIVE_RSP
,
DIAG_ID_Tx
,
1
,
(
uint8_t
*
)(
&
NegRes
.
code
));
return
;
}
}
}
/******************************************************************************
/******************************************************************************
3E# - TesterPresent
3E# - TesterPresent
******************************************************************************/
******************************************************************************/
...
@@ -1335,7 +707,6 @@ static const uint8_t Ser3EBanResponse = AbleResponseType;
...
@@ -1335,7 +707,6 @@ static const uint8_t Ser3EBanResponse = AbleResponseType;
static
const
uint8_t
Ser3ESub
[]
=
{
0x00
};
static
const
uint8_t
Ser3ESub
[]
=
{
0x00
};
static
const
uint8_t
Ser3EMinLen
[]
=
{
1
};
static
const
uint8_t
Ser3EMinLen
[]
=
{
1
};
static
const
uint8_t
Ser3ESubLen
[]
=
{
1
};
static
const
uint8_t
Ser3ESubLen
[]
=
{
1
};
static
const
uint8_t
Ser3EUnlockLevel
[]
=
{
NoNeed
};
static
const
uint8_t
Ser3ESupportSession
=
DefaultMode
|
ProgrammingMode
|
ExtendedDiagnosticMode
;
static
const
uint8_t
Ser3ESupportSession
=
DefaultMode
|
ProgrammingMode
|
ExtendedDiagnosticMode
;
static
const
uint8_t
Ser3ESubSupportSession
[]
=
{
DefaultMode
|
ProgrammingMode
|
ExtendedDiagnosticMode
};
static
const
uint8_t
Ser3ESubSupportSession
[]
=
{
DefaultMode
|
ProgrammingMode
|
ExtendedDiagnosticMode
};
void
UDS_Service_3E_Indication
(
uint16_t
A_TA_type
,
uint16_t
A_Length
,
uint8_t
*
A_Data
)
void
UDS_Service_3E_Indication
(
uint16_t
A_TA_type
,
uint16_t
A_Length
,
uint8_t
*
A_Data
)
...
@@ -1376,11 +747,6 @@ void UDS_Service_3E_Indication(uint16_t A_TA_type, uint16_t A_Length, uint8_t *A
...
@@ -1376,11 +747,6 @@ void UDS_Service_3E_Indication(uint16_t A_TA_type, uint16_t A_Length, uint8_t *A
NrcCode
=
SerXXNRC12Filter
(
SubFunction
,
Ser3ESub
,
sizeof
(
Ser3ESub
),
&
Index
);
NrcCode
=
SerXXNRC12Filter
(
SubFunction
,
Ser3ESub
,
sizeof
(
Ser3ESub
),
&
Index
);
}
}
if
(
0
==
NrcCode
&&
Index
<
sizeof
(
Ser3EUnlockLevel
))
{
NrcCode
=
SerXXNRC33Filter
(
Ser3EUnlockLevel
,
Index
);
}
if
(
0
==
NrcCode
&&
(
Index
<
sizeof
(
Ser3ESubSupportSession
)))
if
(
0
==
NrcCode
&&
(
Index
<
sizeof
(
Ser3ESubSupportSession
)))
{
{
NrcCode
=
SerXXNRC7EFilter
(
Ser3ESubSupportSession
,
Index
);
NrcCode
=
SerXXNRC7EFilter
(
Ser3ESubSupportSession
,
Index
);
...
@@ -1434,131 +800,17 @@ void UDS_Service_3E_Indication(uint16_t A_TA_type, uint16_t A_Length, uint8_t *A
...
@@ -1434,131 +800,17 @@ void UDS_Service_3E_Indication(uint16_t A_TA_type, uint16_t A_Length, uint8_t *A
}
}
}
}
/******************************************************************************
85# - ControlDTCSetting
******************************************************************************/
static
const
uint8_t
Ser85BanResponse
=
AbleResponseType
;
static
const
uint8_t
Ser85Sub
[]
=
{
DTCSettingOn
,
DTCSettingOff
};
static
const
uint8_t
Ser85MinLen
[]
=
{
1
};
static
const
uint8_t
Ser85SubLen
[]
=
{
1
,
1
};
static
const
uint8_t
Ser85UnlockLevel
[]
=
{
NoNeed
,
NoNeed
};
static
const
uint8_t
Ser85SupportSession
=
ProgrammingMode
|
ExtendedDiagnosticMode
;
static
const
uint8_t
Ser85SubSupportSession
[]
=
{
ProgrammingMode
|
ExtendedDiagnosticMode
};
void
UDS_Service_85_Indication
(
uint16_t
A_TA_type
,
uint16_t
A_Length
,
uint8_t
*
A_Data
)
{
uint8_t
i
;
uint8_t
si
=
ControlDTCSetting
;
uint8_t
NrcCode
=
0
;
uint8_t
Index
=
0
;
uint8_t
SubFunction
=
0
;
uint16_t
Service85DiagDataLength
=
A_Length
;
uint16_t
FunorPhy
=
A_TA_type
;
for
(
i
=
0
;
i
<
Service85DiagDataLength
;
++
i
)
{
UDS_ISO14229_Transfer
[
i
]
=
*
(
A_Data
+
i
);
}
if
(
0
==
NrcCode
)
{
NrcCode
=
SerXXNRC7FFilter
(
Ser85SupportSession
);
}
if
(
0
==
NrcCode
)
{
NrcCode
=
SerXXNRC13Filter
(
MinLengthType
,
Service85DiagDataLength
,
Ser85MinLen
,
Index
);
}
if
(
0
==
NrcCode
)
{
if
(
AbleResponseType
==
Ser85BanResponse
)
{
SubFunction
=
UDS_ISO14229_Transfer
[
0
]
&
0x7F
;
}
else
{
SubFunction
=
UDS_ISO14229_Transfer
[
0
];
}
NrcCode
=
SerXXNRC12Filter
(
SubFunction
,
Ser85Sub
,
sizeof
(
Ser85Sub
),
&
Index
);
}
if
(
0
==
NrcCode
&&
Index
<
sizeof
(
Ser85UnlockLevel
))
{
NrcCode
=
SerXXNRC33Filter
(
Ser85UnlockLevel
,
Index
);
}
if
(
0
==
NrcCode
&&
(
Index
<
sizeof
(
Ser85SubSupportSession
)))
{
NrcCode
=
SerXXNRC7EFilter
(
Ser85SubSupportSession
,
Index
);
}
if
(
0
==
NrcCode
&&
(
Index
<
sizeof
(
Ser85SubLen
)))
{
NrcCode
=
SerXXNRC13Filter
(
SubLengthType
,
Service85DiagDataLength
,
Ser85SubLen
,
Index
);
}
if
(
0
==
NrcCode
)
{
NrcCode
=
SerXXNRC22Filter
();
}
if
(
0
==
NrcCode
)
{
if
(
DTCSettingOn
==
SubFunction
)
{
// CAN_DTC_OFF = 0;
}
else
if
(
DTCSettingOff
==
SubFunction
)
{
// CAN_DTC_OFF = 1;
}
if
(
AbleResponseType
==
Ser85BanResponse
)
{
if
(
bit_is_clear
(
UDS_ISO14229_Transfer
[
0
],
7
))
{
UDS_Service_Response
(
si
,
POSITIVE_RSP
,
DIAG_ID_Tx
,
1
,
UDS_ISO14229_Transfer
);
}
}
else
{
UDS_Service_Response
(
si
,
POSITIVE_RSP
,
DIAG_ID_Tx
,
1
,
UDS_ISO14229_Transfer
);
}
}
else
{
if
(
DIAG_ID_Rx_FUN
==
FunorPhy
)
{
if
((
NrcCode
!=
0x11
)
&&
(
NrcCode
!=
0x12
)
&&
(
NrcCode
!=
0x13
)
&&
(
NrcCode
!=
0x7E
)
&&
(
NrcCode
!=
0x7F
)
&&
(
NrcCode
!=
0x31
))
{
NegRes
.
code
=
NrcCode
;
UDS_Service_Response
(
si
,
NEGATIVE_RSP
,
DIAG_ID_Tx
,
1
,
(
uint8_t
*
)(
&
NegRes
.
code
));
return
;
}
}
else
{
NegRes
.
code
=
NrcCode
;
UDS_Service_Response
(
si
,
NEGATIVE_RSP
,
DIAG_ID_Tx
,
1
,
(
uint8_t
*
)(
&
NegRes
.
code
));
return
;
}
}
}
/*************IGN on,S3 Timeout****************/
/*************IGN on,S3 Timeout****************/
void
DIAG_InitParameter
(
void
)
void
DIAG_InitParameter
(
void
)
{
{
S3_ServerCnt
=
0
;
S3_ServerCnt
=
0
;
S3_ServerEN
=
0
;
S3_ServerEN
=
0
;
SessionType
=
DefaultSession
;
SessionType
=
DefaultSession
;
DiagLockFlag
=
0
;
RANDOM
=
1573
;
Services27_01_Requested
=
0
;
}
}
void
Get_Into_630H_Update_MCU_Mode
(
void
)
void
Get_Into_630H_Update_MCU_Mode
(
void
)
{
{
uint8_t
i
;
Write_App_InValid
(
Flag_App_OTAStatus
);
Write_App_InValid
(
Flag_App_OTAStatus
);
for
(
i
=
0
;
i
<
250
;
++
i
)
for
(
i
=
0
;
i
<
250
;
++
i
)
{
{
...
...
Firmware/Source/UDS/UDS_ISO14229_Services.h
View file @
f958e54b
...
@@ -41,10 +41,11 @@
...
@@ -41,10 +41,11 @@
*/
*/
#define NoNeedWait 0x00u
#define NoNeedWait 0x00u
#define NeedWait 0x01u
#define NeedWait 0x01u
#define APP_STATUS_ADDR (0x501000)
#define FLASH_APP_STATUS_INFO (0x00501000UL)
/* APP 程序有效性标识地址 */
#define APP_DATA_INFO (0x501400)
#define FLASH_SECOND_BOOT_INFO (0x00501400UL)
/* 二级Boot程序状态地址 */
#define APP_DATA_WRITE (0x501800)
#define FLASH_630H_UPDATE_INFO (0x00501800UL)
/* 630H升级信息 */
#define FLASH_APP_RODATA_INFO (0x00501C00UL)
/* 存储只读DID信息 */
#define FLASH_APP_RWDATA_INFO (0x00502000UL)
/* 存储可写的DID信息 */
#define Data_Flash_Addr_BootValid_OFFSET 0x00000000
#define Data_Flash_Addr_BootValid_OFFSET 0x00000000
#define Data_Flash_Addr_DiagReceive_OFFSET 0x00002000
#define Data_Flash_Addr_DiagReceive_OFFSET 0x00002000
...
@@ -323,35 +324,6 @@
...
@@ -323,35 +324,6 @@
#define CheckSumErr 7 // Checksum Error
#define CheckSumErr 7 // Checksum Error
#define UnknownPartID 8 // Unknown Part ID
#define UnknownPartID 8 // Unknown Part ID
typedef
struct
{
uint32_t
Flag
;
uint8_t
Attemptcnt
;
uint8_t
RequestSeedCnt
;
uint8_t
AttemptIIcnt
;
uint8_t
RequestSeedIICnt
;
}
Ser27_FlowCtrlCntUnion
;
typedef
struct
{
uint32_t
Flag
;
uint8_t
DID_F180
[
6
];
uint8_t
DID_F187
[
16
];
uint8_t
DID_F193
[
6
];
uint8_t
DID_F195
[
6
];
uint8_t
Filldata
[
2
];
}
DiagDFlashData
;
extern
DiagDFlashData
DiagDataForDFlash
;
typedef
struct
{
uint32_t
Flag
;
uint8_t
DID_F184
[
32
];
}
Ser2EDFlashData
;
extern
Ser2EDFlashData
Ser2EDataForDFlash
;
typedef
struct
typedef
struct
{
{
uint32_t
Flag
;
uint32_t
Flag
;
...
@@ -369,19 +341,10 @@ typedef struct
...
@@ -369,19 +341,10 @@ typedef struct
void
UDS_Service_10_Indication
(
uint16_t
A_TA_type
,
uint16_t
A_Length
,
uint8_t
*
A_Data
);
void
UDS_Service_10_Indication
(
uint16_t
A_TA_type
,
uint16_t
A_Length
,
uint8_t
*
A_Data
);
void
UDS_Service_11_Indication
(
uint16_t
A_TA_type
,
uint16_t
A_Length
,
uint8_t
*
A_Data
);
void
UDS_Service_11_Indication
(
uint16_t
A_TA_type
,
uint16_t
A_Length
,
uint8_t
*
A_Data
);
void
UDS_Service_22_Indication
(
uint16_t
A_TA_type
,
uint16_t
A_Length
,
uint8_t
*
A_Data
);
void
UDS_Service_22_Indication
(
uint16_t
A_TA_type
,
uint16_t
A_Length
,
uint8_t
*
A_Data
);
void
UDS_Service_2E_Indication
(
uint16_t
A_TA_type
,
uint16_t
A_Length
,
uint8_t
*
A_Data
);
void
UDS_Service_27_Indication
(
uint16_t
A_TA_type
,
uint16_t
A_Length
,
uint8_t
*
A_Data
);
void
UDS_Service_28_Indication
(
uint16_t
A_TA_type
,
uint16_t
A_Length
,
uint8_t
*
A_Data
);
void
UDS_Service_3E_Indication
(
uint16_t
A_TA_type
,
uint16_t
A_Length
,
uint8_t
*
A_Data
);
void
UDS_Service_3E_Indication
(
uint16_t
A_TA_type
,
uint16_t
A_Length
,
uint8_t
*
A_Data
);
void
UDS_Service_85_Indication
(
uint16_t
A_TA_type
,
uint16_t
A_Length
,
uint8_t
*
A_Data
);
void
S3_ServerCNTT
(
void
);
void
S3_ServerCNTT
(
void
);
void
Randomcnt
(
void
);
extern
void
DIAG_InitParameter
(
void
);
extern
void
DIAG_InitParameter
(
void
);
void
GetSeed
(
void
);
void
CalculateKey
(
void
);
void
CalculateKeyLv11
(
void
);
typedef
void
(
*
InitFunction
)(
void
);
typedef
void
(
*
InitFunction
)(
void
);
/***********Local Functin*************/
/***********Local Functin*************/
...
@@ -390,15 +353,11 @@ uint8_t SerXXNRC12Filter(uint8_t insub, const uint8_t *supportsub, uint8_t size,
...
@@ -390,15 +353,11 @@ uint8_t SerXXNRC12Filter(uint8_t insub, const uint8_t *supportsub, uint8_t size,
uint8_t
SerXXNRC13Filter
(
uint8_t
type
,
uint8_t
serlength
,
const
uint8_t
*
length
,
uint8_t
index
);
uint8_t
SerXXNRC13Filter
(
uint8_t
type
,
uint8_t
serlength
,
const
uint8_t
*
length
,
uint8_t
index
);
uint8_t
SerXXNRC22Filter
(
void
);
uint8_t
SerXXNRC22Filter
(
void
);
uint8_t
SerXXNRC31DIDFilter
(
uint16_t
inDID
,
const
uint16_t
*
DIDList
,
uint8_t
size
,
uint8_t
*
index
);
uint8_t
SerXXNRC31DIDFilter
(
uint16_t
inDID
,
const
uint16_t
*
DIDList
,
uint8_t
size
,
uint8_t
*
index
);
uint8_t
SerXXNRC33Filter
(
const
uint8_t
*
levelList
,
uint8_t
index
);
uint8_t
SerXXNRC7EFilter
(
const
uint8_t
*
SubSupportSession
,
uint8_t
index
);
uint8_t
SerXXNRC7EFilter
(
const
uint8_t
*
SubSupportSession
,
uint8_t
index
);
uint8_t
SerXXNRC7FFilter
(
uint8_t
SupportSession
);
uint8_t
SerXXNRC7FFilter
(
uint8_t
SupportSession
);
extern
void
Data_Set_DiagPara
(
void
);
void
Write_App_InValid
(
uint32_t
m32
);
void
Write_App_InValid
(
uint32_t
m32
);
void
Data_Read_DiagPara
(
void
);
void
DFlash_init
(
void
);
void
Data_Read_DiagPara
(
void
);
extern
void
Get_Into_630H_Update_MCU_Mode
(
void
);
extern
void
Get_Into_630H_Update_MCU_Mode
(
void
);
extern
void
Check_MCU_Info_in_630H
(
void
);
#endif
#endif
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment