Skip to content

Commit de44210

Browse files
committed
add updated iso14229.c/h files
1 parent 0ce6ecb commit de44210

File tree

2 files changed

+34
-2
lines changed

2 files changed

+34
-2
lines changed

iso14229.c

Lines changed: 24 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -984,6 +984,29 @@ static UDSErr_t Handle_0x11_ECUReset(UDSServer_t *srv, UDSReq_t *r) {
984984
return UDS_PositiveResponse;
985985
}
986986

987+
static UDSErr_t Handle_0x14_ClearDiagnosticInformation(UDSServer_t *srv, UDSReq_t *r) {
988+
if (r->recv_len < UDS_0X14_REQ_MIN_LEN) {
989+
return NegativeResponse(r, UDS_NRC_IncorrectMessageLengthOrInvalidFormat);
990+
}
991+
992+
r->send_buf[0] = UDS_RESPONSE_SID_OF(kSID_CLEAR_DIAGNOSTIC_INFORMATION);
993+
r->send_len = UDS_0X14_RESP_BASE_LEN;
994+
995+
UDSCDIArgs_t args = {
996+
.groupOfDTC = (uint32_t)((r->recv_buf[1] << 16) | (r->recv_buf[2] << 8) | r->recv_buf[3]),
997+
.hasMemorySelection = (r->recv_len >= 5),
998+
.memorySelection = (r->recv_len >= 5) ? r->recv_buf[4] : 0,
999+
};
1000+
1001+
UDSErr_t err = EmitEvent(srv, UDS_EVT_ClearDiagnosticInfo, &args);
1002+
1003+
if (err != UDS_PositiveResponse) {
1004+
return NegativeResponse(r, err);
1005+
}
1006+
1007+
return UDS_PositiveResponse;
1008+
}
1009+
9871010
static uint8_t safe_copy(UDSServer_t *srv, const void *src, uint16_t count) {
9881011
if (srv == NULL) {
9891012
return UDS_NRC_GeneralReject;
@@ -1724,7 +1747,7 @@ static UDSService getServiceForSID(uint8_t sid) {
17241747
case kSID_ECU_RESET:
17251748
return Handle_0x11_ECUReset;
17261749
case kSID_CLEAR_DIAGNOSTIC_INFORMATION:
1727-
return NULL;
1750+
return Handle_0x14_ClearDiagnosticInformation;
17281751
case kSID_READ_DTC_INFORMATION:
17291752
return NULL;
17301753
case kSID_READ_DATA_BY_IDENTIFIER:

iso14229.h

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -301,6 +301,7 @@ typedef enum UDSEvent {
301301
// Server Event ----------------- Argument Type
302302
UDS_EVT_DiagSessCtrl, // UDSDiagSessCtrlArgs_t *
303303
UDS_EVT_EcuReset, // UDSECUResetArgs_t *
304+
UDS_EVT_ClearDiagnosticInfo, // UDSCDIArgs_t *
304305
UDS_EVT_ReadDataByIdent, // UDSRDBIArgs_t *
305306
UDS_EVT_ReadMemByAddr, // UDSReadMemByAddrArgs_t *
306307
UDS_EVT_CommCtrl, // UDSCommCtrlArgs_t *
@@ -487,13 +488,15 @@ typedef enum {
487488
#define UDS_MAX_DIAGNOSTIC_SERVICES 0x7F
488489

489490
#define UDS_RESPONSE_SID_OF(request_sid) ((request_sid) + 0x40)
490-
#define UDS_REQUEST_SID_OF(response_sid) ((response_sid)-0x40)
491+
#define UDS_REQUEST_SID_OF(response_sid) ((response_sid) - 0x40)
491492

492493
#define UDS_NEG_RESP_LEN 3U
493494
#define UDS_0X10_REQ_LEN 2U
494495
#define UDS_0X10_RESP_LEN 6U
495496
#define UDS_0X11_REQ_MIN_LEN 2U
496497
#define UDS_0X11_RESP_BASE_LEN 2U
498+
#define UDS_0X14_REQ_MIN_LEN 4U
499+
#define UDS_0X14_RESP_BASE_LEN 1U
497500
#define UDS_0X23_REQ_MIN_LEN 4U
498501
#define UDS_0X23_RESP_BASE_LEN 1U
499502
#define UDS_0X22_RESP_BASE_LEN 1U
@@ -882,6 +885,12 @@ typedef struct {
882885
a UDS_EVT_DoScheduledReset will be issued */
883886
} UDSECUResetArgs_t;
884887

888+
typedef struct {
889+
const uint32_t groupOfDTC; /*! lower 3 bytes describe the groupOfDTC */
890+
const bool hasMemorySelection; /*! `true` when a memory selection byte is present */
891+
const uint8_t memorySelection; /*! memorySelection byte (optional) */
892+
} UDSCDIArgs_t;
893+
885894
typedef struct {
886895
const uint16_t dataId; /*! RDBI Data Identifier */
887896
uint8_t (*copy)(UDSServer_t *srv, const void *src,

0 commit comments

Comments
 (0)