1 /* -------------------------------- Arctic Core ------------------------------
\r
2 * Arctic Core - the open source AUTOSAR platform http://arccore.com
\r
4 * Copyright (C) 2009 ArcCore AB <contact@arccore.com>
\r
6 * This source code is free software; you can redistribute it and/or modify it
\r
7 * under the terms of the GNU General Public License version 2 as published by the
\r
8 * Free Software Foundation; See <http://www.gnu.org/licenses/old-licenses/gpl-2.0.txt>.
\r
10 * This program is distributed in the hope that it will be useful, but
\r
11 * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
\r
12 * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
\r
14 * -------------------------------- Arctic Core ------------------------------*/
\r
16 //lint -esym(754, SID) //Structure member SID not used in udsReadDtcInfoSub_0x01_0x07_0x11_0x12() and udsReadDtcInfoSub_0x02_0x0A_0x0F_0x13_0x15()
\r
20 * General requirements
\r
22 /** @req DCM273 */ /** @req DCM272 */
\r
23 /** @req DCM039 */ /** @req DCM038 */ /** @req DCM269 */
\r
24 /** @req DCM271 */ /** @req DCM274 */ /** @req DCM275 */ /** @req DCM424 */
\r
28 #include "Dcm_Internal.h"
\r
31 #if defined(USE_MCU)
\r
38 #define ZERO_SUB_FUNCTION 0x00
\r
39 #define DCM_FORMAT_LOW_MASK 0x0F
\r
40 #define DCM_FORMAT_HIGH_MASK 0xF0
\r
41 #define DCM_MEMORY_ADDRESS_MASK 0xFFFFFF
\r
42 #define DCM_DID_HIGH_MASK 0xFF00
\r
43 #define DCM_DID_LOW_MASK 0xFF
\r
44 #define DCM_PERODICDID_HIHG_MASK 0xF200
\r
45 #define SID_AND_ALFID_LEN2 0x2
\r
46 #define SID_AND_ALFID_LEN4 0x4
\r
47 #define SID_AND_ALFID_LEN5 0x5
\r
48 #define SID_AND_ALFID_LEN6 0x6
\r
49 #define SID_AND_ALFID_LEN7 0x7
\r
51 #define BYTES_TO_DTC(hb, mb, lb) (((uint32)(hb) << 16) | ((uint32)(mb) << 8) | (uint32)(lb))
\r
52 #define DTC_HIGH_BYTE(dtc) (((uint32)(dtc) >> 16) & 0xFFu)
\r
53 #define DTC_MID_BYTE(dtc) (((uint32)(dtc) >> 8) & 0xFFu)
\r
54 #define DTC_LOW_BYTE(dtc) ((uint32)(dtc) & 0xFFu)
\r
58 boolean resetPending;
\r
59 PduIdType resetPduId;
\r
60 } DspUdsEcuResetDataType;
\r
62 static DspUdsEcuResetDataType dspUdsEcuResetData;
\r
63 static boolean dspWritePending;
\r
66 boolean reqInProgress;
\r
67 Dcm_SecLevelType reqSecLevel;
\r
68 const Dcm_DspSecurityRowType *reqSecLevelRef;
\r
69 } DspUdsSecurityAccessDataType;
\r
71 static DspUdsSecurityAccessDataType dspUdsSecurityAccesData;
\r
78 }Dcm_DspMemoryStateType;
\r
79 Dcm_DspMemoryStateType dspMemoryState;
\r
82 DCM_DDD_SOURCE_DEFAULT,
\r
84 DCM_DDD_SOURCE_ADDRESS
\r
88 uint32 PDidTxCounter;
\r
89 uint32 PDidTxCounterNumber;
\r
91 }Dcm_pDidType;/* a type to save the periodic DID and cycle */
\r
94 Dcm_pDidType dspPDid[DCM_LIMITNUMBER_PERIODDATA]; /*a buffer to save the periodic DID and cycle */
\r
95 uint8 PDidNr; /* note the number of periodic DID is used */
\r
98 Dsp_pDidRefType dspPDidRef;
\r
101 uint8 formatOrPosition; /*note the formate of address and size*/
\r
102 uint32 SourceAddressOrDid; /*note the memory address */
\r
103 uint16 Size; /*note the memory size */
\r
104 Dcm_DspDDDTpyeID DDDTpyeID;
\r
105 }Dcm_DspDDDSourceType;
\r
108 uint16 DynamicallyDid;
\r
109 Dcm_DspDDDSourceType DDDSource[DCM_MAX_DDDSOURCE_NUMBER];
\r
113 Dcm_DspDDDType dspDDD[DCM_MAX_DDD_NUMBER];
\r
117 * * static Function
\r
120 static boolean lookupReadMemory(uint32 memoryAddress,
\r
121 uint8 memoryAddressFormat,
\r
123 const Dcm_DspMemoryIdInfo **MemoryPtr);
\r
125 static boolean LookupDDD(uint16 didNr, const Dcm_DspDDDType **DDid);
\r
127 static boolean checkWriteMemoryByAddress(boolean useId,
\r
128 uint32 memoryAddress,
\r
129 uint8 memoryAddressFormat,
\r
131 const Dcm_DspMemoryIdInfo *dspMemory);
\r
140 dspUdsSecurityAccesData.reqInProgress = FALSE;
\r
141 dspUdsEcuResetData.resetPending = FALSE;
\r
143 dspWritePending = FALSE;
\r
144 dspMemoryState=DCM_MEMORY_UNUSED;
\r
145 /* clear periodic send buffer */
\r
146 memset(&dspPDidRef,0,sizeof(dspPDidRef));
\r
147 /* clear dynamically Did buffer */
\r
148 memset(&dspDDD[0],0,sizeof(dspDDD));
\r
151 void DspMemoryMainFunction(void)
\r
153 Dcm_ReturnWriteMemoryType WriteRet;
\r
154 Dcm_ReturnReadMemoryType ReadRet;
\r
155 switch(dspMemoryState)
\r
157 case DCM_MEMORY_UNUSED:
\r
159 case DCM_MEMORY_READ:
\r
160 ReadRet = Dcm_ReadMemory(DCM_PENDING,0,0,0,0);
\r
161 if(ReadRet == DCM_READ_OK)/*asynchronous writing is ok*/
\r
163 DsdDspProcessingDone(DCM_E_POSITIVERESPONSE);
\r
164 dspMemoryState = DCM_MEMORY_UNUSED;
\r
166 if(ReadRet == DCM_READ_FAILED)
\r
168 dspMemoryState = DCM_MEMORY_FAILED;
\r
171 case DCM_MEMORY_WRITE:
\r
172 WriteRet = Dcm_WriteMemory(DCM_PENDING,0,0,0,0);
\r
173 if(WriteRet == DCM_WRITE_OK)/*asynchronous writing is ok*/
\r
175 DsdDspProcessingDone(DCM_E_POSITIVERESPONSE);
\r
176 dspMemoryState = DCM_MEMORY_UNUSED;
\r
178 if(WriteRet == DCM_WRITE_FAILED)
\r
180 dspMemoryState = DCM_MEMORY_FAILED;
\r
183 case DCM_MEMORY_FAILED:
\r
184 DsdDspProcessingDone(DCM_E_GENERALPROGRAMMINGFAILURE);
\r
185 dspMemoryState = DCM_MEMORY_UNUSED;
\r
190 void DspPeriodicDIDMainFunction()
\r
193 boolean sentResponseThisLoop = FALSE;
\r
195 for(i = 0;i < dspPDidRef.PDidNr; i++)
\r
197 if(dspPDidRef.dspPDid[i].PDidTxCounterNumber > dspPDidRef.dspPDid[i].PDidTxCounter)
\r
199 dspPDidRef.dspPDid[i].PDidTxCounter++;
\r
203 if( sentResponseThisLoop == FALSE ) {
\r
204 dspPDidRef.dspPDid[i].PDidTxCounter = 0;
\r
205 /*AutoSar DCM 8.10.5 */
\r
206 DslInternal_ResponseOnOneDataByPeriodicId(dspPDidRef.dspPDid[i].PeriodicDid);
\r
207 sentResponseThisLoop = TRUE;
\r
210 /* Don't do anything - PDid will be sent next loop */
\r
217 DspMemoryMainFunction();
\r
218 DspPeriodicDIDMainFunction();
\r
222 boolean DspCheckSessionLevel(Dcm_DspSessionRowType const* const* sessionLevelRefTable)
\r
224 Std_ReturnType returnStatus;
\r
225 boolean levelFound = FALSE;
\r
226 Dcm_SesCtrlType currentSession;
\r
228 returnStatus = DslGetSesCtrlType(¤tSession);
\r
229 if (returnStatus == E_OK) {
\r
230 while ( ((*sessionLevelRefTable)->DspSessionLevel != currentSession) && (!(*sessionLevelRefTable)->Arc_EOL) ) {
\r
231 sessionLevelRefTable++;
\r
234 if (!(*sessionLevelRefTable)->Arc_EOL) {
\r
243 boolean DspCheckSecurityLevel(Dcm_DspSecurityRowType const* const* securityLevelRefTable)
\r
245 Std_ReturnType returnStatus;
\r
246 boolean levelFound = FALSE;
\r
247 Dcm_SecLevelType currentSecurityLevel;
\r
249 returnStatus = DslGetSecurityLevel(¤tSecurityLevel);
\r
250 if (returnStatus == E_OK) {
\r
251 while ( ((*securityLevelRefTable)->DspSecurityLevel != currentSecurityLevel) && (!(*securityLevelRefTable)->Arc_EOL) ) {
\r
252 securityLevelRefTable++;
\r
254 if (!(*securityLevelRefTable)->Arc_EOL) {
\r
263 static Std_ReturnType askApplicationForSessionPermission(Dcm_SesCtrlType newSessionLevel)
\r
265 Std_ReturnType returnCode = E_OK;
\r
266 const Dcm_DslSessionControlType *sesControl = DCM_Config.Dsl->DslSessionControl;
\r
267 Dcm_SesCtrlType currentSessionLevel;
\r
268 Std_ReturnType result;
\r
270 while ( (!sesControl->Arc_EOL) && (returnCode != E_SESSION_NOT_ALLOWED)) {
\r
271 if (sesControl->GetSesChgPermission != NULL) {
\r
272 result = Dcm_GetSesCtrlType(¤tSessionLevel);
\r
273 if (result == E_OK) {
\r
274 result = sesControl->GetSesChgPermission(currentSessionLevel ,newSessionLevel);
\r
275 if (result != E_OK) {
\r
276 returnCode = result;
\r
279 returnCode = E_NOT_OK;
\r
289 void DspUdsDiagnosticSessionControl(const PduInfoType *pduRxData, PduInfoType *pduTxData)
\r
292 const Dcm_DspSessionRowType *sessionRow = DCM_Config.Dsp->DspSession->DspSessionRow;
\r
293 Dcm_SesCtrlType reqSessionType;
\r
294 Std_ReturnType result;
\r
296 if (pduRxData->SduLength == 2) {
\r
297 reqSessionType = pduRxData->SduDataPtr[1];
\r
298 // Check if type exist in session table
\r
299 while ((sessionRow->DspSessionLevel != reqSessionType) && (!sessionRow->Arc_EOL) ) {
\r
303 if (!sessionRow->Arc_EOL) {
\r
304 result = askApplicationForSessionPermission(reqSessionType);
\r
305 if (result == E_OK) {
\r
306 DslSetSesCtrlType(reqSessionType); /** @req DCM311 */
\r
307 // Create positive response
\r
308 pduTxData->SduDataPtr[1] = reqSessionType;
\r
309 pduTxData->SduLength = 2;
\r
310 DsdDspProcessingDone(DCM_E_POSITIVERESPONSE);
\r
313 // TODO: Add handling of special case of E_FORCE_RCRRP (Dcm138)
\r
314 DsdDspProcessingDone(DCM_E_CONDITIONSNOTCORRECT); /** @req DCM308 */
\r
318 DsdDspProcessingDone(DCM_E_SUBFUNCTIONNOTSUPPORTED); /** @req DCM307 */
\r
323 DsdDspProcessingDone(DCM_E_INCORRECTMESSAGELENGTHORINVALIDFORMAT);
\r
328 void DspUdsEcuReset(const PduInfoType *pduRxData, PduIdType txPduId, PduInfoType *pduTxData)
\r
331 uint8 reqResetType;
\r
333 if (pduRxData->SduLength == 2) {
\r
334 reqResetType = pduRxData->SduDataPtr[1];
\r
336 switch (reqResetType)
\r
338 case 0x01: // Hard reset
\r
339 // TODO: Ask application for permission (Dcm373) (Dcm375) (Dcm377)
\r
341 // Schedule the reset
\r
342 dspUdsEcuResetData.resetPending = TRUE;
\r
343 dspUdsEcuResetData.resetPduId = txPduId;
\r
345 // Create positive response
\r
346 pduTxData->SduDataPtr[1] = reqResetType;
\r
347 pduTxData->SduLength = 2;
\r
348 DsdDspProcessingDone(DCM_E_POSITIVERESPONSE);
\r
352 DsdDspProcessingDone(DCM_E_SUBFUNCTIONNOTSUPPORTED);
\r
358 DsdDspProcessingDone(DCM_E_INCORRECTMESSAGELENGTHORINVALIDFORMAT);
\r
363 void DspUdsClearDiagnosticInformation(const PduInfoType *pduRxData, PduInfoType *pduTxData)
\r
367 Dem_ReturnClearDTCType result;
\r
369 if (pduRxData->SduLength == 4) {
\r
370 dtc = BYTES_TO_DTC(pduRxData->SduDataPtr[1], pduRxData->SduDataPtr[2], pduRxData->SduDataPtr[3]);
\r
372 result = Dem_ClearDTC(dtc, DEM_DTC_KIND_ALL_DTCS, DEM_DTC_ORIGIN_PRIMARY_MEMORY); /** @req DCM005 */
\r
377 // Create positive response
\r
378 pduTxData->SduLength = 1;
\r
379 DsdDspProcessingDone(DCM_E_POSITIVERESPONSE);
\r
383 DsdDspProcessingDone(DCM_E_REQUESTOUTOFRANGE);
\r
389 DsdDspProcessingDone(DCM_E_INCORRECTMESSAGELENGTHORINVALIDFORMAT);
\r
394 static Dcm_NegativeResponseCodeType udsReadDtcInfoSub_0x01_0x07_0x11_0x12(const PduInfoType *pduRxData, PduInfoType *pduTxData)
\r
399 uint8 dtcStatusAvailabilityMask;
\r
400 uint8 dtcFormatIdentifier;
\r
401 uint8 dtcCountHighByte;
\r
402 uint8 dtcCountLowByte;
\r
405 Dcm_NegativeResponseCodeType responseCode = DCM_E_POSITIVERESPONSE;
\r
406 Dem_ReturnSetDTCFilterType setDtcFilterResult;
\r
408 // Setup the DTC filter
\r
409 switch (pduRxData->SduDataPtr[1]) /** @req DCM293 */
\r
411 case 0x01: // reportNumberOfDTCByStatusMask
\r
412 setDtcFilterResult = Dem_SetDTCFilter(pduRxData->SduDataPtr[2], DEM_DTC_KIND_ALL_DTCS, DEM_DTC_ORIGIN_PRIMARY_MEMORY, DEM_FILTER_WITH_SEVERITY_NO, VALUE_IS_NOT_USED, DEM_FILTER_FOR_FDC_NO);
\r
415 case 0x07: // reportNumberOfDTCBySeverityMaskRecord
\r
416 setDtcFilterResult = Dem_SetDTCFilter(pduRxData->SduDataPtr[3], DEM_DTC_KIND_ALL_DTCS, DEM_DTC_ORIGIN_PRIMARY_MEMORY, DEM_FILTER_WITH_SEVERITY_YES, pduRxData->SduDataPtr[2], DEM_FILTER_FOR_FDC_NO);
\r
419 case 0x11: // reportNumberOfMirrorMemoryDTCByStatusMask
\r
420 setDtcFilterResult = Dem_SetDTCFilter(pduRxData->SduDataPtr[2], DEM_DTC_KIND_ALL_DTCS, DEM_DTC_ORIGIN_MIRROR_MEMORY, DEM_FILTER_WITH_SEVERITY_NO, VALUE_IS_NOT_USED, DEM_FILTER_FOR_FDC_NO);
\r
423 case 0x12: // reportNumberOfEmissionRelatedOBDDTCByStatusMask
\r
424 setDtcFilterResult = Dem_SetDTCFilter(pduRxData->SduDataPtr[2], DEM_DTC_KIND_EMISSION_REL_DTCS, DEM_DTC_ORIGIN_PRIMARY_MEMORY, DEM_FILTER_WITH_SEVERITY_NO, VALUE_IS_NOT_USED, DEM_FILTER_FOR_FDC_NO);
\r
428 setDtcFilterResult = DEM_WRONG_FILTER;
\r
432 if (setDtcFilterResult == DEM_FILTER_ACCEPTED) {
\r
433 Std_ReturnType result;
\r
434 Dem_ReturnGetNumberOfFilteredDTCType getNumerResult;
\r
435 uint16 numberOfFilteredDtc;
\r
436 uint8 dtcStatusMask;
\r
437 //lint --e(826) PC-Lint exception - Suspicious pointer conversion
\r
438 //lint --e(927) PC-Lint exception - Pointer to pointer cast
\r
439 TxDataType *txData = (TxDataType*)pduTxData->SduDataPtr;
\r
442 getNumerResult = Dem_GetNumberOfFilteredDtc(&numberOfFilteredDtc);
\r
443 if (getNumerResult == DEM_NUMBER_OK) {
\r
444 result = Dem_GetDTCStatusAvailabilityMask(&dtcStatusMask);
\r
445 if (result != E_OK) {
\r
449 // Create positive response (ISO 14229-1 table 251)
\r
450 txData->reportType = pduRxData->SduDataPtr[1]; // reportType
\r
451 txData->dtcStatusAvailabilityMask = dtcStatusMask; // DTCStatusAvailabilityMask
\r
452 txData->dtcFormatIdentifier = Dem_GetTranslationType(); // DTCFormatIdentifier
\r
453 txData->dtcCountHighByte = (numberOfFilteredDtc >> 8); // DTCCount high byte
\r
454 txData->dtcCountLowByte = (numberOfFilteredDtc & 0xFFu); // DTCCount low byte
\r
455 pduTxData->SduLength = 6;
\r
457 // TODO: What to do?
\r
458 responseCode = DCM_E_GENERALREJECT;
\r
462 responseCode = DCM_E_REQUESTOUTOFRANGE;
\r
465 return responseCode;
\r
469 static Dcm_NegativeResponseCodeType udsReadDtcInfoSub_0x02_0x0A_0x0F_0x13_0x15(const PduInfoType *pduRxData, PduInfoType *pduTxData)
\r
471 Dcm_NegativeResponseCodeType responseCode = DCM_E_POSITIVERESPONSE;
\r
472 Dem_ReturnSetDTCFilterType setDtcFilterResult;
\r
476 uint8 dtcMiddleByte;
\r
479 } dtcAndStatusRecordType;
\r
484 uint8 dtcStatusAvailabilityMask;
\r
485 dtcAndStatusRecordType dtcAndStatusRecord[];
\r
488 // Setup the DTC filter
\r
489 switch (pduRxData->SduDataPtr[1]) /** @req DCM378 */
\r
491 case 0x02: // reportDTCByStatusMask
\r
492 setDtcFilterResult = Dem_SetDTCFilter(pduRxData->SduDataPtr[2], DEM_DTC_KIND_ALL_DTCS, DEM_DTC_ORIGIN_PRIMARY_MEMORY, DEM_FILTER_WITH_SEVERITY_NO, VALUE_IS_NOT_USED, DEM_FILTER_FOR_FDC_NO);
\r
495 case 0x0A: // reportSupportedDTC
\r
496 setDtcFilterResult = Dem_SetDTCFilter(DEM_DTC_STATUS_MASK_ALL, DEM_DTC_KIND_ALL_DTCS, DEM_DTC_ORIGIN_PRIMARY_MEMORY, DEM_FILTER_WITH_SEVERITY_NO, VALUE_IS_NOT_USED, DEM_FILTER_FOR_FDC_NO);
\r
499 case 0x0F: // reportMirrorMemoryDTCByStatusMask
\r
500 setDtcFilterResult = Dem_SetDTCFilter(pduRxData->SduDataPtr[2], DEM_DTC_KIND_ALL_DTCS, DEM_DTC_ORIGIN_MIRROR_MEMORY, DEM_FILTER_WITH_SEVERITY_NO, VALUE_IS_NOT_USED, DEM_FILTER_FOR_FDC_NO);
\r
503 case 0x13: // reportEmissionRelatedOBDDTCByStatusMask
\r
504 setDtcFilterResult = Dem_SetDTCFilter(pduRxData->SduDataPtr[2], DEM_DTC_KIND_EMISSION_REL_DTCS, DEM_DTC_ORIGIN_PRIMARY_MEMORY, DEM_FILTER_WITH_SEVERITY_NO, VALUE_IS_NOT_USED, DEM_FILTER_FOR_FDC_NO);
\r
507 case 0x15: // reportDTCWithPermanentStatus
\r
508 setDtcFilterResult = Dem_SetDTCFilter(DEM_DTC_STATUS_MASK_ALL, DEM_DTC_KIND_ALL_DTCS, DEM_DTC_ORIGIN_PERMANENT_MEMORY, DEM_FILTER_WITH_SEVERITY_NO, VALUE_IS_NOT_USED, DEM_FILTER_FOR_FDC_NO);
\r
512 setDtcFilterResult = DEM_WRONG_FILTER;
\r
516 if (setDtcFilterResult == DEM_FILTER_ACCEPTED) {
\r
517 uint8 dtcStatusMask;
\r
518 //lint --e(826) PC-Lint exception - Suspicious pointer conversion
\r
519 //lint --e(927) PC-Lint exception - Pointer to pointer cast
\r
520 TxDataType *txData = (TxDataType*)pduTxData->SduDataPtr;
\r
521 Dem_ReturnGetNextFilteredDTCType getNextFilteredDtcResult;
\r
523 Dem_EventStatusExtendedType dtcStatus;
\r
524 uint16 nrOfDtcs = 0;
\r
525 Std_ReturnType result;
\r
528 result = Dem_GetDTCStatusAvailabilityMask(&dtcStatusMask);
\r
529 if (result != E_OK) {
\r
533 // Create positive response (ISO 14229-1 table 252)
\r
534 txData->reportType = pduRxData->SduDataPtr[1];
\r
535 txData->dtcStatusAvailabilityMask = dtcStatusMask;
\r
537 if (dtcStatusMask != 0x00) { /** @req DCM008 */
\r
538 getNextFilteredDtcResult = Dem_GetNextFilteredDTC(&dtc, &dtcStatus);
\r
539 while (getNextFilteredDtcResult == DEM_FILTERED_OK) {
\r
540 txData->dtcAndStatusRecord[nrOfDtcs].dtcHighByte = DTC_HIGH_BYTE(dtc);
\r
541 txData->dtcAndStatusRecord[nrOfDtcs].dtcMiddleByte = DTC_MID_BYTE(dtc);
\r
542 txData->dtcAndStatusRecord[nrOfDtcs].dtcLowByte = DTC_LOW_BYTE(dtc);
\r
543 txData->dtcAndStatusRecord[nrOfDtcs].statusOfDtc = dtcStatus;
\r
545 getNextFilteredDtcResult = Dem_GetNextFilteredDTC(&dtc, &dtcStatus);
\r
548 if (getNextFilteredDtcResult != DEM_FILTERED_NO_MATCHING_DTC) {
\r
549 responseCode = DCM_E_REQUESTOUTOFRANGE;
\r
552 pduTxData->SduLength = (PduLengthType)(3 + (nrOfDtcs * sizeof(dtcAndStatusRecordType)));
\r
555 responseCode = DCM_E_REQUESTOUTOFRANGE;
\r
558 return responseCode;
\r
561 // PC-Lint (715 etc): Remove errors until function is filled.
\r
562 //lint -e{715, 838, 818} Symbol not referenced, responseCode not used, txData should be const
\r
563 static Dcm_NegativeResponseCodeType udsReadDtcInfoSub_0x08(const PduInfoType *pduRxData, PduInfoType *pduTxData)
\r
565 Dcm_NegativeResponseCodeType responseCode = DCM_E_POSITIVERESPONSE;
\r
567 // TODO: Not supported yet, (DEM module does not currently support severity).
\r
568 responseCode = DCM_E_REQUESTOUTOFRANGE;
\r
570 return responseCode;
\r
574 // PC-Lint (715 etc): Remove errors until function is filled.
\r
575 //lint -e{715, 838, 818} Symbol not referenced, responseCode not used, txData should be const
\r
576 static Dcm_NegativeResponseCodeType udsReadDtcInfoSub_0x09(const PduInfoType *pduRxData, PduInfoType *pduTxData)
\r
578 Dcm_NegativeResponseCodeType responseCode = DCM_E_POSITIVERESPONSE;
\r
580 // TODO: Not supported yet, (DEM module does not currently support severity).
\r
581 responseCode = DCM_E_REQUESTOUTOFRANGE;
\r
583 return responseCode;
\r
587 static Dcm_NegativeResponseCodeType udsReadDtcInfoSub_0x06_0x10(const PduInfoType *pduRxData, PduInfoType *pduTxData)
\r
589 Dcm_NegativeResponseCodeType responseCode = DCM_E_POSITIVERESPONSE;
\r
590 Dem_DTCOriginType dtcOrigin;
\r
594 // Switch on sub function
\r
595 switch (pduRxData->SduDataPtr[1]) /** @req DCM378 */
\r
597 case 0x06: // reportDTCExtendedDataRecordByDTCNumber
\r
598 dtcOrigin = DEM_DTC_ORIGIN_PRIMARY_MEMORY;
\r
601 case 0x10: // reportMirrorMemoryDTCExtendedDataRecordByDTCNumber
\r
602 dtcOrigin = DEM_DTC_ORIGIN_MIRROR_MEMORY;
\r
606 responseCode = DCM_E_SUBFUNCTIONNOTSUPPORTED;
\r
611 // Switch on record number
\r
612 switch (pduRxData->SduDataPtr[5])
\r
614 case 0xFF: // Report all Extended Data Records for a particular DTC
\r
615 startRecNum = 0x00;
\r
619 case 0xFE: // Report all OBD Extended Data Records for a particular DTC
\r
620 startRecNum = 0x90;
\r
624 default: // Report one specific Extended Data Records for a particular DTC
\r
625 startRecNum = pduRxData->SduDataPtr[5];
\r
626 endRecNum = startRecNum;
\r
630 if (responseCode == DCM_E_POSITIVERESPONSE) {
\r
631 Dem_ReturnGetStatusOfDTCType getStatusOfDtcResult;
\r
633 Dem_EventStatusExtendedType statusOfDtc;
\r
635 dtc = BYTES_TO_DTC(pduRxData->SduDataPtr[2], pduRxData->SduDataPtr[3], pduRxData->SduDataPtr[4]);
\r
636 getStatusOfDtcResult = Dem_GetStatusOfDTC(dtc, DEM_DTC_KIND_ALL_DTCS, dtcOrigin, &statusOfDtc); /** @req DCM295 */ /** @req DCM475 */
\r
637 if (getStatusOfDtcResult == DEM_STATUS_OK) {
\r
638 Dem_ReturnGetExtendedDataRecordByDTCType getExtendedDataRecordByDtcResult;
\r
641 uint16 txIndex = 6;
\r
643 /** @req DCM297 */ /** @req DCM474 */ /** @req DCM386 */
\r
644 pduTxData->SduDataPtr[1] = pduRxData->SduDataPtr[1]; // Sub function
\r
645 pduTxData->SduDataPtr[2] = DTC_HIGH_BYTE(dtc); // DTC high byte
\r
646 pduTxData->SduDataPtr[3] = DTC_MID_BYTE(dtc); // DTC mid byte
\r
647 pduTxData->SduDataPtr[4] = DTC_LOW_BYTE(dtc); // DTC low byte
\r
648 pduTxData->SduDataPtr[5] = statusOfDtc; // DTC status
\r
649 for (recNum = startRecNum; recNum <= endRecNum; recNum++) {
\r
650 recLength = pduTxData->SduLength - (txIndex + 1); // Calculate what's left in buffer
\r
651 /** @req DCM296 */ /** @req DCM476 */ /** @req DCM382 */
\r
652 getExtendedDataRecordByDtcResult = Dem_GetExtendedDataRecordByDTC(dtc, DEM_DTC_KIND_ALL_DTCS, dtcOrigin, recNum, &pduTxData->SduDataPtr[txIndex+1], &recLength);
\r
653 if (getExtendedDataRecordByDtcResult == DEM_RECORD_OK) {
\r
654 pduTxData->SduDataPtr[txIndex++] = recNum;
\r
655 /* Instead of calling Dem_GetSizeOfExtendedDataRecordByDTC() the result from Dem_GetExtendedDataRecordByDTC() is used */
\r
656 /** @req DCM478 */ /** @req DCM479 */ /** @req DCM480 */
\r
657 txIndex += recLength;
\r
660 // TODO: What to do here?
\r
663 pduTxData->SduLength = txIndex;
\r
666 responseCode = DCM_E_REQUESTOUTOFRANGE;
\r
670 return responseCode;
\r
674 // PC-Lint (715 etc): Remove errors until function is filled.
\r
675 //lint -e{715, 838, 818} Symbol not referenced, responseCode not used, txData should be const
\r
676 static Dcm_NegativeResponseCodeType udsReadDtcInfoSub_0x03(const PduInfoType *pduRxData, PduInfoType *pduTxData)
\r
678 Dcm_NegativeResponseCodeType responseCode = DCM_E_POSITIVERESPONSE;
\r
680 // TODO: Not supported yet
\r
681 responseCode = DCM_E_REQUESTOUTOFRANGE;
\r
683 return responseCode;
\r
687 // PC-Lint (715 etc): Remove errors until function is filled.
\r
688 //lint -e{715, 838, 818} Symbol not referenced, responseCode not used, txData should be const
\r
689 static Dcm_NegativeResponseCodeType udsReadDtcInfoSub_0x04(const PduInfoType *pduRxData, PduInfoType *pduTxData)
\r
691 Dcm_NegativeResponseCodeType responseCode = DCM_E_POSITIVERESPONSE;
\r
693 // TODO: Not supported yet
\r
694 responseCode = DCM_E_REQUESTOUTOFRANGE;
\r
696 return responseCode;
\r
700 // PC-Lint (715 etc): Remove errors until function is filled.
\r
701 //lint -e{715, 838, 818} Symbol not referenced, responseCode not used, txData should be const
\r
702 static Dcm_NegativeResponseCodeType udsReadDtcInfoSub_0x05(const PduInfoType *pduRxData, PduInfoType *pduTxData)
\r
704 Dcm_NegativeResponseCodeType responseCode = DCM_E_POSITIVERESPONSE;
\r
706 // TODO: Not supported yet
\r
707 responseCode = DCM_E_REQUESTOUTOFRANGE;
\r
709 return responseCode;
\r
713 // PC-Lint (715 etc): Remove errors until function is filled.
\r
714 //lint -e{715, 838, 818} Symbol not referenced, responseCode not used, txData should be const
\r
715 static Dcm_NegativeResponseCodeType udsReadDtcInfoSub_0x0B_0x0C_0x0D_0x0E(const PduInfoType *pduRxData, PduInfoType *pduTxData)
\r
717 Dcm_NegativeResponseCodeType responseCode = DCM_E_POSITIVERESPONSE;
\r
719 // TODO: Not supported yet
\r
720 responseCode = DCM_E_REQUESTOUTOFRANGE;
\r
722 return responseCode;
\r
726 // PC-Lint (715 etc): Remove errors until function is filled.
\r
727 //lint -e{715, 838, 818} Symbol not referenced, responseCode not used, txData should be const
\r
728 static Dcm_NegativeResponseCodeType udsReadDtcInfoSub_0x14(const PduInfoType *pduRxData, PduInfoType *pduTxData)
\r
730 Dcm_NegativeResponseCodeType responseCode = DCM_E_POSITIVERESPONSE;
\r
732 // TODO: Not supported yet
\r
733 responseCode = DCM_E_REQUESTOUTOFRANGE;
\r
735 return responseCode;
\r
739 void DspUdsReadDtcInformation(const PduInfoType *pduRxData, PduInfoType *pduTxData)
\r
742 // Sub function number 0 1 2 3 4 5 6 7 8 9 A B C D E F 10 11 12 13 14 15
\r
743 const uint8 sduLength[0x16] = {0, 3, 3, 6, 6, 3, 6, 4, 4, 5, 2, 2, 2, 2, 2, 3, 6, 3, 3, 3, 2, 2};
\r
745 Dcm_NegativeResponseCodeType responseCode = DCM_E_POSITIVERESPONSE;
\r
747 uint8 subFunctionNumber = pduRxData->SduDataPtr[1];
\r
750 if (subFunctionNumber <= 0x15) {
\r
751 if (pduRxData->SduLength == sduLength[subFunctionNumber]) {
\r
752 switch (subFunctionNumber)
\r
754 case 0x01: // reportNumberOfDTCByStatusMask
\r
755 case 0x07: // reportNumberOfDTCBySeverityMaskRecord
\r
756 case 0x11: // reportNumberOfMirrorMemoryDTCByStatusMask
\r
757 case 0x12: // reportNumberOfEmissionRelatedOBDDTCByStatusMask
\r
758 responseCode = udsReadDtcInfoSub_0x01_0x07_0x11_0x12(pduRxData, pduTxData);
\r
761 case 0x02: // reportDTCByStatusMask
\r
762 case 0x0A: // reportSupportedDTC
\r
763 case 0x0F: // reportMirrorMemoryDTCByStatusMask
\r
764 case 0x13: // reportEmissionRelatedOBDDTCByStatusMask
\r
765 case 0x15: // reportDTCWithPermanentStatus
\r
766 responseCode = udsReadDtcInfoSub_0x02_0x0A_0x0F_0x13_0x15(pduRxData, pduTxData);
\r
769 case 0x08: // reportDTCBySeverityMaskRecord
\r
770 responseCode = udsReadDtcInfoSub_0x08(pduRxData, pduTxData);
\r
773 case 0x09: // reportSeverityInformationOfDTC
\r
774 responseCode = udsReadDtcInfoSub_0x09(pduRxData, pduTxData);
\r
777 case 0x06: // reportDTCExtendedDataRecordByDTCNumber
\r
778 case 0x10: // reportMirrorMemoryDTCExtendedDataRecordByDTCNumber
\r
779 responseCode = udsReadDtcInfoSub_0x06_0x10(pduRxData, pduTxData);
\r
782 case 0x03: // reportDTCSnapshotIdentidication
\r
783 responseCode = udsReadDtcInfoSub_0x03(pduRxData, pduTxData);
\r
786 case 0x04: // reportDTCSnapshotByDtcNumber
\r
787 responseCode = udsReadDtcInfoSub_0x04(pduRxData, pduTxData);
\r
790 case 0x05: // reportDTCSnapshotRecordNumber
\r
791 responseCode = udsReadDtcInfoSub_0x05(pduRxData, pduTxData);
\r
794 case 0x0B: // reportFirstTestFailedDTC
\r
795 case 0x0C: // reportFirstConfirmedDTC
\r
796 case 0x0D: // reportMostRecentTestFailedDTC
\r
797 case 0x0E: // reportMostRecentConfirmedDTC
\r
798 responseCode = udsReadDtcInfoSub_0x0B_0x0C_0x0D_0x0E(pduRxData, pduTxData);
\r
801 case 0x14: // reportDTCFaultDetectionCounter
\r
802 responseCode = udsReadDtcInfoSub_0x14(pduRxData, pduTxData);
\r
806 // Unknown sub function
\r
807 responseCode = DCM_E_REQUESTOUTOFRANGE;
\r
813 responseCode = DCM_E_INCORRECTMESSAGELENGTHORINVALIDFORMAT;
\r
817 // Sub function out of range
\r
818 responseCode = DCM_E_REQUESTOUTOFRANGE;
\r
821 DsdDspProcessingDone(responseCode);
\r
824 ** This Function for check the pointer of Dynamically Did Sourced by Did buffer using a didNr
\r
826 static boolean LookupDDD(uint16 didNr, const Dcm_DspDDDType **DDid )
\r
829 boolean ret = FALSE;
\r
830 const Dcm_DspDDDType* DDidptr = &dspDDD[0];
\r
832 for(i = 0;((i < DCM_MAX_DDD_NUMBER) && (ret == FALSE)); i++)
\r
834 if(DDidptr->DynamicallyDid == didNr)
\r
852 static boolean lookupDid(uint16 didNr, const Dcm_DspDidType **didPtr)
\r
854 const Dcm_DspDidType *dspDid = DCM_Config.Dsp->DspDid;
\r
855 boolean didFound = FALSE;
\r
857 while ((dspDid->DspDidIdentifier != didNr) && (!dspDid->Arc_EOL)) {
\r
861 if (!dspDid->Arc_EOL) {
\r
870 static Dcm_NegativeResponseCodeType readDidData(const Dcm_DspDidType *didPtr, PduInfoType *pduTxData, uint16 *txPos)
\r
872 Dcm_NegativeResponseCodeType responseCode = DCM_E_POSITIVERESPONSE;
\r
874 if ((didPtr->DspDidInfoRef->DspDidAccess.DspDidRead != NULL) && (didPtr->DspDidConditionCheckReadFnc != NULL) && (didPtr->DspDidReadDataFnc != NULL)) { /** @req DCM433 */
\r
875 if (DspCheckSessionLevel(didPtr->DspDidInfoRef->DspDidAccess.DspDidRead->DspDidReadSessionRef)) { /** @req DCM434 */
\r
876 if (DspCheckSecurityLevel(didPtr->DspDidInfoRef->DspDidAccess.DspDidRead->DspDidReadSecurityLevelRef)) { /** @req DCM435 */
\r
877 Std_ReturnType result;
\r
878 Dcm_NegativeResponseCodeType errorCode;
\r
879 result = didPtr->DspDidConditionCheckReadFnc(&errorCode);
\r
880 if ((result == E_OK) && (errorCode == DCM_E_POSITIVERESPONSE)) { /** @req DCM439 */
\r
883 if (didPtr->DspDidInfoRef->DspDidFixedLength) { /** @req DCM436 */
\r
884 didLen = didPtr->DspDidSize;
\r
888 if (didPtr->DspDidReadDataLengthFnc != NULL) {
\r
889 result = didPtr->DspDidReadDataLengthFnc(&didLen);
\r
893 if (result == E_OK) {
\r
894 // Now ready for reading the data!
\r
895 if ((*txPos + didLen + 2) <= pduTxData->SduLength) {
\r
896 pduTxData->SduDataPtr[*txPos] = (didPtr->DspDidIdentifier >> 8) & 0xFFu;
\r
898 pduTxData->SduDataPtr[*txPos] = didPtr->DspDidIdentifier & 0xFFu;
\r
900 result = didPtr->DspDidReadDataFnc(&pduTxData->SduDataPtr[*txPos]); /** @req DCM437 */
\r
903 if (result != E_OK) {
\r
904 responseCode = DCM_E_CONDITIONSNOTCORRECT;
\r
907 else { // tx buffer full
\r
908 responseCode = DCM_E_REQUESTOUTOFRANGE;
\r
911 else { // Not possible to obtain did length
\r
912 responseCode = DCM_E_CONDITIONSNOTCORRECT;
\r
915 else { // CheckRead failed
\r
916 responseCode = DCM_E_CONDITIONSNOTCORRECT;
\r
919 else { // Not allowed in current security level
\r
920 responseCode = DCM_E_SECUTITYACCESSDENIED;
\r
923 else { // Not allowed in current session
\r
924 responseCode = DCM_E_SERVICENOTSUPPORTEDINACTIVESESSION;
\r
927 else { // Read access not configured
\r
928 responseCode = DCM_E_REQUESTOUTOFRANGE;
\r
931 if (responseCode == DCM_E_POSITIVERESPONSE) {
\r
932 // Recurse trough the rest of the dids. /** @req DCM440 */
\r
934 for (i=0; (!didPtr->DspDidRef[i]->Arc_EOL) && (responseCode == DCM_E_POSITIVERESPONSE); i++) {
\r
935 responseCode = readDidData(didPtr->DspDidRef[i], pduTxData, txPos);
\r
939 return responseCode;
\r
943 ** This Function for read Dynamically Did data buffer Sourced by Memory address using a didNr
\r
945 static Dcm_NegativeResponseCodeType readDDDData( Dcm_DspDDDType *PDidPtr, uint8 *Data,uint16 *Length)
\r
949 uint8 AddressFormat;
\r
950 uint16 SourceDataLength = 0;
\r
951 const Dcm_DspMemoryIdInfo *SourceMemoryInfoptr = NULL;
\r
952 const Dcm_DspDidType *SourceDidPtr = NULL;
\r
953 Dcm_NegativeResponseCodeType responseCode = DCM_E_POSITIVERESPONSE;
\r
956 for(i = 0;(i < DCM_MAX_DDDSOURCE_NUMBER) && (PDidPtr->DDDSource[i].formatOrPosition != 0)
\r
957 &&(responseCode == DCM_E_POSITIVERESPONSE);i++)
\r
959 if(PDidPtr->DDDSource[i].DDDTpyeID == DCM_DDD_SOURCE_ADDRESS)
\r
962 AddressFormat = PDidPtr->DDDSource[i].formatOrPosition&DCM_FORMAT_HIGH_MASK >> 4;
\r
963 if(TRUE == lookupReadMemory(PDidPtr->DDDSource[i].SourceAddressOrDid,AddressFormat,
\r
964 PDidPtr->DDDSource[i].Size, &SourceMemoryInfoptr))
\r
966 if(DspCheckSecurityLevel(SourceMemoryInfoptr->pReadMemoryInfo->pSecurityLevel) != TRUE)
\r
968 responseCode = DCM_E_SECUTITYACCESSDENIED;
\r
973 responseCode = DCM_E_REQUESTOUTOFRANGE;
\r
975 if(responseCode == DCM_E_POSITIVERESPONSE)
\r
977 Dcm_ReadMemory(DCM_INITIAL,SourceMemoryInfoptr->MemoryIdValue,
\r
978 PDidPtr->DDDSource[i].SourceAddressOrDid,
\r
979 PDidPtr->DDDSource[i].Size,
\r
981 *Length = *Length + PDidPtr->DDDSource[i].Size;
\r
984 else if(PDidPtr->DDDSource[i].DDDTpyeID == DCM_DDD_SOURCE_DID)
\r
987 if(lookupDid(PDidPtr->DDDSource[i].SourceAddressOrDid,&SourceDidPtr) == TRUE)
\r
989 if(DspCheckSecurityLevel(SourceDidPtr->DspDidInfoRef->DspDidAccess.DspDidRead->DspDidReadSecurityLevelRef) != TRUE)
\r
991 responseCode = DCM_E_SECUTITYACCESSDENIED;
\r
993 if(SourceDidPtr->DspDidInfoRef->DspDidFixedLength == TRUE)
\r
995 SourceDataLength = SourceDidPtr->DspDidSize;
\r
999 if(SourceDidPtr->DspDidReadDataLengthFnc != NULL)
\r
1001 SourceDidPtr->DspDidReadDataLengthFnc(&SourceDataLength);
\r
1004 if((SourceDidPtr->DspDidReadDataFnc != NULL) && (SourceDataLength != 0) && (DCM_E_POSITIVERESPONSE == responseCode))
\r
1007 SourceDidPtr->DspDidReadDataFnc((Data + *Length));
\r
1008 for(dataCount = 0;dataCount < SourceDataLength;dataCount++)
\r
1010 if(dataCount < PDidPtr->DDDSource[i].Size)
\r
1012 *(Data + *Length + dataCount) = *(Data + *Length + dataCount + PDidPtr->DDDSource[i].formatOrPosition - 1);
\r
1016 *(Data + *Length + dataCount) = 0;
\r
1019 *Length = *Length + PDidPtr->DDDSource[i].Size;
\r
1023 responseCode = DCM_E_REQUESTOUTOFRANGE;
\r
1028 responseCode = DCM_E_REQUESTOUTOFRANGE;
\r
1034 responseCode = DCM_E_REQUESTOUTOFRANGE;
\r
1037 return responseCode;
\r
1040 void DspUdsReadDataByIdentifier(const PduInfoType *pduRxData, PduInfoType *pduTxData)
\r
1042 /** @req DCM253 */
\r
1043 Dcm_NegativeResponseCodeType responseCode = DCM_E_POSITIVERESPONSE;
\r
1046 const Dcm_DspDidType *didPtr = NULL;
\r
1047 Dcm_DspDDDType *DDidPtr=NULL;
\r
1052 if ( ((pduRxData->SduLength - 1) % 2) == 0 ) {
\r
1053 nrOfDids = (pduRxData->SduLength - 1) / 2;
\r
1055 for (i = 0; (i < nrOfDids) && (responseCode == DCM_E_POSITIVERESPONSE); i++)
\r
1057 didNr = (uint16)((uint16)pduRxData->SduDataPtr[1 + (i * 2)] << 8) + pduRxData->SduDataPtr[2 + (i * 2)];
\r
1058 if (lookupDid(didNr, &didPtr)) { /** @req DCM438 */
\r
1059 responseCode = readDidData(didPtr, pduTxData, &txPos);
\r
1062 else if(LookupDDD(didNr,(const Dcm_DspDDDType **)&DDidPtr) == TRUE)
\r
1064 /*DCM 651,DCM 652*/
\r
1065 pduTxData->SduDataPtr[txPos] = (DDidPtr->DynamicallyDid>>8) & 0xFF;
\r
1067 pduTxData->SduDataPtr[txPos] = (uint8)(DDidPtr->DynamicallyDid & 0xFF);
\r
1069 responseCode = readDDDData(DDidPtr,&(pduTxData->SduDataPtr[txPos]), &Length);
\r
1070 txPos = txPos + Length;
\r
1074 { // DID not found
\r
1075 responseCode = DCM_E_REQUESTOUTOFRANGE;
\r
1080 responseCode = DCM_E_INCORRECTMESSAGELENGTHORINVALIDFORMAT;
\r
1083 if (responseCode == DCM_E_POSITIVERESPONSE) {
\r
1084 pduTxData->SduLength = txPos;
\r
1087 DsdDspProcessingDone(responseCode);
\r
1091 static Dcm_NegativeResponseCodeType readDidScalingData(const Dcm_DspDidType *didPtr, const PduInfoType *pduTxData, uint16 *txPos)
\r
1093 Dcm_NegativeResponseCodeType responseCode = DCM_E_POSITIVERESPONSE;
\r
1095 if (didPtr->DspDidGetScalingInfoFnc != NULL) {
\r
1096 uint16 scalingInfoLen;
\r
1098 scalingInfoLen = didPtr->DspDidInfoRef->DspDidScalingInfoSize;
\r
1099 if ((*txPos + scalingInfoLen + 2) <= pduTxData->SduLength) {
\r
1100 Std_ReturnType result;
\r
1101 Dcm_NegativeResponseCodeType errorCode;
\r
1103 pduTxData->SduDataPtr[*txPos] = (didPtr->DspDidIdentifier >> 8) & 0xFFu;
\r
1105 pduTxData->SduDataPtr[*txPos] = didPtr->DspDidIdentifier & 0xFFu;
\r
1107 result = didPtr->DspDidGetScalingInfoFnc(&pduTxData->SduDataPtr[*txPos], &errorCode); /** @req DCM394 */
\r
1108 *txPos += scalingInfoLen;
\r
1110 if ((result != E_OK) || (errorCode != DCM_E_POSITIVERESPONSE)) {
\r
1111 responseCode = DCM_E_CONDITIONSNOTCORRECT;
\r
1114 else { // tx buffer full
\r
1115 responseCode = DCM_E_REQUESTOUTOFRANGE;
\r
1118 else { // DspDidGetScalingInfoFnc null pointer
\r
1119 responseCode = DCM_E_CONDITIONSNOTCORRECT;
\r
1122 return responseCode;
\r
1125 void DspUdsReadScalingDataByIdentifier(const PduInfoType *pduRxData, PduInfoType *pduTxData)
\r
1127 /** @req DCM258 */
\r
1128 Dcm_NegativeResponseCodeType responseCode = DCM_E_POSITIVERESPONSE;
\r
1130 const Dcm_DspDidType *didPtr = NULL;
\r
1134 if (pduRxData->SduLength == 3) {
\r
1135 didNr = (uint16)((uint16)pduRxData->SduDataPtr[1] << 8) + pduRxData->SduDataPtr[2];
\r
1136 if (lookupDid(didNr, &didPtr)) {
\r
1137 responseCode = readDidScalingData(didPtr, pduTxData, &txPos);
\r
1139 else { // DID not found
\r
1140 responseCode = DCM_E_REQUESTOUTOFRANGE;
\r
1143 if (responseCode == DCM_E_POSITIVERESPONSE) {
\r
1144 pduTxData->SduLength = txPos;
\r
1149 responseCode = DCM_E_INCORRECTMESSAGELENGTHORINVALIDFORMAT;
\r
1152 DsdDspProcessingDone(responseCode);
\r
1156 static Dcm_NegativeResponseCodeType writeDidData(const Dcm_DspDidType *didPtr, const PduInfoType *pduRxData, uint16 writeDidLen)
\r
1158 Dcm_NegativeResponseCodeType responseCode = DCM_E_POSITIVERESPONSE;
\r
1160 if ((didPtr->DspDidInfoRef->DspDidAccess.DspDidWrite != NULL) && (didPtr->DspDidConditionCheckWriteFnc != NULL) && (didPtr->DspDidWriteDataFnc != NULL)) { /** @req DCM468 */
\r
1161 if (DspCheckSessionLevel(didPtr->DspDidInfoRef->DspDidAccess.DspDidWrite->DspDidWriteSessionRef)) { /** @req DCM469 */
\r
1162 if (DspCheckSecurityLevel(didPtr->DspDidInfoRef->DspDidAccess.DspDidWrite->DspDidWriteSecurityLevelRef)) { /** @req DCM470 */
\r
1163 Std_ReturnType result;
\r
1164 Dcm_NegativeResponseCodeType errorCode;
\r
1165 result = didPtr->DspDidConditionCheckWriteFnc(&errorCode); /** @req DCM471 */
\r
1166 if ((result == E_OK) && (errorCode == DCM_E_POSITIVERESPONSE)) {
\r
1167 uint16 didLen = 0;
\r
1168 result = E_NOT_OK;
\r
1169 if (didPtr->DspDidInfoRef->DspDidFixedLength) { /** @req DCM472 */
\r
1170 didLen = didPtr->DspDidSize;
\r
1174 if (didPtr->DspDidReadDataLengthFnc != NULL) {
\r
1175 result = didPtr->DspDidReadDataLengthFnc(&didLen);
\r
1178 if (result == E_OK) {
\r
1179 if (didLen == writeDidLen) { /** @req DCM473 */
\r
1180 result = didPtr->DspDidWriteDataFnc(&pduRxData->SduDataPtr[3], (uint8)didLen, &errorCode); /** @req DCM395 */
\r
1181 if ((result != E_OK) && (errorCode == DCM_E_POSITIVERESPONSE)) {
\r
1182 responseCode = DCM_E_CONDITIONSNOTCORRECT;
\r
1186 responseCode = DCM_E_INCORRECTMESSAGELENGTHORINVALIDFORMAT;
\r
1189 else { // Not possible to obtain did length
\r
1190 responseCode = DCM_E_CONDITIONSNOTCORRECT;
\r
1193 else { // CheckRead failed
\r
1194 responseCode = DCM_E_CONDITIONSNOTCORRECT;
\r
1197 else { // Not allowed in current security level
\r
1198 responseCode = DCM_E_SECUTITYACCESSDENIED;
\r
1201 else { // Not allowed in current session
\r
1202 responseCode = DCM_E_SERVICENOTSUPPORTEDINACTIVESESSION;
\r
1205 else { // Read access not configured
\r
1206 responseCode = DCM_E_REQUESTOUTOFRANGE;
\r
1209 return responseCode;
\r
1212 void DspUdsWriteDataByIdentifier(const PduInfoType *pduRxData, PduInfoType *pduTxData)
\r
1214 /** @req DCM255 */
\r
1215 Dcm_NegativeResponseCodeType responseCode = DCM_E_POSITIVERESPONSE;
\r
1217 const Dcm_DspDidType *didPtr = NULL;
\r
1219 uint16 didDataLength;
\r
1221 didDataLength = pduRxData->SduLength - 3;
\r
1222 didNr = (uint16)((uint16)pduRxData->SduDataPtr[1] << 8) + pduRxData->SduDataPtr[2];
\r
1223 if (lookupDid(didNr, &didPtr)) { /** @req DCM467 */
\r
1224 responseCode = writeDidData(didPtr, pduRxData, didDataLength);
\r
1226 else { // DID not found
\r
1227 responseCode = DCM_E_REQUESTOUTOFRANGE;
\r
1230 if (responseCode == DCM_E_POSITIVERESPONSE) {
\r
1231 pduTxData->SduLength = 3;
\r
1232 pduTxData->SduDataPtr[1] = (didNr >> 8) & 0xFFu;
\r
1233 pduTxData->SduDataPtr[2] = didNr & 0xFFu;
\r
1236 DsdDspProcessingDone(responseCode);
\r
1240 void DspUdsSecurityAccess(const PduInfoType *pduRxData, PduInfoType *pduTxData)
\r
1242 /** @req DCM252 */
\r
1243 Dcm_NegativeResponseCodeType responseCode = DCM_E_POSITIVERESPONSE;
\r
1245 // Check sub function range (0x01 to 0x42)
\r
1246 if ((pduRxData->SduDataPtr[1] >= 0x01) && (pduRxData->SduDataPtr[1] <= 0x42)) {
\r
1247 boolean isRequestSeed = pduRxData->SduDataPtr[1] & 0x01u;
\r
1248 Dcm_SecLevelType requestedSecurityLevel = (pduRxData->SduDataPtr[1]-1)/2;
\r
1249 Dcm_NegativeResponseCodeType getSeedErrorCode;
\r
1251 if (isRequestSeed) {
\r
1252 // requestSeed message
\r
1253 // Check if type exist in security table
\r
1254 const Dcm_DspSecurityRowType *securityRow = &DCM_Config.Dsp->DspSecurity->DspSecurityRow[0];
\r
1255 while ((securityRow->DspSecurityLevel != requestedSecurityLevel) && (!securityRow->Arc_EOL)) {
\r
1258 if (!securityRow->Arc_EOL) {
\r
1260 if (pduRxData->SduLength == (2 + securityRow->DspSecurityADRSize)) { /** @req DCM321.RequestSeed */
\r
1261 Dcm_SecLevelType activeSecLevel;
\r
1262 Std_ReturnType result;
\r
1263 result = Dcm_GetSecurityLevel(&activeSecLevel);
\r
1264 if (result == E_OK) {
\r
1265 if (requestedSecurityLevel == activeSecLevel) { /** @req DCM323 */
\r
1266 pduTxData->SduDataPtr[1] = pduRxData->SduDataPtr[1];
\r
1267 // If same level set the seed to zeroes
\r
1268 memset(&pduTxData->SduDataPtr[2], 0, securityRow->DspSecuritySeedSize);
\r
1269 pduTxData->SduLength = 2 + securityRow->DspSecuritySeedSize;
\r
1271 // New security level ask for seed
\r
1272 if (securityRow->GetSeed != NULL) {
\r
1273 Std_ReturnType getSeedResult;
\r
1274 getSeedResult = securityRow->GetSeed(&pduRxData->SduDataPtr[2], &pduTxData->SduDataPtr[2], &getSeedErrorCode); /** @req DCM324.RequestSeed */
\r
1275 if ((getSeedResult == E_OK) && (getSeedErrorCode == E_OK)) {
\r
1276 // Everything ok add sub function to tx message and send it.
\r
1277 pduTxData->SduDataPtr[1] = pduRxData->SduDataPtr[1];
\r
1278 pduTxData->SduLength = 2 + securityRow->DspSecuritySeedSize;
\r
1280 dspUdsSecurityAccesData.reqSecLevel = requestedSecurityLevel;
\r
1281 dspUdsSecurityAccesData.reqSecLevelRef = securityRow;
\r
1282 dspUdsSecurityAccesData.reqInProgress = TRUE;
\r
1285 // GetSeed returned not ok
\r
1286 responseCode = DCM_E_INCORRECTMESSAGELENGTHORINVALIDFORMAT;
\r
1289 responseCode = DCM_E_INCORRECTMESSAGELENGTHORINVALIDFORMAT;
\r
1293 // TODO: What to do?
\r
1294 responseCode = DCM_E_GENERALREJECT;
\r
1300 responseCode = DCM_E_INCORRECTMESSAGELENGTHORINVALIDFORMAT;
\r
1304 // Requested security level not configured
\r
1305 responseCode = DCM_E_INCORRECTMESSAGELENGTHORINVALIDFORMAT;
\r
1309 // sendKey message
\r
1310 if (dspUdsSecurityAccesData.reqInProgress) {
\r
1311 if (pduRxData->SduLength == (2 + dspUdsSecurityAccesData.reqSecLevelRef->DspSecurityKeySize)) { /** @req DCM321.SendKey */
\r
1312 if (requestedSecurityLevel == dspUdsSecurityAccesData.reqSecLevel) {
\r
1313 if (dspUdsSecurityAccesData.reqSecLevelRef->CompareKey != NULL) {
\r
1314 Std_ReturnType compareKeyResult;
\r
1315 compareKeyResult = dspUdsSecurityAccesData.reqSecLevelRef->CompareKey(&pduRxData->SduDataPtr[2]); /** @req DCM324.SendKey */
\r
1316 if (compareKeyResult == E_OK) {
\r
1317 // Request accepted
\r
1319 DslSetSecurityLevel(dspUdsSecurityAccesData.reqSecLevelRef->DspSecurityLevel); /** @req DCM325 */
\r
1320 dspUdsSecurityAccesData.reqInProgress = FALSE;
\r
1321 pduTxData->SduDataPtr[1] = pduRxData->SduDataPtr[1];
\r
1322 pduTxData->SduLength = 2;
\r
1325 responseCode = DCM_E_CONDITIONSNOTCORRECT;
\r
1328 responseCode = DCM_E_CONDITIONSNOTCORRECT;
\r
1332 responseCode = DCM_E_CONDITIONSNOTCORRECT;
\r
1337 responseCode = DCM_E_INCORRECTMESSAGELENGTHORINVALIDFORMAT;
\r
1341 // sendKey request without a preceding requestSeed
\r
1342 responseCode = DCM_E_REQUESTSEQUENCEERROR;
\r
1347 responseCode = DCM_E_SUBFUNCTIONNOTSUPPORTED;
\r
1350 DsdDspProcessingDone(responseCode);
\r
1354 static boolean lookupRoutine(uint16 routineId, const Dcm_DspRoutineType **routinePtr)
\r
1356 const Dcm_DspRoutineType *dspRoutine = DCM_Config.Dsp->DspRoutine;
\r
1357 boolean routineFound = FALSE;
\r
1359 while ((dspRoutine->DspRoutineIdentifier != routineId) && (!dspRoutine->Arc_EOL)) {
\r
1363 if (!dspRoutine->Arc_EOL) {
\r
1364 routineFound = TRUE;
\r
1365 *routinePtr = dspRoutine;
\r
1368 return routineFound;
\r
1372 static Dcm_NegativeResponseCodeType startRoutine(const Dcm_DspRoutineType *routinePtr, const PduInfoType *pduRxData, PduInfoType *pduTxData)
\r
1374 Dcm_NegativeResponseCodeType responseCode = DCM_E_POSITIVERESPONSE;
\r
1375 Std_ReturnType routineResult;
\r
1378 if ((routinePtr->DspStartRoutineFnc != NULL) && (routinePtr->DspRoutineInfoRef->DspStartRoutine != NULL)) {
\r
1379 if (((routinePtr->DspRoutineInfoRef->DspStartRoutine->DspStartRoutineCtrlOptRecSize + 4) == pduRxData->SduLength)
\r
1380 && ((routinePtr->DspRoutineInfoRef->DspStartRoutine->DspStartRoutineStsOptRecSize + 4) <= pduTxData->SduLength)) {
\r
1381 pduTxData->SduLength = routinePtr->DspRoutineInfoRef->DspStartRoutine->DspStartRoutineStsOptRecSize + 4;
\r
1382 routineResult = routinePtr->DspStartRoutineFnc(&pduRxData->SduDataPtr[4], &pduTxData->SduDataPtr[4], &responseCode); /** @req DCM400 */ /** @req DCM401 */
\r
1383 if (routineResult != E_OK) {
\r
1384 responseCode = DCM_E_CONDITIONSNOTCORRECT;
\r
1388 responseCode = DCM_E_INCORRECTMESSAGELENGTHORINVALIDFORMAT;
\r
1392 responseCode = DCM_E_CONDITIONSNOTCORRECT;
\r
1395 return responseCode;
\r
1399 static Dcm_NegativeResponseCodeType stopRoutine(const Dcm_DspRoutineType *routinePtr, const PduInfoType *pduRxData, PduInfoType *pduTxData)
\r
1401 Dcm_NegativeResponseCodeType responseCode = DCM_E_POSITIVERESPONSE;
\r
1402 Std_ReturnType routineResult;
\r
1405 if ((routinePtr->DspStopRoutineFnc != NULL) && (routinePtr->DspRoutineInfoRef->DspRoutineStop != NULL)) {
\r
1406 if (((routinePtr->DspRoutineInfoRef->DspRoutineStop->DspStopRoutineCtrlOptRecSize + 4) == pduRxData->SduLength)
\r
1407 && ((routinePtr->DspRoutineInfoRef->DspRoutineStop->DspStopRoutineStsOptRecSize + 4) <= pduTxData->SduLength)) {
\r
1408 pduTxData->SduLength = routinePtr->DspRoutineInfoRef->DspRoutineStop->DspStopRoutineStsOptRecSize + 4;
\r
1409 routineResult = routinePtr->DspStopRoutineFnc(&pduRxData->SduDataPtr[4], &pduTxData->SduDataPtr[4], &responseCode); /** @req DCM402 */ /** @req DCM403 */
\r
1410 if (routineResult != E_OK) {
\r
1411 responseCode = DCM_E_CONDITIONSNOTCORRECT;
\r
1415 responseCode = DCM_E_INCORRECTMESSAGELENGTHORINVALIDFORMAT;
\r
1419 responseCode = DCM_E_CONDITIONSNOTCORRECT;
\r
1422 return responseCode;
\r
1426 static Dcm_NegativeResponseCodeType requestRoutineResults(const Dcm_DspRoutineType *routinePtr, PduInfoType *pduTxData)
\r
1428 Dcm_NegativeResponseCodeType responseCode = DCM_E_POSITIVERESPONSE;
\r
1429 Std_ReturnType routineResult;
\r
1431 // requestRoutineResults
\r
1432 if ((routinePtr->DspRequestResultRoutineFnc != NULL) && (routinePtr->DspRoutineInfoRef->DspRoutineRequestRes != NULL)) {
\r
1433 if ((routinePtr->DspRoutineInfoRef->DspRoutineRequestRes->DspReqResRtnCtrlOptRecSize + 4) <= pduTxData->SduLength) {
\r
1434 pduTxData->SduLength = routinePtr->DspRoutineInfoRef->DspRoutineRequestRes->DspReqResRtnCtrlOptRecSize + 4;
\r
1435 routineResult = routinePtr->DspRequestResultRoutineFnc(&pduTxData->SduDataPtr[4], &responseCode); /** @req DCM404 */ /** @req DCM405 */
\r
1436 if (routineResult != E_OK) {
\r
1437 responseCode = DCM_E_CONDITIONSNOTCORRECT;
\r
1441 responseCode = DCM_E_INCORRECTMESSAGELENGTHORINVALIDFORMAT;
\r
1445 responseCode = DCM_E_CONDITIONSNOTCORRECT;
\r
1448 return responseCode;
\r
1452 void DspUdsRoutineControl(const PduInfoType *pduRxData, PduInfoType *pduTxData)
\r
1454 /** @req DCM257 */
\r
1455 Dcm_NegativeResponseCodeType responseCode = DCM_E_POSITIVERESPONSE;
\r
1456 uint8 subFunctionNumber = 0;
\r
1457 uint16 routineId = 0;
\r
1458 const Dcm_DspRoutineType *routinePtr = NULL;
\r
1460 if (pduRxData->SduLength >= 4) {
\r
1461 subFunctionNumber = pduRxData->SduDataPtr[1];
\r
1462 if ((subFunctionNumber > 0) && (subFunctionNumber < 4)) {
\r
1463 routineId = (uint16)((uint16)pduRxData->SduDataPtr[2] << 8) + pduRxData->SduDataPtr[3];
\r
1464 if (lookupRoutine(routineId, &routinePtr)) {
\r
1465 if (DspCheckSessionLevel(routinePtr->DspRoutineInfoRef->DspRoutineAuthorization.DspRoutineSessionRef)) {
\r
1466 if (DspCheckSecurityLevel(routinePtr->DspRoutineInfoRef->DspRoutineAuthorization.DspRoutineSecurityLevelRef)) {
\r
1467 switch (subFunctionNumber) {
\r
1468 case 0x01: // startRoutine
\r
1469 responseCode = startRoutine(routinePtr, pduRxData, pduTxData);
\r
1472 case 0x02: // stopRoutine
\r
1473 responseCode = stopRoutine(routinePtr, pduRxData, pduTxData);
\r
1476 case 0x03: // requestRoutineResults
\r
1477 responseCode = requestRoutineResults(routinePtr, pduTxData);
\r
1480 default: // This shall never happen
\r
1481 responseCode = DCM_E_SUBFUNCTIONNOTSUPPORTED;
\r
1485 else { // Not allowed in current security level
\r
1486 responseCode = DCM_E_SECUTITYACCESSDENIED;
\r
1489 else { // Not allowed in current session
\r
1490 responseCode = DCM_E_SERVICENOTSUPPORTEDINACTIVESESSION;
\r
1493 else { // Unknown routine identifier
\r
1494 responseCode = DCM_E_REQUESTOUTOFRANGE;
\r
1497 else { // Sub function not supported
\r
1498 responseCode = DCM_E_SUBFUNCTIONNOTSUPPORTED;
\r
1503 responseCode = DCM_E_INCORRECTMESSAGELENGTHORINVALIDFORMAT;
\r
1506 if (responseCode == DCM_E_POSITIVERESPONSE) {
\r
1507 // Add header to the positive response message
\r
1508 pduTxData->SduDataPtr[1] = subFunctionNumber;
\r
1509 pduTxData->SduDataPtr[2] = (routineId >> 8) & 0xFFu;
\r
1510 pduTxData->SduDataPtr[3] = routineId & 0xFFu;
\r
1513 DsdDspProcessingDone(responseCode);
\r
1517 void DspUdsTesterPresent(const PduInfoType *pduRxData, PduInfoType *pduTxData)
\r
1519 /** @req DCM251 */
\r
1520 if (pduRxData->SduLength == 2) {
\r
1521 switch (pduRxData->SduDataPtr[1])
\r
1523 case ZERO_SUB_FUNCTION:
\r
1524 DslResetSessionTimeoutTimer();
\r
1525 // Create positive response
\r
1526 pduTxData->SduDataPtr[1] = ZERO_SUB_FUNCTION;
\r
1527 pduTxData->SduLength = 2;
\r
1528 DsdDspProcessingDone(DCM_E_POSITIVERESPONSE);
\r
1532 DsdDspProcessingDone(DCM_E_SUBFUNCTIONNOTSUPPORTED);
\r
1538 DsdDspProcessingDone(DCM_E_INCORRECTMESSAGELENGTHORINVALIDFORMAT);
\r
1543 void DspUdsControlDtcSetting(const PduInfoType *pduRxData, PduInfoType *pduTxData)
\r
1545 /** @req DCM249 */
\r
1546 Dem_ReturnControlDTCStorageType resultCode;
\r
1548 if (pduRxData->SduLength == 2) {
\r
1549 switch (pduRxData->SduDataPtr[1])
\r
1552 resultCode = Dem_EnableDTCStorage(DEM_DTC_GROUP_ALL_DTCS, DEM_DTC_KIND_ALL_DTCS); /** @req DCM304 */
\r
1553 if (resultCode == DEM_CONTROL_DTC_STORAGE_OK) {
\r
1554 pduTxData->SduDataPtr[1] = 0x01;
\r
1555 pduTxData->SduLength = 2;
\r
1556 DsdDspProcessingDone(DCM_E_POSITIVERESPONSE);
\r
1559 DsdDspProcessingDone(DCM_E_REQUESTOUTOFRANGE);
\r
1564 resultCode = Dem_DisableDTCStorage(DEM_DTC_GROUP_ALL_DTCS, DEM_DTC_KIND_ALL_DTCS); /** @req DCM406 */
\r
1565 if (resultCode == DEM_CONTROL_DTC_STORAGE_OK) {
\r
1566 pduTxData->SduDataPtr[1] = 0x02;
\r
1567 pduTxData->SduLength = 2;
\r
1568 DsdDspProcessingDone(DCM_E_POSITIVERESPONSE);
\r
1571 DsdDspProcessingDone(DCM_E_REQUESTOUTOFRANGE);
\r
1576 DsdDspProcessingDone(DCM_E_SUBFUNCTIONNOTSUPPORTED);
\r
1582 DsdDspProcessingDone(DCM_E_INCORRECTMESSAGELENGTHORINVALIDFORMAT);
\r
1587 void DspDcmConfirmation(PduIdType confirmPduId)
\r
1589 if (dspUdsEcuResetData.resetPending) {
\r
1590 if (confirmPduId == dspUdsEcuResetData.resetPduId) {
\r
1591 dspUdsEcuResetData.resetPending = FALSE;
\r
1592 #if defined(USE_MCU) && ( MCU_PERFORM_RESET_API == STD_ON )
\r
1593 Mcu_PerformReset();
\r
1595 DET_REPORTERROR(MODULE_ID_DCM, 0, DCM_UDS_RESET_ID, DCM_E_NOT_SUPPORTED);
\r
1602 static boolean CheckReadMemoryByAddress( boolean useId,uint32 memoryAddress,
\r
1603 uint8 memoryAddressFormat,
\r
1604 uint32 memorySize,
\r
1605 const Dcm_DspMemoryIdInfo *dspMemory)
\r
1607 boolean ret = FALSE;
\r
1610 if(useId == FALSE)
\r
1613 if((memoryAddress >= dspMemory->pReadMemoryInfo->MemoryAddressLow)
\r
1614 && (memoryAddress <= dspMemory->pReadMemoryInfo->MemoryAddressHigh)
\r
1615 && (memoryAddress + memorySize - 1 <= dspMemory->pReadMemoryInfo->MemoryAddressHigh))
\r
1622 MemoryId = (uint8)(memoryAddress >> ((memoryAddressFormat - 1)*8));
\r
1623 memoryAddress = (uint32)(memoryAddress & DCM_MEMORY_ADDRESS_MASK);
\r
1625 if((MemoryId == dspMemory->MemoryIdValue)&&
\r
1626 (memoryAddress >= dspMemory->pReadMemoryInfo->MemoryAddressLow)
\r
1627 && (memoryAddress <= dspMemory->pReadMemoryInfo->MemoryAddressHigh)
\r
1628 && (memoryAddress + memorySize - 1 <= dspMemory->pReadMemoryInfo->MemoryAddressHigh))
\r
1637 static boolean lookupReadMemory(uint32 memoryAddress,
\r
1638 uint8 memoryAddressFormat,
\r
1639 uint32 memorySize,
\r
1640 const Dcm_DspMemoryIdInfo **MemoryInfoPtr)
\r
1643 boolean memoryFound = FALSE;
\r
1644 const Dcm_DspMemoryIdInfo *dspMemoryInfo = DCM_Config.Dsp->DspMemory->DspMemoryIdInfo;
\r
1646 for(i = 0; (dspMemoryInfo->Arc_EOL == FALSE) && (memoryFound == FALSE); i++)
\r
1648 if(TRUE == CheckReadMemoryByAddress(DCM_Config.Dsp->DspMemory->DcmDspUseMemoryId,memoryAddress,memoryAddressFormat,memorySize,dspMemoryInfo))
\r
1650 memoryFound = TRUE;
\r
1657 if (memoryFound == TRUE)
\r
1659 *MemoryInfoPtr = dspMemoryInfo;
\r
1662 return memoryFound;
\r
1665 static Dcm_NegativeResponseCodeType readMemoryData( Dcm_OpStatusType *OpStatus,
\r
1666 const Dcm_DspMemoryIdInfo *MemoryPtr,
\r
1667 uint32 MemoryAddress,
\r
1668 uint32 MemorySize,
\r
1669 PduInfoType *pduTxData)
\r
1671 Dcm_ReturnReadMemoryType ReadRet;
\r
1672 Dcm_NegativeResponseCodeType responseCode = DCM_E_POSITIVERESPONSE;
\r
1673 ReadRet = Dcm_ReadMemory(*OpStatus,MemoryPtr->MemoryIdValue,
\r
1676 &pduTxData->SduDataPtr[1]);
\r
1677 if(DCM_READ_FAILED == ReadRet)
\r
1679 responseCode = DCM_E_GENERALPROGRAMMINGFAILURE; /*@req Dcm644*/
\r
1681 if (DCM_READ_PENDING == ReadRet)
\r
1683 *OpStatus = DCM_READ_PENDING;
\r
1685 return responseCode;
\r
1688 /*@req Dcm442,DCM492*/
\r
1689 void DspUdsReadMemoryByAddress(const PduInfoType *pduRxData, PduInfoType *pduTxData)
\r
1692 uint32 MemoryAddressStart; /* low address of a memory block to read or write*/
\r
1693 uint32 MemoryIdValue; /* memory ID to read or write uint used by parameter */
\r
1694 const Dcm_DspMemoryIdInfo *MemoryIdConfigPtr;
\r
1695 Dcm_NegativeResponseCodeType ResponseCode;
\r
1696 uint8 MemorySizeFormat;
\r
1697 uint8 MemoryAddressFormat;
\r
1698 uint32 MemorySize;
\r
1699 uint16 MessageLength;
\r
1700 }DspUdsReadMemoryByAddressType; /*the typed used for SID read memory by address*/
\r
1702 DspUdsReadMemoryByAddressType dspReadMemoryByAddress;
\r
1703 Dcm_OpStatusType OpStatus = 0;
\r
1704 dspReadMemoryByAddress.MemoryAddressStart = 0;
\r
1705 dspReadMemoryByAddress.MemorySize = 0;
\r
1706 dspReadMemoryByAddress.MemoryIdConfigPtr = NULL;
\r
1707 dspReadMemoryByAddress.ResponseCode = DCM_E_POSITIVERESPONSE;
\r
1708 dspReadMemoryByAddress.MemorySizeFormat = ((uint8)(pduRxData->SduDataPtr[1] & DCM_FORMAT_HIGH_MASK)) >> 4; /*@req UDS_REQ_0x23_1 & UDS_REQ_0x23_5*/
\r
1709 dspReadMemoryByAddress.MemoryAddressFormat = ((uint8)(pduRxData->SduDataPtr[1])) & 0x0Fu; /*@req UDS_REQ_0x23_1 & UDS_REQ_0x23_5*/
\r
1711 if((dspReadMemoryByAddress.MemoryAddressFormat == 0)||(dspReadMemoryByAddress.MemorySizeFormat == 0))
\r
1713 dspReadMemoryByAddress.ResponseCode = DCM_E_REQUESTOUTOFRANGE; /*UDS_REQ_0x23_10*/
\r
1717 dspReadMemoryByAddress.MessageLength = (uint16)(dspReadMemoryByAddress.MemoryAddressFormat + dspReadMemoryByAddress.MemorySizeFormat + SID_AND_ALFID_LEN2);
\r
1718 if(dspReadMemoryByAddress.MessageLength == (uint16)(pduRxData->SduLength))
\r
1720 /*take start address out */
\r
1721 for(i = 0; i < dspReadMemoryByAddress.MemoryAddressFormat; i++)
\r
1723 dspReadMemoryByAddress.MemoryAddressStart <<= 8;
\r
1724 dspReadMemoryByAddress.MemoryAddressStart += (uint32)(pduRxData->SduDataPtr[SID_AND_ALFID_LEN2 + i]);
\r
1727 /*take value of MemorySize out */
\r
1728 for(i = 0; i < dspReadMemoryByAddress.MemorySizeFormat; i++)
\r
1730 dspReadMemoryByAddress.MemorySize <<= 8;
\r
1731 dspReadMemoryByAddress.MemorySize += (uint32)(pduRxData->SduDataPtr[2 + i + dspReadMemoryByAddress.MemoryAddressFormat]);
\r
1733 if(dspReadMemoryByAddress.MemorySize < DCM_PROTOCAL_TP_MAX_LENGTH)
\r
1735 if(TRUE == lookupReadMemory(dspReadMemoryByAddress.MemoryAddressStart,
\r
1736 dspReadMemoryByAddress.MemoryAddressFormat,
\r
1737 dspReadMemoryByAddress.MemorySize,
\r
1738 &dspReadMemoryByAddress.MemoryIdConfigPtr))
\r
1740 if (DspCheckSecurityLevel(dspReadMemoryByAddress.MemoryIdConfigPtr->pReadMemoryInfo->pSecurityLevel) == TRUE)
\r
1742 dspReadMemoryByAddress.ResponseCode = readMemoryData(&OpStatus,dspReadMemoryByAddress.MemoryIdConfigPtr,
\r
1743 dspReadMemoryByAddress.MemoryAddressStart,
\r
1744 dspReadMemoryByAddress.MemorySize,pduTxData);/*@req UDS_REQ_0x23_9*/
\r
1749 dspReadMemoryByAddress.ResponseCode = DCM_E_SECUTITYACCESSDENIED;/*@req UDS_REQ_0x23_11,@req DCM494*/
\r
1754 dspReadMemoryByAddress.ResponseCode = DCM_E_REQUESTOUTOFRANGE; /*@req UDS_REQ_0x23_7,UDS_REQ_0x23_8*/
\r
1759 dspReadMemoryByAddress.ResponseCode = DCM_E_REQUESTOUTOFRANGE;
\r
1764 dspReadMemoryByAddress.ResponseCode = DCM_E_INCORRECTMESSAGELENGTHORINVALIDFORMAT; /*@req UDS_REQ_0x23_6*/
\r
1767 if(DCM_E_POSITIVERESPONSE == dspReadMemoryByAddress.ResponseCode)
\r
1769 pduTxData->SduLength = 1 + dspReadMemoryByAddress.MemorySize;
\r
1770 if(OpStatus == DCM_READ_PENDING)
\r
1772 dspMemoryState = DCM_MEMORY_READ;
\r
1776 DsdDspProcessingDone(DCM_E_POSITIVERESPONSE);
\r
1781 DsdDspProcessingDone(dspReadMemoryByAddress.ResponseCode);
\r
1785 static boolean checkWriteMemoryByAddress(boolean useId,uint32 memoryAddress,
\r
1786 uint8 memoryAddressFormat,
\r
1787 uint32 memorySize,
\r
1788 const Dcm_DspMemoryIdInfo *dspMemory)
\r
1790 boolean ret = FALSE;
\r
1793 if(useId == FALSE)
\r
1795 if((memoryAddress >= dspMemory->pWriteMemoryInfo->MemoryAddressLow)
\r
1796 && (memoryAddress <= dspMemory->pWriteMemoryInfo->MemoryAddressHigh)
\r
1797 && (memoryAddress + memorySize - 1 <= dspMemory->pWriteMemoryInfo->MemoryAddressHigh))
\r
1804 MemoryId = (uint8)(memoryAddress >> ((memoryAddressFormat - 1)*8));
\r
1805 memoryAddress = memoryAddress & DCM_MEMORY_ADDRESS_MASK;
\r
1807 if((MemoryId == dspMemory->MemoryIdValue) &&
\r
1808 (memoryAddress >= dspMemory->pWriteMemoryInfo->MemoryAddressLow)
\r
1809 && (memoryAddress <= dspMemory->pWriteMemoryInfo->MemoryAddressHigh)
\r
1810 && (memoryAddress + memorySize -1 <= dspMemory->pWriteMemoryInfo->MemoryAddressHigh))
\r
1820 static boolean lookupWriteMemory(uint32 memoryAddress,
\r
1821 uint8 memoryAddressFormat,
\r
1822 uint32 memorySize,
\r
1823 const Dcm_DspMemoryIdInfo **MemoryIdConfigPtr)
\r
1826 const Dcm_DspMemoryIdInfo *dspMemoryInfo = DCM_Config.Dsp->DspMemory->DspMemoryIdInfo;
\r
1827 boolean memoryFound = FALSE;
\r
1829 for(i = 0;(dspMemoryInfo->Arc_EOL == FALSE) && (memoryFound == FALSE);i++)
\r
1831 if(TRUE == checkWriteMemoryByAddress(DCM_Config.Dsp->DspMemory->DcmDspUseMemoryId, memoryAddress,memoryAddressFormat,memorySize,dspMemoryInfo))
\r
1833 memoryFound = TRUE;
\r
1840 if (memoryFound == TRUE)
\r
1842 *MemoryIdConfigPtr = dspMemoryInfo;
\r
1845 return memoryFound;
\r
1848 static Dcm_NegativeResponseCodeType writeMemoryData(Dcm_OpStatusType* OpStatus,
\r
1849 const Dcm_DspMemoryIdInfo *MemoryIdConfigPtr,
\r
1850 uint32 MemoryAddress,
\r
1851 uint32 MemorySize,
\r
1852 uint8 *SourceData)
\r
1854 Dcm_NegativeResponseCodeType responseCode = DCM_E_POSITIVERESPONSE;
\r
1855 Dcm_ReturnWriteMemoryType writeRet;
\r
1856 writeRet = Dcm_WriteMemory(*OpStatus,
\r
1857 MemoryIdConfigPtr->MemoryIdValue,
\r
1861 if(DCM_READ_FAILED == writeRet)
\r
1863 responseCode = DCM_E_GENERALPROGRAMMINGFAILURE; /*@req UDS_REQ_0X3D_16,DCM643*/
\r
1865 else if(DCM_WRITE_PENDING == writeRet)
\r
1867 *OpStatus = DCM_PENDING;
\r
1871 responseCode = DCM_E_POSITIVERESPONSE;
\r
1874 return responseCode;
\r
1877 void DspUdsWriteMemoryByAddress(const PduInfoType* pduRxData, PduInfoType* pduTxData)
\r
1880 uint32 MemoryAddressStart;
\r
1881 uint32 MemoryIdValue;
\r
1882 const Dcm_DspMemoryIdInfo *MemoryIdConfigPtr;
\r
1883 Dcm_NegativeResponseCodeType ResponseCode;
\r
1884 uint8 MemorySizeFormat;
\r
1885 uint8 MemoryAddressFormat;
\r
1886 uint32 MemorySize ;
\r
1887 uint16 MessageLength;
\r
1888 }DspUdsWriteMemoryType;
\r
1890 DspUdsWriteMemoryType dspUdsWriteMemory;
\r
1891 Dcm_OpStatusType OpStatus = DCM_INITIAL;
\r
1892 dspUdsWriteMemory.MemoryAddressStart = 0;
\r
1893 dspUdsWriteMemory.MemoryIdConfigPtr = NULL;
\r
1894 dspUdsWriteMemory.ResponseCode = DCM_E_POSITIVERESPONSE;
\r
1895 dspUdsWriteMemory.MemorySizeFormat = ((uint8)(pduRxData->SduDataPtr[1] & DCM_FORMAT_HIGH_MASK)) >> 4; /*@req UDS_REQ_0x3D_3 & UDS_REQ_0x3D_5*/
\r
1896 dspUdsWriteMemory.MemoryAddressFormat = ((uint8)pduRxData->SduDataPtr[1]) & DCM_FORMAT_LOW_MASK; /*@req UDS_REQ_0x3D_3& UDS_REQ_0x3D_4*/
\r
1897 dspUdsWriteMemory.MemorySize = 0;
\r
1899 if((dspUdsWriteMemory.MemoryAddressFormat == 0) || (dspUdsWriteMemory.MemorySizeFormat == 0)) /*@req UDS_REQ_0x3D_14*/
\r
1901 dspUdsWriteMemory.ResponseCode = DCM_E_REQUESTOUTOFRANGE;
\r
1905 /*take value of MemorySize out */
\r
1906 for(i = 0; i < dspUdsWriteMemory.MemorySizeFormat; i++)
\r
1908 dspUdsWriteMemory.MemorySize <<= 8;
\r
1909 dspUdsWriteMemory.MemorySize += (uint32)(pduRxData->SduDataPtr[2 + i +dspUdsWriteMemory.MemoryAddressFormat]);
\r
1911 dspUdsWriteMemory.MessageLength = (uint16)(2 + dspUdsWriteMemory.MemoryAddressFormat + dspUdsWriteMemory.MemorySizeFormat + dspUdsWriteMemory.MemorySize);
\r
1912 if(dspUdsWriteMemory.MessageLength == pduRxData->SduLength)
\r
1914 /*take Start Address out */
\r
1915 for(i = 0; i < dspUdsWriteMemory.MemoryAddressFormat; i++)
\r
1917 dspUdsWriteMemory.MemoryAddressStart <<= 8;
\r
1918 dspUdsWriteMemory.MemoryAddressStart += (uint32)(pduRxData->SduDataPtr[2 + i]);
\r
1920 if(TRUE == lookupWriteMemory(dspUdsWriteMemory.MemoryAddressStart,
\r
1921 dspUdsWriteMemory.MemoryAddressFormat,
\r
1922 dspUdsWriteMemory.MemorySize,
\r
1923 &dspUdsWriteMemory.MemoryIdConfigPtr))
\r
1925 if (DspCheckSecurityLevel(dspUdsWriteMemory.MemoryIdConfigPtr->pReadMemoryInfo->pSecurityLevel) == TRUE)
\r
1927 dspUdsWriteMemory.ResponseCode = writeMemoryData(&OpStatus,
\r
1928 dspUdsWriteMemory.MemoryIdConfigPtr,
\r
1929 dspUdsWriteMemory.MemoryAddressStart,
\r
1930 dspUdsWriteMemory.MemorySize,
\r
1931 &pduRxData->SduDataPtr[2 + dspUdsWriteMemory.MemoryAddressFormat + dspUdsWriteMemory.MemorySizeFormat]);
\r
1935 dspUdsWriteMemory.ResponseCode = DCM_E_SECUTITYACCESSDENIED; /*@req UDS_REQ_0X3D_15,Dcm490*/
\r
1940 dspUdsWriteMemory.ResponseCode = DCM_E_REQUESTOUTOFRANGE; /*@req UDS_REQ_0x3D_11,UDS_REQ_0x3D_12,Dcm489*/
\r
1945 dspUdsWriteMemory.ResponseCode = DCM_E_INCORRECTMESSAGELENGTHORINVALIDFORMAT;/*@req UDS_REQ_0x3D_9*/
\r
1948 if(DCM_E_POSITIVERESPONSE == dspUdsWriteMemory.ResponseCode)
\r
1950 pduTxData->SduLength = 2 + dspUdsWriteMemory.MemorySizeFormat + dspUdsWriteMemory.MemoryAddressFormat;
\r
1951 pduTxData->SduDataPtr[1] = pduRxData->SduDataPtr[1];
\r
1952 for(i = 0; i < dspUdsWriteMemory.MemorySizeFormat + dspUdsWriteMemory.MemoryAddressFormat; i++)
\r
1954 pduTxData->SduDataPtr[2 + i] = pduRxData->SduDataPtr[2 + i];
\r
1955 if(OpStatus != DCM_PENDING)
\r
1957 DsdDspProcessingDone(dspUdsWriteMemory.ResponseCode);
\r
1961 dspMemoryState=DCM_MEMORY_WRITE;
\r
1967 DsdDspProcessingDone(dspUdsWriteMemory.ResponseCode);
\r
1971 static boolean checkPeriodicIdentifierBuffer(uint8 PeriodicDid,uint8 Length,uint8 *postion)
\r
1974 boolean ret = FALSE;
\r
1975 for(i = 0;(i < Length) && (ret == FALSE);i++)
\r
1977 if(PeriodicDid == dspPDidRef.dspPDid[i].PeriodicDid)
\r
1987 static void ClearPeriodicIdentifierBuffer(uint8 BufferEnd,uint8 postion)
\r
1989 dspPDidRef.dspPDid[postion].PeriodicDid = dspPDidRef.dspPDid[BufferEnd ].PeriodicDid;
\r
1990 dspPDidRef.dspPDid[postion].PDidTxCounter = dspPDidRef.dspPDid[BufferEnd].PDidTxCounter;
\r
1991 dspPDidRef.dspPDid[postion].PDidTxCounterNumber = dspPDidRef.dspPDid[BufferEnd].PDidTxCounterNumber;
\r
1992 dspPDidRef.dspPDid[BufferEnd].PeriodicDid = 0;
\r
1993 dspPDidRef.dspPDid[BufferEnd].PDidTxCounter = 0;
\r
1994 dspPDidRef.dspPDid[BufferEnd ].PDidTxCounterNumber = 0;
\r
1997 static Dcm_NegativeResponseCodeType readPeriodDidData(const Dcm_DspDidType *PDidPtr, uint8 *Data,uint16 *Length)
\r
1999 Dcm_NegativeResponseCodeType responseCode = DCM_E_POSITIVERESPONSE;
\r
2000 if ((PDidPtr->DspDidInfoRef->DspDidAccess.DspDidRead != NULL)
\r
2001 && (PDidPtr->DspDidConditionCheckReadFnc != NULL)
\r
2002 && (PDidPtr->DspDidReadDataFnc != NULL) )
\r
2004 if (DspCheckSessionLevel(PDidPtr->DspDidInfoRef->DspDidAccess.DspDidRead->DspDidReadSessionRef))
\r
2006 if (DspCheckSecurityLevel(PDidPtr->DspDidInfoRef->DspDidAccess.DspDidRead->DspDidReadSecurityLevelRef))
\r
2008 Std_ReturnType result = E_NOT_OK;
\r
2009 Dcm_NegativeResponseCodeType errorCode = DCM_E_POSITIVERESPONSE;
\r
2010 result = PDidPtr->DspDidConditionCheckReadFnc(&errorCode);
\r
2011 if ((result == E_OK) && (errorCode == DCM_E_POSITIVERESPONSE))
\r
2013 result = E_NOT_OK;
\r
2014 if (PDidPtr->DspDidInfoRef->DspDidFixedLength)
\r
2016 *Length= PDidPtr->DspDidSize;
\r
2021 if(PDidPtr->DspDidReadDataLengthFnc!=NULL)
\r
2023 result = PDidPtr->DspDidReadDataLengthFnc(Length);
\r
2027 responseCode = DCM_E_GENERALREJECT;
\r
2030 if (result == E_OK)
\r
2032 result = PDidPtr->DspDidReadDataFnc(Data);
\r
2033 if (result != E_OK)
\r
2035 responseCode = DCM_E_REQUESTOUTOFRANGE;
\r
2040 responseCode = DCM_E_REQUESTOUTOFRANGE;
\r
2045 responseCode = DCM_E_REQUESTOUTOFRANGE;
\r
2050 responseCode = DCM_E_SECUTITYACCESSDENIED;
\r
2055 responseCode = DCM_E_REQUESTOUTOFRANGE;
\r
2060 responseCode = DCM_E_REQUESTOUTOFRANGE;
\r
2062 return responseCode;
\r
2065 static Dcm_NegativeResponseCodeType DspSavePeriodicData(uint16 didNr, uint32 periodicTransmitCounter,uint8 PdidBufferNr)
\r
2067 Dcm_NegativeResponseCodeType responseCode = DCM_E_POSITIVERESPONSE;
\r
2068 const Dcm_DspDidType *SourceDid = NULL;
\r
2069 Dcm_DspDDDType *DDidPtr = NULL;
\r
2071 if (TRUE == lookupDid(didNr, &SourceDid))
\r
2073 if(DspCheckSessionLevel(SourceDid->DspDidInfoRef->DspDidAccess.DspDidRead->DspDidReadSessionRef) == TRUE)
\r
2075 if(DspCheckSecurityLevel(SourceDid->DspDidInfoRef->DspDidAccess.DspDidRead->DspDidReadSecurityLevelRef) == TRUE)
\r
2077 Std_ReturnType result = E_NOT_OK;
\r
2078 Dcm_NegativeResponseCodeType errorCode = DCM_E_POSITIVERESPONSE;
\r
2080 if(SourceDid->DspDidConditionCheckReadFnc != NULL)
\r
2082 result = SourceDid->DspDidConditionCheckReadFnc(&errorCode);
\r
2084 if ((result != E_OK) || (errorCode != DCM_E_POSITIVERESPONSE))
\r
2086 responseCode = DCM_E_REQUESTOUTOFRANGE;
\r
2088 if((SourceDid->DspDidInfoRef->DspDidFixedLength!=TRUE) && (SourceDid->DspDidReadDataLengthFnc == NULL))
\r
2090 responseCode = DCM_E_GENERALREJECT;
\r
2095 responseCode = DCM_E_SECUTITYACCESSDENIED;
\r
2100 responseCode = DCM_E_REQUESTOUTOFRANGE;
\r
2103 else if(LookupDDD(didNr, (const Dcm_DspDDDType **)&DDidPtr) == TRUE)
\r
2105 responseCode = DCM_E_POSITIVERESPONSE;
\r
2109 responseCode = DCM_E_REQUESTOUTOFRANGE;
\r
2111 if(responseCode == DCM_E_POSITIVERESPONSE)
\r
2113 dspPDidRef.dspPDid[PdidBufferNr].PeriodicDid = (uint8)didNr & DCM_DID_LOW_MASK;
\r
2114 dspPDidRef.dspPDid[PdidBufferNr].PDidTxCounter = 0;
\r
2115 dspPDidRef.dspPDid[PdidBufferNr].PDidTxCounterNumber = periodicTransmitCounter;
\r
2117 return responseCode;
\r
2119 static void ClearPeriodicIdentifier(const PduInfoType *pduRxData,PduInfoType *pduTxData )
\r
2121 uint16 PdidNumber;
\r
2122 uint8 PDidLowByte;
\r
2123 uint8 PdidPostion;
\r
2125 if( pduRxData->SduDataPtr[1] == DCM_PERIODICTRANSMIT_STOPSENDING_MODE )
\r
2127 PdidNumber = pduRxData->SduLength - 2;
\r
2128 for(i = 0;i < PdidNumber;i++)
\r
2130 PDidLowByte = pduRxData->SduDataPtr[2];
\r
2131 if(checkPeriodicIdentifierBuffer(PDidLowByte,dspPDidRef.PDidNr,&PdidPostion) == TRUE)
\r
2133 dspPDidRef.PDidNr--;
\r
2134 ClearPeriodicIdentifierBuffer(dspPDidRef.PDidNr, PdidPostion);
\r
2138 pduTxData->SduLength = 1;
\r
2143 UDS Service 0x2a - Read Data By Periodic Identifier
\r
2145 void DspReadDataByPeriodicIdentifier(const PduInfoType *pduRxData,PduInfoType *pduTxData)
\r
2147 /** @req DCM254 */
\r
2148 uint8 PDidLowByte;
\r
2149 uint16 PdidNumber;
\r
2150 uint8 PdidPostion;
\r
2152 uint8 PdidBufferNr;
\r
2153 uint32 periodicTransmitCounter;
\r
2154 uint16 DataLength;
\r
2155 Dcm_NegativeResponseCodeType responseCode = DCM_E_POSITIVERESPONSE;
\r
2156 const Dcm_DspDidType *PDidPtr = NULL;
\r
2157 Dcm_DspDDDType *DDidPtr = NULL;
\r
2158 PdidBufferNr = dspPDidRef.PDidNr;
\r
2159 if(pduRxData->SduLength > 2)
\r
2162 switch(pduRxData->SduDataPtr[1])
\r
2164 case DCM_PERIODICTRANSMIT_DEFAULT_MODE:
\r
2165 periodicTransmitCounter = 0;
\r
2167 case DCM_PERIODICTRANSMIT_SLOWRATE_MODE:
\r
2168 periodicTransmitCounter = DCM_PERIODICTRANSMIT_SLOW;
\r
2170 case DCM_PERIODICTRANSMIT_MEDIUM_MODE:
\r
2171 periodicTransmitCounter = DCM_PERIODICTRANSMIT_MEDIUM;
\r
2173 case DCM_PERIODICTRANSMIT_FAST_MODE:
\r
2174 periodicTransmitCounter = DCM_PERIODICTRANSMIT_FAST;
\r
2176 case DCM_PERIODICTRANSMIT_STOPSENDING_MODE:
\r
2177 ClearPeriodicIdentifier(pduRxData,pduTxData);
\r
2180 responseCode = DCM_E_REQUESTOUTOFRANGE;
\r
2183 if(pduRxData->SduDataPtr[1] != DCM_PERIODICTRANSMIT_STOPSENDING_MODE)
\r
2185 PdidNumber = pduRxData->SduLength - 2;
\r
2186 if(1 == PdidNumber)
\r
2188 PDidLowByte = pduRxData->SduDataPtr[2];
\r
2189 if(checkPeriodicIdentifierBuffer(PDidLowByte,dspPDidRef.PDidNr,&PdidPostion) == TRUE)
\r
2191 if(0 == periodicTransmitCounter)
\r
2193 if (TRUE == lookupDid(((uint16)PDidLowByte + 0xF200), &PDidPtr)) /*UDS_REQ_0x2A_1*/
\r
2195 pduTxData->SduDataPtr[1] = PDidLowByte;
\r
2196 responseCode = readPeriodDidData(PDidPtr,&pduTxData->SduDataPtr[2],&DataLength);
\r
2197 pduTxData->SduLength = DataLength + 2;
\r
2199 else if(TRUE == LookupDDD((0xF200 + (uint16)PDidLowByte), (const Dcm_DspDDDType **)&DDidPtr))
\r
2201 pduTxData->SduDataPtr[1] = PDidLowByte;
\r
2202 responseCode = readDDDData(DDidPtr,&pduTxData->SduDataPtr[2],&DataLength);
\r
2203 pduTxData->SduLength = DataLength + 2;
\r
2207 responseCode = DCM_E_REQUESTOUTOFRANGE;
\r
2209 if(responseCode != DCM_E_POSITIVERESPONSE)
\r
2211 dspPDidRef.PDidNr--;
\r
2212 ClearPeriodicIdentifierBuffer(dspPDidRef.PDidNr,PdidPostion);
\r
2217 dspPDidRef.dspPDid[PdidPostion].PDidTxCounterNumber = periodicTransmitCounter;
\r
2218 pduTxData->SduLength = 1;
\r
2223 responseCode = DspSavePeriodicData((DCM_PERODICDID_HIHG_MASK + (uint16)PDidLowByte),periodicTransmitCounter,PdidBufferNr);
\r
2225 pduTxData->SduLength = 1;
\r
2228 else if((PdidNumber + PdidBufferNr) <= DCM_LIMITNUMBER_PERIODDATA) /*UDS_REQ_0x2A_6*/
\r
2230 for(i = 0;(i < PdidNumber)&&(responseCode == DCM_E_POSITIVERESPONSE);i++)
\r
2232 PDidLowByte = pduRxData->SduDataPtr[2 + i];
\r
2233 if(checkPeriodicIdentifierBuffer(PDidLowByte,PdidBufferNr,&PdidPostion) == TRUE)
\r
2235 if(dspPDidRef.dspPDid[PdidPostion].PDidTxCounterNumber != periodicTransmitCounter)
\r
2237 dspPDidRef.dspPDid[PdidPostion].PDidTxCounterNumber = periodicTransmitCounter;
\r
2242 responseCode = DspSavePeriodicData((0xF200 + (uint16)PDidLowByte),periodicTransmitCounter,PdidBufferNr);
\r
2245 pduTxData->SduLength = 1;
\r
2250 responseCode = DCM_E_REQUESTOUTOFRANGE;
\r
2252 if(responseCode == DCM_E_POSITIVERESPONSE)
\r
2254 dspPDidRef.PDidNr = PdidBufferNr;
\r
2258 else if((pduRxData->SduLength == 2)&&(pduRxData->SduDataPtr[1] == DCM_PERIODICTRANSMIT_STOPSENDING_MODE))
\r
2260 memset(&dspPDidRef,0,sizeof(dspPDidRef));
\r
2261 pduTxData->SduLength = 1;
\r
2265 responseCode = DCM_E_INCORRECTMESSAGELENGTHORINVALIDFORMAT;
\r
2267 DsdDspProcessingDone(responseCode);
\r
2270 static Dcm_NegativeResponseCodeType dynamicallyDefineDataIdentifierbyDid(uint16 DDIdentifier,const PduInfoType *pduRxData,PduInfoType *pduTxData)
\r
2273 uint16 SourceDidNr;
\r
2274 const Dcm_DspDidType *SourceDid = NULL;
\r
2275 Dcm_DspDDDType *DDid = NULL;
\r
2276 uint16 SourceLength = 0;
\r
2277 uint16 DidLength = 0;
\r
2278 uint16 Length = 0;
\r
2280 Dcm_NegativeResponseCodeType responseCode = DCM_E_POSITIVERESPONSE;
\r
2282 if(FALSE == LookupDDD(DDIdentifier, (const Dcm_DspDDDType **)&DDid))
\r
2284 while((Num < DCM_MAX_DDD_NUMBER) && (dspDDD[Num].DynamicallyDid != 0 ))
\r
2288 if(Num >= DCM_MAX_DDD_NUMBER)
\r
2290 responseCode = DCM_E_REQUESTOUTOFRANGE;
\r
2294 DDid = &dspDDD[Num];
\r
2299 while((SourceLength < DCM_MAX_DDDSOURCE_NUMBER) && (DDid->DDDSource[SourceLength].formatOrPosition != 0 ))
\r
2303 if(SourceLength > DCM_MAX_DDDSOURCE_NUMBER)
\r
2305 responseCode = DCM_E_REQUESTOUTOFRANGE;
\r
2308 if(responseCode == DCM_E_POSITIVERESPONSE)
\r
2310 Length = (pduRxData->SduLength - SID_AND_ALFID_LEN4) /SID_AND_ALFID_LEN4;
\r
2311 if(((Length*SID_AND_ALFID_LEN4) == (pduRxData->SduLength - SID_AND_ALFID_LEN4)) && (Length != 0))
\r
2313 if((Length + SourceLength) <= DCM_MAX_DDDSOURCE_NUMBER)
\r
2315 for(i = 0;(i < Length) && (responseCode == DCM_E_POSITIVERESPONSE);i++)
\r
2317 SourceDidNr = (((uint16)pduRxData->SduDataPtr[SID_AND_ALFID_LEN4 + i*SID_AND_ALFID_LEN4] << 8) & DCM_DID_HIGH_MASK) + (((uint16)pduRxData->SduDataPtr[(5 + i*SID_AND_ALFID_LEN4)]) & DCM_DID_LOW_MASK);
\r
2318 if(TRUE == lookupDid(SourceDidNr, &SourceDid))/*UDS_REQ_0x2C_4*/
\r
2320 if(DspCheckSessionLevel(SourceDid->DspDidInfoRef->DspDidAccess.DspDidRead->DspDidReadSessionRef))
\r
2322 if(DspCheckSecurityLevel(SourceDid->DspDidInfoRef->DspDidAccess.DspDidRead->DspDidReadSecurityLevelRef))
\r
2324 if(SourceDid->DspDidInfoRef->DspDidFixedLength == TRUE)
\r
2326 DidLength = SourceDid->DspDidSize;
\r
2330 if( SourceDid->DspDidReadDataLengthFnc != NULL)
\r
2332 SourceDid->DspDidReadDataLengthFnc(&DidLength);
\r
2335 if(DidLength != 0)
\r
2337 if((pduRxData->SduDataPtr[SID_AND_ALFID_LEN6 + i*SID_AND_ALFID_LEN4] != 0) &&
\r
2338 (pduRxData->SduDataPtr[SID_AND_ALFID_LEN7 + i*SID_AND_ALFID_LEN4] != 0) &&
\r
2339 (((uint16)pduRxData->SduDataPtr[SID_AND_ALFID_LEN6 + i*SID_AND_ALFID_LEN4] + (uint16)pduRxData->SduDataPtr[SID_AND_ALFID_LEN7 + i*SID_AND_ALFID_LEN4] - 1) <= DidLength))
\r
2341 DDid->DDDSource[i + SourceLength].formatOrPosition = pduRxData->SduDataPtr[SID_AND_ALFID_LEN6 + i*SID_AND_ALFID_LEN4];
\r
2342 DDid->DDDSource[i + SourceLength].Size = pduRxData->SduDataPtr[SID_AND_ALFID_LEN7 + i*SID_AND_ALFID_LEN4];
\r
2343 DDid->DDDSource[i + SourceLength].SourceAddressOrDid = SourceDid->DspDidIdentifier;
\r
2344 DDid->DDDSource[i + SourceLength].DDDTpyeID = DCM_DDD_SOURCE_DID;
\r
2348 /*UDS_REQ_0x2C_6*/
\r
2349 responseCode = DCM_E_REQUESTOUTOFRANGE;
\r
2355 /*UDS_REQ_0x2C_14*/
\r
2356 responseCode = DCM_E_REQUESTOUTOFRANGE;
\r
2361 responseCode = DCM_E_SECUTITYACCESSDENIED;
\r
2366 /*UDS_REQ_0x2C_19,DCM726*/
\r
2367 responseCode = DCM_E_REQUESTOUTOFRANGE;
\r
2373 responseCode = DCM_E_REQUESTOUTOFRANGE;
\r
2379 /*UDS_REQ_0x2C_13*/
\r
2380 responseCode = DCM_E_REQUESTOUTOFRANGE;
\r
2385 /*UDS_REQ_0x2C_11*/
\r
2386 responseCode = DCM_E_INCORRECTMESSAGELENGTHORINVALIDFORMAT;
\r
2388 if(responseCode == DCM_E_POSITIVERESPONSE)
\r
2390 DDid->DynamicallyDid = DDIdentifier;
\r
2391 pduTxData->SduDataPtr[1] = DCM_DDD_SUBFUNCTION_DEFINEBYDID;
\r
2394 if(responseCode == DCM_E_POSITIVERESPONSE)
\r
2396 pduTxData->SduDataPtr[1] = DCM_DDD_SUBFUNCTION_DEFINEBYDID;
\r
2399 return responseCode;
\r
2402 static Dcm_NegativeResponseCodeType dynamicallyDefineDataIdentifierbyAddress(uint16 DDIdentifier,const PduInfoType *pduRxData,PduInfoType *pduTxData)
\r
2404 uint8 LengthCount;
\r
2405 uint8 SourceCount;
\r
2407 uint8 AddressFormat;
\r
2408 uint8 MemorySizeFormat;
\r
2409 uint32 MemoryAddress = 0;
\r
2410 uint16 MemorySize = 0;
\r
2411 uint16 SourceLength = 0;
\r
2412 Dcm_DspDDDType *DDid = NULL;
\r
2413 const Dcm_DspMemoryIdInfo *SourceMemoryInfo = NULL;
\r
2415 Dcm_NegativeResponseCodeType responseCode = DCM_E_POSITIVERESPONSE;
\r
2417 if(FALSE == LookupDDD(DDIdentifier, (const Dcm_DspDDDType **)&DDid))
\r
2419 while((Num < DCM_MAX_DDD_NUMBER) && (dspDDD[Num].DynamicallyDid != 0 ))
\r
2423 if(Num >= DCM_MAX_DDD_NUMBER)
\r
2425 responseCode = DCM_E_REQUESTOUTOFRANGE;
\r
2429 DDid = &dspDDD[Num];
\r
2434 while((SourceLength < DCM_MAX_DDDSOURCE_NUMBER) && (DDid->DDDSource[SourceLength].formatOrPosition != 0 ))
\r
2438 if(SourceLength >= DCM_MAX_DDDSOURCE_NUMBER)
\r
2440 responseCode = DCM_E_REQUESTOUTOFRANGE;
\r
2443 if(responseCode == DCM_E_POSITIVERESPONSE)
\r
2445 AddressFormat = (uint8)pduRxData->SduDataPtr[4] & DCM_FORMAT_LOW_MASK;
\r
2446 MemorySizeFormat = (uint8)(pduRxData->SduDataPtr[4] >> 4) & DCM_FORMAT_LOW_MASK;
\r
2447 if((AddressFormat+MemorySizeFormat) != 0)
\r
2449 Length = (pduRxData->SduLength - SID_AND_ALFID_LEN5) / (AddressFormat + MemorySizeFormat);
\r
2451 if((AddressFormat != 0) && (MemorySizeFormat != 0) && ((SourceLength+Length) <= DCM_MAX_DDDSOURCE_NUMBER))
\r
2453 if((Length != 0)&&( Length * (AddressFormat + MemorySizeFormat) == (pduRxData->SduLength - 5) ))
\r
2455 for(LengthCount = 0; (LengthCount < Length) && (responseCode == DCM_E_POSITIVERESPONSE); LengthCount++)
\r
2457 MemoryAddress = 0;
\r
2458 for(SourceCount = 0; SourceCount < AddressFormat; SourceCount++)
\r
2460 MemoryAddress = MemoryAddress << 8;
\r
2461 MemoryAddress += (uint32)(pduRxData->SduDataPtr[5 + SourceCount + LengthCount * (AddressFormat + MemorySizeFormat)]);
\r
2464 /*take value of MemorySize out */
\r
2466 for(SourceCount = 0; SourceCount < MemorySizeFormat; SourceCount++)
\r
2468 MemorySize = MemorySize << 8;
\r
2469 MemorySize += (uint32)(pduRxData->SduDataPtr[5 + SourceCount + AddressFormat + LengthCount * (AddressFormat + MemorySizeFormat)]);
\r
2471 if(TRUE == lookupReadMemory(MemoryAddress, AddressFormat,MemorySize,&SourceMemoryInfo))
\r
2473 if(DspCheckSecurityLevel(SourceMemoryInfo->pReadMemoryInfo->pSecurityLevel) == TRUE)
\r
2475 DDid->DDDSource[LengthCount + SourceLength].formatOrPosition = pduRxData->SduDataPtr[4];
\r
2476 DDid->DDDSource[LengthCount + SourceLength].SourceAddressOrDid = MemoryAddress;
\r
2477 DDid->DDDSource[LengthCount + SourceLength].Size = MemorySize;
\r
2478 DDid->DDDSource[LengthCount + SourceLength].DDDTpyeID = DCM_DDD_SOURCE_ADDRESS;
\r
2479 /*UDS_REQ_0x2C_6*/
\r
2483 /*UDS_REQ_0x2C_19,DCM726*/
\r
2484 responseCode = DCM_E_SECUTITYACCESSDENIED;
\r
2489 /*UDS_REQ_0x2C_15,UDS_REQ_0x2C_16*/
\r
2490 responseCode = DCM_E_REQUESTOUTOFRANGE;
\r
2493 if(responseCode == DCM_E_POSITIVERESPONSE)
\r
2495 DDid->DynamicallyDid = DDIdentifier;
\r
2500 /*UDS_REQ_0x2C_11*/
\r
2501 responseCode = DCM_E_INCORRECTMESSAGELENGTHORINVALIDFORMAT;
\r
2506 /*UDS_REQ_0x2C_17, UDS_REQ_0x2C_18*/
\r
2507 responseCode = DCM_E_REQUESTOUTOFRANGE;
\r
2511 if(responseCode == DCM_E_POSITIVERESPONSE)
\r
2513 pduTxData->SduDataPtr[1] = DCM_DDD_SUBFUNCTION_DEFINEBYADDRESS;
\r
2516 return responseCode;
\r
2522 UDS Service 0x2c - Clear dynamically Did
\r
2524 static Dcm_NegativeResponseCodeType CleardynamicallyDid(uint16 DDIdentifier,const PduInfoType *pduRxData, PduInfoType * pduTxData)
\r
2526 /*UDS_REQ_0x2C_5*/
\r
2530 uint8 ClearNum = 0;
\r
2531 Dcm_DspDDDType *DDid = NULL;
\r
2532 Dcm_NegativeResponseCodeType responseCode = DCM_E_POSITIVERESPONSE;
\r
2534 if(pduRxData->SduLength == 4)
\r
2536 if(TRUE == LookupDDD(DDIdentifier, (const Dcm_DspDDDType **)&DDid))
\r
2539 if((checkPeriodicIdentifierBuffer(pduRxData->SduDataPtr[3], dspPDidRef.PDidNr, &position) == TRUE)&&(pduRxData->SduDataPtr[2] == 0xF2))
\r
2541 /*UDS_REQ_0x2C_9*/
\r
2542 responseCode = DCM_E_REQUESTOUTOFRANGE;
\r
2546 for(i = 1;i < DCM_MAX_DDD_NUMBER;i++)
\r
2548 if(0 == dspDDD[i].DynamicallyDid)
\r
2551 DDid->DynamicallyDid = dspDDD[ClearNum].DynamicallyDid;
\r
2552 dspDDD[ClearNum].DynamicallyDid = 0;
\r
2553 for(ClearCount = 0;ClearCount < DCM_MAX_DDDSOURCE_NUMBER;ClearCount++)
\r
2556 DDid->DDDSource[ClearCount].DDDTpyeID = dspDDD[ClearNum].DDDSource[ClearCount].DDDTpyeID;
\r
2557 DDid->DDDSource[ClearCount].formatOrPosition = dspDDD[ClearNum].DDDSource[ClearCount].formatOrPosition;
\r
2558 DDid->DDDSource[ClearCount].SourceAddressOrDid = dspDDD[ClearNum].DDDSource[ClearCount].SourceAddressOrDid;
\r
2559 DDid->DDDSource[ClearCount].Size = dspDDD[ClearNum].DDDSource[ClearCount].Size;
\r
2560 dspDDD[ClearNum].DDDSource[ClearCount].DDDTpyeID = 0;
\r
2561 dspDDD[ClearNum].DDDSource[ClearCount].formatOrPosition = 0;
\r
2562 dspDDD[ClearNum].DDDSource[ClearCount].SourceAddressOrDid = 0;
\r
2563 dspDDD[ClearNum].DDDSource[ClearCount].Size = 0;
\r
2572 responseCode = DCM_E_INCORRECTMESSAGELENGTHORINVALIDFORMAT;
\r
2574 if(responseCode == DCM_E_POSITIVERESPONSE)
\r
2576 pduTxData->SduDataPtr[1] = DCM_DDD_SUBFUNCTION_CLEAR;
\r
2577 pduTxData->SduLength = 2;
\r
2580 return responseCode;
\r
2583 void DspDynamicallyDefineDataIdentifier(const PduInfoType *pduRxData,PduInfoType *pduTxData)
\r
2585 /*UDS_REQ_0x2C_1,DCM 259*/
\r
2588 boolean PeriodicdUse = FALSE;
\r
2589 Dcm_NegativeResponseCodeType responseCode = DCM_E_POSITIVERESPONSE;
\r
2590 uint16 DDIdentifier = ((((uint16)pduRxData->SduDataPtr[2]) << 8) & DCM_DID_HIGH_MASK) + (pduRxData->SduDataPtr[3] & DCM_DID_LOW_MASK);
\r
2591 if(pduRxData->SduLength > 2)
\r
2593 /* Check if DDID equals 0xF2 or 0xF3 */
\r
2594 if((pduRxData->SduDataPtr[2] & 0xF2) == 0xF2)
\r
2596 switch(pduRxData->SduDataPtr[1]) /*UDS_REQ_0x2C_2,DCM 646*/
\r
2598 case DCM_DDD_SUBFUNCTION_DEFINEBYDID:
\r
2599 responseCode = dynamicallyDefineDataIdentifierbyDid(DDIdentifier,pduRxData,pduTxData);
\r
2601 case DCM_DDD_SUBFUNCTION_DEFINEBYADDRESS:
\r
2602 responseCode = dynamicallyDefineDataIdentifierbyAddress(DDIdentifier,pduRxData,pduTxData);
\r
2604 case DCM_DDD_SUBFUNCTION_CLEAR:
\r
2605 responseCode = CleardynamicallyDid(DDIdentifier,pduRxData,pduTxData);
\r
2608 responseCode = DCM_E_SUBFUNCTIONNOTSUPPORTED;
\r
2609 /*UDS_REQ_0x2C_10*/
\r
2615 responseCode = DCM_E_REQUESTOUTOFRANGE;
\r
2617 if(responseCode == DCM_E_POSITIVERESPONSE)
\r
2619 pduTxData->SduDataPtr[2] = pduRxData->SduDataPtr[2];
\r
2620 pduTxData->SduDataPtr[3] = pduRxData->SduDataPtr[3];
\r
2621 pduTxData->SduLength = 4;
\r
2624 else if((pduRxData->SduLength == 2)&&(pduRxData->SduDataPtr[1] == DCM_DDD_SUBFUNCTION_CLEAR))
\r
2626 /*UDS_REQ_0x2C_7*/
\r
2627 for(i = 0;i < DCM_MAX_DDD_NUMBER;i++)
\r
2629 if(checkPeriodicIdentifierBuffer((uint8)(dspDDD[i].DynamicallyDid & DCM_DID_LOW_MASK),dspPDidRef.PDidNr,&Position) == TRUE)
\r
2631 PeriodicdUse = TRUE;
\r
2634 if(PeriodicdUse == FALSE)
\r
2636 memset(dspDDD,0,sizeof(dspDDD));
\r
2637 pduTxData->SduDataPtr[1] = DCM_DDD_SUBFUNCTION_CLEAR;
\r
2638 pduTxData->SduLength = 2;
\r
2642 responseCode = DCM_E_REQUESTOUTOFRANGE;
\r
2647 /*UDS_REQ_0x2C_11*/
\r
2648 responseCode = DCM_E_INCORRECTMESSAGELENGTHORINVALIDFORMAT;
\r
2650 DsdDspProcessingDone(responseCode);
\r
2653 static Dcm_NegativeResponseCodeType DspIOControlReturnControlToECU(const Dcm_DspDidType *DidPtr,const PduInfoType *pduRxData,PduInfoType *pduTxData)
\r
2655 Dcm_NegativeResponseCodeType responseCode = DCM_E_POSITIVERESPONSE;
\r
2656 if(DidPtr->DspDidInfoRef->DspDidAccess.DspDidControl->DspDidReturnControlToEcu == TRUE)
\r
2658 if(pduRxData->SduLength > 4)
\r
2660 if(DidPtr->DspDidInfoRef->DspDidAccess.DspDidControl != NULL)
\r
2662 if(((DidPtr->DspDidControlRecordSize->DspDidControlRecordSize + 7) >> 3) == (pduRxData->SduLength - 4))
\r
2664 if(DidPtr->DspDidReturnControlToEcuFnc != NULL)
\r
2666 DidPtr->DspDidReturnControlToEcuFnc(NULL,&pduRxData->SduDataPtr[4],&pduTxData->SduDataPtr[4],&responseCode);
\r
2671 responseCode = DCM_E_REQUESTOUTOFRANGE;
\r
2676 responseCode = DCM_E_REQUESTOUTOFRANGE;
\r
2681 responseCode = DCM_E_REQUESTOUTOFRANGE;
\r
2686 if(DidPtr->DspDidReturnControlToEcuFnc != NULL)
\r
2689 if(DidPtr->DspDidControlRecordSize != NULL)
\r
2691 DidPtr->DspDidReturnControlToEcuFnc(NULL,NULL,&pduTxData->SduDataPtr[4],&responseCode);
\r
2692 pduTxData->SduLength = DidPtr->DspDidControlRecordSize->DspDidControlStatusRecordSize + 4;
\r
2696 responseCode = DCM_E_REQUESTOUTOFRANGE;
\r
2701 responseCode = DCM_E_REQUESTOUTOFRANGE;
\r
2707 responseCode = DCM_E_REQUESTOUTOFRANGE;
\r
2709 if(responseCode == DCM_E_POSITIVERESPONSE)
\r
2711 pduTxData->SduLength = DidPtr->DspDidControlRecordSize->DspDidControlStatusRecordSize + 4;
\r
2712 pduTxData->SduDataPtr[3] = DCM_RETURN_CONTROL_TO_ECU;
\r
2715 return responseCode;
\r
2718 static Dcm_NegativeResponseCodeType DspIOControlResetToDefault(const Dcm_DspDidType *DidPtr,const PduInfoType *pduRxData,PduInfoType *pduTxData)
\r
2720 Dcm_NegativeResponseCodeType responseCode = DCM_E_POSITIVERESPONSE;
\r
2721 if(DidPtr->DspDidInfoRef->DspDidAccess.DspDidControl->DspDidResetToDefault == TRUE)
\r
2723 if(pduRxData->SduLength > 4)
\r
2725 if(DidPtr->DspDidInfoRef->DspDidAccess.DspDidControl != NULL)
\r
2727 if(((DidPtr->DspDidControlRecordSize->DspDidControlRecordSize + 7) >> 3) == (pduRxData->SduLength - 4))
\r
2729 if(DidPtr->DspDidReturnControlToEcuFnc != NULL)
\r
2731 DidPtr->DspDidResetToDeaultFnc(NULL,&pduRxData->SduDataPtr[4],&pduTxData->SduDataPtr[4],&responseCode);
\r
2735 responseCode = DCM_E_REQUESTOUTOFRANGE;
\r
2740 responseCode = DCM_E_REQUESTOUTOFRANGE;
\r
2745 responseCode = DCM_E_REQUESTOUTOFRANGE;
\r
2750 if(DidPtr->DspDidResetToDeaultFnc != NULL)
\r
2753 if(DidPtr->DspDidControlRecordSize != NULL)
\r
2755 DidPtr->DspDidResetToDeaultFnc(NULL,NULL,&pduTxData->SduDataPtr[4],&responseCode);
\r
2756 pduTxData->SduLength = DidPtr->DspDidControlRecordSize->DspDidControlStatusRecordSize + 4;
\r
2760 responseCode = DCM_E_REQUESTOUTOFRANGE;
\r
2765 responseCode = DCM_E_REQUESTOUTOFRANGE;
\r
2771 responseCode = DCM_E_REQUESTOUTOFRANGE;
\r
2773 if(responseCode == DCM_E_POSITIVERESPONSE)
\r
2775 pduTxData->SduLength = DidPtr->DspDidControlRecordSize->DspDidControlStatusRecordSize+4;
\r
2776 pduTxData->SduDataPtr[3] = DCM_RESET_TO_DEFAULT;
\r
2778 return responseCode;
\r
2782 UDS Service 0x2F - IOControl Freeze Current State
\r
2784 static Dcm_NegativeResponseCodeType DspIOControlFreezeCurrentState(const Dcm_DspDidType *DidPtr,const PduInfoType *pduRxData,PduInfoType *pduTxData)
\r
2786 Dcm_NegativeResponseCodeType responseCode = DCM_E_POSITIVERESPONSE;
\r
2787 if(DidPtr->DspDidInfoRef->DspDidAccess.DspDidControl->DspDidFreezeCurrentState == TRUE)
\r
2789 if(pduRxData->SduLength > 4)
\r
2791 if(DidPtr->DspDidInfoRef->DspDidAccess.DspDidControl != NULL)
\r
2793 if(((DidPtr->DspDidControlRecordSize->DspDidControlRecordSize + 7) >> 3) == (pduRxData->SduLength - 4))
\r
2795 if(DidPtr->DspDidFreezeCurrentStateFnc != NULL)
\r
2797 DidPtr->DspDidFreezeCurrentStateFnc(NULL,&pduRxData->SduDataPtr[4],&pduTxData->SduDataPtr[4],&responseCode);
\r
2801 responseCode = DCM_E_REQUESTOUTOFRANGE;
\r
2806 responseCode = DCM_E_REQUESTOUTOFRANGE;
\r
2811 responseCode = DCM_E_REQUESTOUTOFRANGE;
\r
2816 if(DidPtr->DspDidFreezeCurrentStateFnc != NULL)
\r
2819 if(DidPtr->DspDidControlRecordSize != 0)
\r
2821 DidPtr->DspDidFreezeCurrentStateFnc(NULL,NULL,&pduTxData->SduDataPtr[4],&responseCode);
\r
2822 pduTxData->SduLength = DidPtr->DspDidControlRecordSize->DspDidControlStatusRecordSize + 4;
\r
2826 responseCode = DCM_E_REQUESTOUTOFRANGE;
\r
2831 responseCode = DCM_E_REQUESTOUTOFRANGE;
\r
2837 responseCode = DCM_E_REQUESTOUTOFRANGE;
\r
2839 if(responseCode == DCM_E_POSITIVERESPONSE)
\r
2841 pduTxData->SduLength = DidPtr->DspDidControlRecordSize->DspDidControlStatusRecordSize + 4;
\r
2842 pduTxData->SduDataPtr[3] = DCM_FREEZE_CURRENT_STATE;
\r
2845 return responseCode;
\r
2848 static Dcm_NegativeResponseCodeType DspIOControlShortTeamAdjustment(const Dcm_DspDidType *DidPtr,const PduInfoType *pduRxData,PduInfoType *pduTxData)
\r
2850 Dcm_NegativeResponseCodeType responseCode = DCM_E_POSITIVERESPONSE;
\r
2851 uint8 didControlOptionRecordSize = DidPtr->DspDidControlRecordSize->DspDidControlOptionRecordSize;
\r
2852 if(DidPtr->DspDidInfoRef->DspDidAccess.DspDidControl->DspDidShortTermAdjustment == TRUE)
\r
2854 if(pduRxData->SduLength > 4)
\r
2856 if(DidPtr->DspDidInfoRef->DspDidAccess.DspDidControl != NULL)
\r
2858 if(((((DidPtr->DspDidControlRecordSize->DspDidControlRecordSize + 7)) >> 3) + (didControlOptionRecordSize)) == (pduRxData->SduLength - 4))
\r
2860 if(DidPtr->DspDidShortTermAdjustmentFnc != NULL)
\r
2862 DidPtr->DspDidShortTermAdjustmentFnc(&pduRxData->SduDataPtr[4],&pduRxData->SduDataPtr[4 + didControlOptionRecordSize],&pduTxData->SduDataPtr[4],&responseCode);
\r
2866 responseCode = DCM_E_REQUESTOUTOFRANGE;
\r
2869 else if((didControlOptionRecordSize) == (pduRxData->SduLength - 4))
\r
2871 if(DidPtr->DspDidShortTermAdjustmentFnc != NULL)
\r
2873 DidPtr->DspDidShortTermAdjustmentFnc(&pduRxData->SduDataPtr[4],NULL,&pduTxData->SduDataPtr[4],&responseCode);
\r
2877 responseCode = DCM_E_REQUESTOUTOFRANGE;
\r
2882 responseCode = DCM_E_REQUESTOUTOFRANGE;
\r
2887 responseCode = DCM_E_REQUESTOUTOFRANGE;
\r
2892 responseCode = DCM_E_REQUESTOUTOFRANGE;
\r
2897 responseCode = DCM_E_REQUESTOUTOFRANGE;
\r
2899 if(responseCode == DCM_E_POSITIVERESPONSE)
\r
2901 pduTxData->SduLength = DidPtr->DspDidControlRecordSize->DspDidControlStatusRecordSize + 4;
\r
2902 pduTxData->SduDataPtr[3] = DCM_SHORT_TERM_ADJUSTMENT;
\r
2905 return responseCode;
\r
2908 void DspIOControlByDataIdentifier(const PduInfoType *pduRxData,PduInfoType *pduTxData)
\r
2911 const Dcm_DspDidType *DidPtr = NULL;
\r
2912 Dcm_NegativeResponseCodeType responseCode = DCM_E_POSITIVERESPONSE;
\r
2913 didNr = (pduRxData->SduDataPtr[1] << 8 & DCM_DID_HIGH_MASK) + (pduRxData->SduDataPtr[2] & DCM_DID_LOW_MASK);
\r
2914 if(pduRxData->SduLength > 3)
\r
2916 if(TRUE == lookupDid(didNr, &DidPtr))
\r
2918 if(FALSE == DidPtr->DspDidUsePort)
\r
2920 if(NULL != DidPtr->DspDidInfoRef->DspDidAccess.DspDidControl)
\r
2922 if(TRUE == DspCheckSessionLevel(DidPtr->DspDidInfoRef->DspDidAccess.DspDidControl->DspDidControlSessionRef))
\r
2924 if(TRUE == DspCheckSecurityLevel(DidPtr->DspDidInfoRef->DspDidAccess.DspDidControl->DspDidControlSecurityLevelRef))
\r
2926 switch(pduRxData->SduDataPtr[3])
\r
2928 case DCM_RETURN_CONTROL_TO_ECU:
\r
2929 responseCode = DspIOControlReturnControlToECU(DidPtr,pduRxData,pduTxData);
\r
2931 case DCM_RESET_TO_DEFAULT:
\r
2932 responseCode = DspIOControlResetToDefault(DidPtr,pduRxData,pduTxData);
\r
2934 case DCM_FREEZE_CURRENT_STATE:
\r
2935 responseCode = DspIOControlFreezeCurrentState(DidPtr,pduRxData,pduTxData);
\r
2937 case DCM_SHORT_TERM_ADJUSTMENT:
\r
2938 responseCode = DspIOControlShortTeamAdjustment(DidPtr,pduRxData,pduTxData);
\r
2941 responseCode = DCM_E_REQUESTOUTOFRANGE;
\r
2948 responseCode = DCM_E_SECUTITYACCESSDENIED;
\r
2953 responseCode = DCM_E_REQUESTOUTOFRANGE;
\r
2958 responseCode = DCM_E_REQUESTOUTOFRANGE;
\r
2963 /* if UsePort == True, NRC 0x10 */
\r
2964 responseCode = DCM_E_GENERALREJECT;
\r
2969 responseCode = DCM_E_REQUESTOUTOFRANGE;
\r
2974 responseCode = DCM_E_INCORRECTMESSAGELENGTHORINVALIDFORMAT;
\r
2976 if(responseCode == DCM_E_POSITIVERESPONSE)
\r
2978 pduTxData->SduDataPtr[1] = pduRxData->SduDataPtr[1];
\r
2979 pduTxData->SduDataPtr[2] = pduRxData->SduDataPtr[2];
\r
2981 DsdDspProcessingDone(responseCode);
\r