#define SID_AND_ALFID_LEN6 0x6\r
#define SID_AND_ALFID_LEN7 0x7\r
\r
+/* == Parser macros == */\r
+/* General */\r
+#define SID_INDEX 0\r
+#define SID_LEN 1\r
+#define SF_INDEX 1\r
+#define SF_LEN 1\r
+/* Read/WriteMemeoryByAddress */\r
+#define ALFID_INDEX 1\r
+#define ALFID_LEN 1\r
+#define ADDR_START_INDEX 2\r
+/* DynamicallyDefineDataByIdentifier */\r
+#define DDDDI_INDEX 2\r
+#define DDDDI_LEN 2\r
+#define DYNDEF_ALFID_INDEX 4\r
+#define DYNDEF_ADDRESS_START_INDEX 5\r
+\r
#define BYTES_TO_DTC(hb, mb, lb) (((uint32)(hb) << 16) | ((uint32)(mb) << 8) | (uint32)(lb))\r
#define DTC_HIGH_BYTE(dtc) (((uint32)(dtc) >> 16) & 0xFFu)\r
#define DTC_MID_BYTE(dtc) (((uint32)(dtc) >> 8) & 0xFFu)\r
#define DTC_LOW_BYTE(dtc) ((uint32)(dtc) & 0xFFu)\r
\r
+typedef enum {\r
+ DCM_READ_MEMORY = 0,\r
+ DCM_WRITE_MEMORY,\r
+} DspMemoryServiceType;\r
\r
typedef struct {\r
boolean resetPending;\r
\r
typedef struct{\r
uint8 formatOrPosition; /*note the formate of address and size*/\r
+ uint8 memoryIdentifier;\r
uint32 SourceAddressOrDid; /*note the memory address */\r
uint16 Size; /*note the memory size */\r
Dcm_DspDDDTpyeID DDDTpyeID;\r
* * static Function\r
*/\r
\r
-static boolean lookupReadMemory(uint32 memoryAddress,\r
- uint8 memoryAddressFormat,\r
- uint32 memorySize,\r
- const Dcm_DspMemoryIdInfo **MemoryPtr);\r
-\r
static boolean LookupDDD(uint16 didNr, const Dcm_DspDDDType **DDid);\r
-\r
-static boolean checkWriteMemoryByAddress(boolean useId,\r
- uint32 memoryAddress,\r
- uint8 memoryAddressFormat,\r
- uint32 memorySize,\r
- const Dcm_DspMemoryIdInfo *dspMemory);\r
-\r
+static Dcm_NegativeResponseCodeType checkAddressRange(DspMemoryServiceType serviceType, uint8 memoryIdentifier, uint32 memoryAddress, uint32 length);\r
+static const Dcm_DspMemoryRangeInfo* findRange(const Dcm_DspMemoryRangeInfo *memoryRangePtr, uint32 memoryAddress, uint32 length);\r
+static Dcm_NegativeResponseCodeType writeMemoryData(Dcm_OpStatusType* OpStatus, uint8 memoryIdentifier, uint32 MemoryAddress, uint32 MemorySize, uint8 *SourceData);\r
\r
/*\r
* end \r
/* clear periodic send buffer */\r
memset(&dspPDidRef,0,sizeof(dspPDidRef));\r
/* clear dynamically Did buffer */\r
- memset(&dspDDD[0],0,sizeof(dspDDD)); \r
+ memset(&dspDDD[0],0,sizeof(dspDDD));\r
}\r
\r
void DspMemoryMainFunction(void)\r
void DspPeriodicDIDMainFunction()\r
{\r
uint8 i;\r
+ boolean sentResponseThisLoop = FALSE;\r
+\r
for(i = 0;i < dspPDidRef.PDidNr; i++)\r
{\r
if(dspPDidRef.dspPDid[i].PDidTxCounterNumber > dspPDidRef.dspPDid[i].PDidTxCounter)\r
}\r
else\r
{\r
- dspPDidRef.dspPDid[i].PDidTxCounter = 0;\r
- /*AutoSar DCM 8.10.5 */\r
- DslInternal_ResponseOnOneDataByPeriodicId(dspPDidRef.dspPDid[i].PeriodicDid);\r
+ if( sentResponseThisLoop == FALSE ) {\r
+ if (E_OK == DslInternal_ResponseOnOneDataByPeriodicId(dspPDidRef.dspPDid[i].PeriodicDid)){\r
+ dspPDidRef.dspPDid[i].PDidTxCounter = 0;\r
+ /*AutoSar DCM 8.10.5 */\r
+ sentResponseThisLoop = TRUE;\r
+ }\r
+ }\r
+ else {\r
+ /* Don't do anything - PDid will be sent next loop */\r
+ }\r
} \r
}\r
}\r
uint8 SID;\r
uint8 reportType;\r
uint8 dtcStatusAvailabilityMask;\r
- dtcAndStatusRecordType *dtcAndStatusRecord;\r
+ dtcAndStatusRecordType dtcAndStatusRecord[];\r
} TxDataType;\r
\r
// Setup the DTC filter\r
//lint -e{715, 838, 818} Symbol not referenced, responseCode not used, txData should be const\r
static Dcm_NegativeResponseCodeType udsReadDtcInfoSub_0x04(const PduInfoType *pduRxData, PduInfoType *pduTxData)\r
{\r
+ // 1. Only consider Negative Response 0x10\r
+\r
Dcm_NegativeResponseCodeType responseCode = DCM_E_POSITIVERESPONSE;\r
+ Dem_DTCKindType DtcType = 0;\r
+ Dem_DTCOriginType DtcOrigin = 0;\r
+ uint32 DtcNumber = 0;\r
+ uint8 RecordNumber = 0;\r
+ uint8 SizeOfTxBuf = pduTxData->SduLength;\r
+ uint8 AvailableBufSize = 0;\r
+ uint8 RecNumOffset = 0;\r
+ uint16 index = 0;\r
+ uint16 EventIndex =0;\r
+ uint16 FFIdNumber = 0;\r
+ Dem_ReturnGetFreezeFrameDataByDTCType GetFFbyDtcReturnCode = DEM_GET_FFDATABYDTC_OK;\r
+ Dem_ReturnGetStatusOfDTCType GetStatusOfDtc = DEM_STATUS_OK;\r
+ Dem_EventStatusExtendedType DtcStatus = 0;\r
+ Dem_EventParameterType *pEventParaTemp = NULL;\r
+\r
+ // Now let's assume DTC has 3 bytes.\r
+ DtcNumber = (((uint32)pduRxData->SduDataPtr[2])<<16) +\r
+ (((uint32)pduRxData->SduDataPtr[3])<<8) +\r
+ ((uint32)pduRxData->SduDataPtr[4]);\r
+\r
+ RecordNumber = pduRxData->SduDataPtr[5];\r
+\r
+ for (EventIndex = 0; DEM_Config.ConfigSet->EventParameter[EventIndex].Arc_EOL != TRUE; EventIndex++){\r
+ // search each event linked to this DTC\r
+ if (DEM_Config.ConfigSet->EventParameter[EventIndex].DTCClassRef->DTC == DtcNumber){\r
+ pEventParaTemp = (Dem_EventParameterType *)(&DEM_Config.ConfigSet->EventParameter[EventIndex]);\r
+ }\r
+ else {\r
+ pEventParaTemp = NULL;\r
+ }\r
+\r
+ if (pEventParaTemp != NULL) {\r
+ DtcType = pEventParaTemp->DTCClassRef->DTCKind;\r
+ //DtcOrigin = pEventParaTemp->EventClass->EventDestination[?];\r
+ // now use DEM_DTC_ORIGIN_PRIMARY_MEMORY as default.\r
+ DtcOrigin = DEM_DTC_ORIGIN_PRIMARY_MEMORY;\r
+ pduTxData->SduDataPtr[6 + RecNumOffset] = RecordNumber;\r
+\r
+ // get Dids' number\r
+ for (index = 0; pEventParaTemp->FreezeFrameClassRef[index] != NULL; index++){\r
+ if (pEventParaTemp->FreezeFrameClassRef[index]->FFRecordNumber == RecordNumber) {\r
+ // Calculate the Number of Dids in FF\r
+ for (FFIdNumber = 0; pEventParaTemp->FreezeFrameClassRef[index]->FFIdClassRef[FFIdNumber]->Arc_EOL != FALSE; FFIdNumber++) {\r
+ ;\r
+ }\r
+ }\r
+ }\r
+ pduTxData->SduDataPtr[7 + RecNumOffset] = FFIdNumber;\r
\r
- // TODO: Not supported yet\r
- responseCode = DCM_E_REQUESTOUTOFRANGE;\r
+ // get FF data\r
+ AvailableBufSize = SizeOfTxBuf - 7 - RecNumOffset;\r
+ GetFFbyDtcReturnCode = Dem_GetFreezeFrameDataByDTC(DtcNumber, DtcType, DtcOrigin,\r
+ RecordNumber, &pduTxData->SduDataPtr[8 + RecNumOffset], &AvailableBufSize);\r
+ if (GetFFbyDtcReturnCode != DEM_GET_FFDATABYDTC_OK){\r
+ break;\r
+ }\r
+ RecNumOffset = RecNumOffset + AvailableBufSize;\r
+ pduTxData->SduLength = 8 + RecNumOffset;\r
+ }\r
+ }\r
+\r
+ // Negative response\r
+ switch (GetFFbyDtcReturnCode) {\r
+ case DEM_GET_FFDATABYDTC_OK:\r
+ break;\r
+ default:\r
+ responseCode = DCM_E_GENERALREJECT;\r
+ return responseCode;\r
+ }\r
\r
+ GetStatusOfDtc = Dem_GetStatusOfDTC(DtcNumber, DtcType, DtcOrigin, &DtcStatus); /** @req DEM212 */\r
+ switch (GetStatusOfDtc) {\r
+ case DEM_STATUS_OK:\r
+ break;\r
+ default:\r
+ responseCode = DCM_E_GENERALREJECT;\r
+ return responseCode;\r
+ }\r
+\r
+\r
+ // Positive response\r
+ // See ISO 14229(2006) Table 254\r
+ pduTxData->SduDataPtr[0] = 0x59; // positive response\r
+ pduTxData->SduDataPtr[1] = 0x04; // subid\r
+ pduTxData->SduDataPtr[2] = pduRxData->SduDataPtr[2]; // DTC\r
+ pduTxData->SduDataPtr[3] = pduRxData->SduDataPtr[3];\r
+ pduTxData->SduDataPtr[4] = pduRxData->SduDataPtr[4];\r
+ pduTxData->SduDataPtr[5] = (uint8)DtcStatus; //status\r
return responseCode;\r
}\r
\r
dspDid++;\r
}\r
\r
- if (!dspDid->Arc_EOL) {\r
+ if (!dspDid->Arc_EOL && (!dspDid->DspDidInfoRef->DspDidDynamicllyDefined)) {\r
didFound = TRUE;\r
*didPtr = dspDid;\r
}\r
{\r
uint8 i;\r
uint8 dataCount;\r
- uint8 AddressFormat;\r
uint16 SourceDataLength = 0;\r
- const Dcm_DspMemoryIdInfo *SourceMemoryInfoptr = NULL;\r
const Dcm_DspDidType *SourceDidPtr = NULL;\r
Dcm_NegativeResponseCodeType responseCode = DCM_E_POSITIVERESPONSE;\r
*Length = 0;\r
{\r
if(PDidPtr->DDDSource[i].DDDTpyeID == DCM_DDD_SOURCE_ADDRESS)\r
{\r
-\r
- AddressFormat = PDidPtr->DDDSource[i].formatOrPosition&DCM_FORMAT_HIGH_MASK >> 4;\r
- if(TRUE == lookupReadMemory(PDidPtr->DDDSource[i].SourceAddressOrDid,AddressFormat,\r
- PDidPtr->DDDSource[i].Size, &SourceMemoryInfoptr))\r
- {\r
- if(DspCheckSecurityLevel(SourceMemoryInfoptr->pReadMemoryInfo->pSecurityLevel) != TRUE)\r
- {\r
- responseCode = DCM_E_SECUTITYACCESSDENIED;\r
- }\r
- }\r
- else\r
- {\r
- responseCode = DCM_E_REQUESTOUTOFRANGE;\r
- }\r
- if(responseCode == DCM_E_POSITIVERESPONSE)\r
- {\r
- Dcm_ReadMemory(DCM_INITIAL,SourceMemoryInfoptr->MemoryIdValue,\r
+ responseCode = checkAddressRange(DCM_READ_MEMORY, PDidPtr->DDDSource[i].memoryIdentifier, PDidPtr->DDDSource[i].SourceAddressOrDid, PDidPtr->DDDSource[i].Size);\r
+ if( responseCode == DCM_E_POSITIVERESPONSE ) {\r
+ Dcm_ReadMemory(DCM_INITIAL,PDidPtr->DDDSource[i].memoryIdentifier,\r
PDidPtr->DDDSource[i].SourceAddressOrDid,\r
PDidPtr->DDDSource[i].Size,\r
(Data + *Length));\r
responseCode = readDidData(didPtr, pduTxData, &txPos);\r
}\r
\r
- else if(LookupDDD(didNr,&DDidPtr) == TRUE)\r
+ else if(LookupDDD(didNr,(const Dcm_DspDDDType **)&DDidPtr) == TRUE)\r
{\r
/*DCM 651,DCM 652*/\r
pduTxData->SduDataPtr[txPos] = (DDidPtr->DynamicallyDid>>8) & 0xFF;\r
\r
if (result == E_OK) {\r
if (didLen == writeDidLen) { /** @req DCM473 */\r
- result = didPtr->DspDidWriteDataFnc(&pduRxData->SduDataPtr[3], (uint8)didLen, &errorCode); /** @req DCM395 */\r
- if ((result != E_OK) || (errorCode != DCM_E_POSITIVERESPONSE)) {\r
+ result = didPtr->DspDidWriteDataFnc(&pduRxData->SduDataPtr[3], (uint8)didLen, &responseCode); /** @req DCM395 */\r
+ if( result != E_OK && responseCode == DCM_E_POSITIVERESPONSE ) {\r
responseCode = DCM_E_CONDITIONSNOTCORRECT;\r
}\r
}\r
}\r
}\r
\r
-\r
-/* REVIEW JB 2012-06-05: Removed iSoft function header - please don't add iSoft specific headers in the future */\r
-static boolean CheckReadMemoryByAddress( boolean useId,uint32 memoryAddress,\r
- uint8 memoryAddressFormat,\r
- uint32 memorySize,\r
- const Dcm_DspMemoryIdInfo *dspMemory)\r
-{\r
- boolean ret = FALSE;\r
- uint8 MemoryId;\r
-\r
- if(useId == FALSE)\r
- {\r
- /*@req DCM493*/\r
- if((memoryAddress >= dspMemory->pReadMemoryInfo->MemoryAddressLow)\r
- && (memoryAddress <= dspMemory->pReadMemoryInfo->MemoryAddressHigh)\r
- && (memoryAddress + memorySize - 1 <= dspMemory->pReadMemoryInfo->MemoryAddressHigh))\r
- {\r
- ret = TRUE;\r
- }\r
- }\r
- else\r
- {\r
- MemoryId = (uint8)(memoryAddress >> ((memoryAddressFormat - 1)*8));\r
- memoryAddress = (uint32)(memoryAddress & DCM_MEMORY_ADDRESS_MASK);\r
-\r
- if((MemoryId == dspMemory->MemoryIdValue)&&\r
- (memoryAddress >= dspMemory->pReadMemoryInfo->MemoryAddressLow)\r
- && (memoryAddress <= dspMemory->pReadMemoryInfo->MemoryAddressHigh)\r
- && (memoryAddress + memorySize - 1 <= dspMemory->pReadMemoryInfo->MemoryAddressHigh))\r
- {\r
- ret = TRUE;\r
- }\r
- }\r
- \r
- return ret;\r
-}\r
-\r
-static boolean lookupReadMemory(uint32 memoryAddress,\r
- uint8 memoryAddressFormat,\r
- uint32 memorySize,\r
- const Dcm_DspMemoryIdInfo **MemoryInfoPtr)\r
-{\r
- uint8 i;\r
- boolean memoryFound = FALSE;\r
- const Dcm_DspMemoryIdInfo *dspMemoryInfo = DCM_Config.Dsp->DspMemory->DspMemoryIdInfo;\r
-\r
- for(i = 0; (dspMemoryInfo->Arc_EOL == FALSE) && (memoryFound == FALSE); i++)\r
- {\r
- if(TRUE == CheckReadMemoryByAddress(DCM_Config.Dsp->DspMemory->DcmDspUseMemoryId,memoryAddress,memoryAddressFormat,memorySize,dspMemoryInfo))\r
- {\r
- memoryFound = TRUE;\r
- }\r
- else\r
- {\r
- (Dcm_DspMemoryIdInfo *)dspMemoryInfo++;\r
- }\r
- }\r
- if (memoryFound == TRUE)\r
- {\r
- *MemoryInfoPtr = dspMemoryInfo;\r
- }\r
- \r
- return memoryFound;\r
-}\r
-\r
static Dcm_NegativeResponseCodeType readMemoryData( Dcm_OpStatusType *OpStatus,\r
- const Dcm_DspMemoryIdInfo *MemoryPtr,\r
+ uint8 memoryIdentifier,\r
uint32 MemoryAddress,\r
uint32 MemorySize,\r
PduInfoType *pduTxData)\r
{\r
Dcm_ReturnReadMemoryType ReadRet;\r
Dcm_NegativeResponseCodeType responseCode = DCM_E_POSITIVERESPONSE;\r
- ReadRet = Dcm_ReadMemory(*OpStatus,MemoryPtr->MemoryIdValue,\r
+ ReadRet = Dcm_ReadMemory(*OpStatus,memoryIdentifier,\r
MemoryAddress,\r
MemorySize,\r
&pduTxData->SduDataPtr[1]);\r
return responseCode;\r
}\r
\r
-/*@req Dcm442,DCM492*/\r
-void DspUdsReadMemoryByAddress(const PduInfoType *pduRxData, PduInfoType *pduTxData)\r
-{\r
- typedef struct{\r
- uint32 MemoryAddressStart; /* low address of a memory block to read or write*/\r
- uint32 MemoryIdValue; /* memory ID to read or write uint used by parameter */\r
- const Dcm_DspMemoryIdInfo *MemoryIdConfigPtr; \r
- Dcm_NegativeResponseCodeType ResponseCode; \r
- uint8 MemorySizeFormat;\r
- uint8 MemoryAddressFormat;\r
- uint32 MemorySize;\r
- uint16 MessageLength;\r
- }DspUdsReadMemoryByAddressType; /*the typed used for SID read memory by address*/\r
- uint8 i;\r
- DspUdsReadMemoryByAddressType dspReadMemoryByAddress;\r
- Dcm_OpStatusType OpStatus = 0;\r
- dspReadMemoryByAddress.MemoryAddressStart = 0;\r
- dspReadMemoryByAddress.MemorySize = 0;\r
- dspReadMemoryByAddress.MemoryIdConfigPtr = NULL;\r
- dspReadMemoryByAddress.ResponseCode = DCM_E_POSITIVERESPONSE;\r
- dspReadMemoryByAddress.MemorySizeFormat = ((uint8)(pduRxData->SduDataPtr[1] & DCM_FORMAT_HIGH_MASK)) >> 4; /*@req UDS_REQ_0x23_1 & UDS_REQ_0x23_5*/\r
- dspReadMemoryByAddress.MemoryAddressFormat = ((uint8)(pduRxData->SduDataPtr[1])) & 0x0Fu; /*@req UDS_REQ_0x23_1 & UDS_REQ_0x23_5*/\r
-\r
- if((dspReadMemoryByAddress.MemoryAddressFormat == 0)||(dspReadMemoryByAddress.MemorySizeFormat == 0))\r
- {\r
- dspReadMemoryByAddress.ResponseCode = DCM_E_REQUESTOUTOFRANGE; /*UDS_REQ_0x23_10*/\r
- }\r
- else\r
+static Dcm_NegativeResponseCodeType checkAddressRange(DspMemoryServiceType serviceType, uint8 memoryIdentifier, uint32 memoryAddress, uint32 length) {\r
+ const Dcm_DspMemoryIdInfo *dspMemoryInfo = DCM_Config.Dsp->DspMemory->DspMemoryIdInfo;\r
+ const Dcm_DspMemoryRangeInfo *memoryRangeInfo = NULL;\r
+ Dcm_NegativeResponseCodeType diagResponseCode = DCM_E_REQUESTOUTOFRANGE;\r
+\r
+ for( ; (dspMemoryInfo->Arc_EOL == FALSE) && (memoryRangeInfo == NULL); dspMemoryInfo++ )\r
{\r
- dspReadMemoryByAddress.MessageLength = (uint16)(dspReadMemoryByAddress.MemoryAddressFormat + dspReadMemoryByAddress.MemorySizeFormat + SID_AND_ALFID_LEN2);\r
- if(dspReadMemoryByAddress.MessageLength == (uint16)(pduRxData->SduLength))\r
+ if( ((TRUE == DCM_Config.Dsp->DspMemory->DcmDspUseMemoryId) && (dspMemoryInfo->MemoryIdValue == memoryIdentifier))\r
+ || (FALSE == DCM_Config.Dsp->DspMemory->DcmDspUseMemoryId) )\r
{\r
- /*take start address out */\r
- for(i = 0; i < dspReadMemoryByAddress.MemoryAddressFormat; i++)\r
+ if( DCM_READ_MEMORY == serviceType )\r
+ {\r
+ memoryRangeInfo = findRange( dspMemoryInfo->pReadMemoryInfo, memoryAddress, length );\r
+ }\r
+ else\r
{\r
- dspReadMemoryByAddress.MemoryAddressStart <<= 8;\r
- dspReadMemoryByAddress.MemoryAddressStart += (uint32)(pduRxData->SduDataPtr[SID_AND_ALFID_LEN2 + i]);\r
+ memoryRangeInfo = findRange( dspMemoryInfo->pWriteMemoryInfo, memoryAddress, length );\r
}\r
\r
- /*take value of MemorySize out */\r
- for(i = 0; i < dspReadMemoryByAddress.MemorySizeFormat; i++)\r
+ if( NULL != memoryRangeInfo )\r
{\r
- dspReadMemoryByAddress.MemorySize <<= 8;\r
- dspReadMemoryByAddress.MemorySize += (uint32)(pduRxData->SduDataPtr[2 + i + dspReadMemoryByAddress.MemoryAddressFormat]);\r
+ if( DspCheckSecurityLevel(memoryRangeInfo->pSecurityLevel) )\r
+ {\r
+ /* Range is ok */\r
+ diagResponseCode = DCM_E_POSITIVERESPONSE;\r
+ }\r
+ else\r
+ {\r
+ diagResponseCode = DCM_E_SECUTITYACCESSDENIED;\r
+ }\r
}\r
- if(dspReadMemoryByAddress.MemorySize < DCM_PROTOCAL_TP_MAX_LENGTH)\r
+ else {\r
+ /* Range was not configured for read/write */\r
+ diagResponseCode = DCM_E_REQUESTOUTOFRANGE;\r
+ }\r
+ }\r
+ else {\r
+ /* No memory with this id found */\r
+ diagResponseCode = DCM_E_REQUESTOUTOFRANGE;\r
+ }\r
+ }\r
+ return diagResponseCode;\r
+}\r
+\r
+static const Dcm_DspMemoryRangeInfo* findRange(const Dcm_DspMemoryRangeInfo *memoryRangePtr, uint32 memoryAddress, uint32 length)\r
+{\r
+ const Dcm_DspMemoryRangeInfo *memoryRange = NULL;\r
+\r
+ for( ; (memoryRangePtr->Arc_EOL == FALSE) && (memoryRange == NULL); memoryRangePtr++ )\r
+ {\r
+ /*@req DCM493*/\r
+ if((memoryAddress >= memoryRangePtr->MemoryAddressLow)\r
+ && (memoryAddress <= memoryRangePtr->MemoryAddressHigh)\r
+ && (memoryAddress + length - 1 <= memoryRangePtr->MemoryAddressHigh))\r
+ {\r
+ memoryRange = memoryRangePtr;\r
+ }\r
+ }\r
+\r
+ return memoryRange;\r
+}\r
+\r
+void DspUdsWriteMemoryByAddress(const PduInfoType *pduRxData, PduInfoType *pduTxData)\r
+{\r
+ Dcm_NegativeResponseCodeType diagResponseCode;\r
+ uint8 sizeFormat;\r
+ uint8 addressFormat;\r
+ uint32 memoryAddress = 0;\r
+ uint32 length = 0;\r
+ uint8 i;\r
+ uint8 memoryIdentifier = 0; /* Should be 0 if DcmDspUseMemoryId == FALSE */\r
+ Dcm_OpStatusType OpStatus;\r
+ uint8 addressOffset;\r
+\r
+ if( pduRxData->SduLength > ALFID_INDEX )\r
+ {\r
+ sizeFormat = ((uint8)(pduRxData->SduDataPtr[ALFID_INDEX] & DCM_FORMAT_HIGH_MASK)) >> 4; /*@req UDS_REQ_0x23_1 & UDS_REQ_0x23_5*/;\r
+ addressFormat = ((uint8)(pduRxData->SduDataPtr[ALFID_INDEX])) & DCM_FORMAT_LOW_MASK; /*@req UDS_REQ_0x23_1 & UDS_REQ_0x23_5*/;\r
+ if((addressFormat != 0) && (sizeFormat != 0))\r
+ {\r
+ if(addressFormat + sizeFormat + SID_LEN + ALFID_LEN <= pduRxData->SduLength)\r
{\r
- if(TRUE == lookupReadMemory(dspReadMemoryByAddress.MemoryAddressStart,\r
- dspReadMemoryByAddress.MemoryAddressFormat,\r
- dspReadMemoryByAddress.MemorySize,\r
- &dspReadMemoryByAddress.MemoryIdConfigPtr))\r
+ if( TRUE == DCM_Config.Dsp->DspMemory->DcmDspUseMemoryId ) {\r
+ memoryIdentifier = pduRxData->SduDataPtr[ADDR_START_INDEX];\r
+ addressOffset = 1;\r
+ }\r
+ else {\r
+ addressOffset = 0;\r
+ }\r
+\r
+ /* Parse address */\r
+ for(i = addressOffset; i < addressFormat; i++)\r
{\r
- if (DspCheckSecurityLevel(dspReadMemoryByAddress.MemoryIdConfigPtr->pReadMemoryInfo->pSecurityLevel) == TRUE)\r
- {\r
- dspReadMemoryByAddress.ResponseCode = readMemoryData(&OpStatus,dspReadMemoryByAddress.MemoryIdConfigPtr,\r
- dspReadMemoryByAddress.MemoryAddressStart,\r
- dspReadMemoryByAddress.MemorySize,pduTxData);/*@req UDS_REQ_0x23_9*/\r
- \r
- }\r
- else\r
+ memoryAddress <<= 8;\r
+ memoryAddress += (uint32)(pduRxData->SduDataPtr[ADDR_START_INDEX + i]);\r
+ }\r
+\r
+ /* Parse size */\r
+ for(i = 0; i < sizeFormat; i++)\r
+ {\r
+ length <<= 8;\r
+ length += (uint32)(pduRxData->SduDataPtr[ADDR_START_INDEX + addressFormat + i]);\r
+ }\r
+\r
+ if( addressFormat + sizeFormat + SID_LEN + ALFID_LEN + length == pduRxData->SduLength )\r
+ {\r
+\r
+ diagResponseCode = checkAddressRange(DCM_WRITE_MEMORY, memoryIdentifier, memoryAddress, length);\r
+ if( DCM_E_POSITIVERESPONSE == diagResponseCode )\r
{\r
- dspReadMemoryByAddress.ResponseCode = DCM_E_SECUTITYACCESSDENIED;/*@req UDS_REQ_0x23_11,@req DCM494*/\r
+ diagResponseCode = writeMemoryData(&OpStatus, memoryIdentifier, memoryAddress, length,\r
+ &pduRxData->SduDataPtr[SID_LEN + ALFID_LEN + addressFormat + sizeFormat]);\r
}\r
+\r
}\r
else\r
{\r
- dspReadMemoryByAddress.ResponseCode = DCM_E_REQUESTOUTOFRANGE; /*@req UDS_REQ_0x23_7,UDS_REQ_0x23_8*/\r
+ diagResponseCode = DCM_E_INCORRECTMESSAGELENGTHORINVALIDFORMAT;\r
}\r
}\r
else\r
{\r
- dspReadMemoryByAddress.ResponseCode = DCM_E_REQUESTOUTOFRANGE;\r
+ diagResponseCode = DCM_E_INCORRECTMESSAGELENGTHORINVALIDFORMAT;\r
}\r
}\r
else\r
{\r
- dspReadMemoryByAddress.ResponseCode = DCM_E_INCORRECTMESSAGELENGTHORINVALIDFORMAT; /*@req UDS_REQ_0x23_6*/\r
+ diagResponseCode = DCM_E_REQUESTOUTOFRANGE; /*UDS_REQ_0x23_10*/\r
}\r
}\r
- if(DCM_E_POSITIVERESPONSE == dspReadMemoryByAddress.ResponseCode)\r
+ else\r
{\r
- pduTxData->SduLength = 1 + dspReadMemoryByAddress.MemorySize;\r
- if(OpStatus == DCM_READ_PENDING)\r
- {\r
- dspMemoryState = DCM_MEMORY_READ;\r
- }\r
- else\r
+ diagResponseCode = DCM_E_INCORRECTMESSAGELENGTHORINVALIDFORMAT;\r
+ }\r
+\r
+ if(DCM_E_POSITIVERESPONSE == diagResponseCode)\r
+ {\r
+ pduTxData->SduLength = SID_LEN + ALFID_LEN + addressFormat + sizeFormat;\r
+ pduTxData->SduDataPtr[ALFID_INDEX] = pduRxData->SduDataPtr[ALFID_INDEX];\r
+ for(i = 0; i < addressFormat + sizeFormat; i++)\r
{\r
- DsdDspProcessingDone(DCM_E_POSITIVERESPONSE);\r
+ pduTxData->SduDataPtr[ADDR_START_INDEX + i] = pduRxData->SduDataPtr[ADDR_START_INDEX + i];\r
+ if(OpStatus != DCM_WRITE_PENDING)\r
+ {\r
+ DsdDspProcessingDone(diagResponseCode);\r
+ }\r
+ else\r
+ {\r
+ dspMemoryState=DCM_MEMORY_WRITE;\r
+ }\r
}\r
}\r
else\r
{\r
- DsdDspProcessingDone(dspReadMemoryByAddress.ResponseCode);\r
+ DsdDspProcessingDone(diagResponseCode);\r
}\r
}\r
\r
-static boolean checkWriteMemoryByAddress(boolean useId,uint32 memoryAddress,\r
- uint8 memoryAddressFormat,\r
- uint32 memorySize,\r
- const Dcm_DspMemoryIdInfo *dspMemory)\r
+/*@req Dcm442,DCM492*/\r
+void DspUdsReadMemoryByAddress(const PduInfoType *pduRxData, PduInfoType *pduTxData)\r
{\r
- boolean ret = FALSE;\r
- uint8 MemoryId;\r
- \r
- if(useId == FALSE)\r
+ Dcm_NegativeResponseCodeType diagResponseCode;\r
+ uint8 sizeFormat;\r
+ uint8 addressFormat;\r
+ uint32 memoryAddress = 0;\r
+ uint32 length = 0;\r
+ uint8 i;\r
+ uint8 memoryIdentifier = 0; /* Should be 0 if DcmDspUseMemoryId == FALSE */\r
+ Dcm_OpStatusType OpStatus;\r
+ uint8 addressOffset;\r
+\r
+ if( pduRxData->SduLength > ALFID_INDEX )\r
{\r
- if((memoryAddress >= dspMemory->pWriteMemoryInfo->MemoryAddressLow)\r
- && (memoryAddress <= dspMemory->pWriteMemoryInfo->MemoryAddressHigh)\r
- && (memoryAddress + memorySize - 1 <= dspMemory->pWriteMemoryInfo->MemoryAddressHigh))\r
+ sizeFormat = ((uint8)(pduRxData->SduDataPtr[ALFID_INDEX] & DCM_FORMAT_HIGH_MASK)) >> 4; /*@req UDS_REQ_0x23_1 & UDS_REQ_0x23_5*/;\r
+ addressFormat = ((uint8)(pduRxData->SduDataPtr[ALFID_INDEX])) & DCM_FORMAT_LOW_MASK; /*@req UDS_REQ_0x23_1 & UDS_REQ_0x23_5*/;\r
+ if((addressFormat != 0) && (sizeFormat != 0))\r
{\r
- ret = TRUE;\r
+ if(addressFormat + sizeFormat + SID_LEN + ALFID_LEN == pduRxData->SduLength)\r
+ {\r
+ if( TRUE == DCM_Config.Dsp->DspMemory->DcmDspUseMemoryId ) {\r
+ memoryIdentifier = pduRxData->SduDataPtr[ADDR_START_INDEX];\r
+ addressOffset = 1;\r
+ }\r
+ else {\r
+ addressOffset = 0;\r
+ }\r
+\r
+ /* Parse address */\r
+ for(i = addressOffset; i < addressFormat; i++)\r
+ {\r
+ memoryAddress <<= 8;\r
+ memoryAddress += (uint32)(pduRxData->SduDataPtr[ADDR_START_INDEX + i]);\r
+ }\r
+\r
+ /* Parse size */\r
+ for(i = 0; i < sizeFormat; i++)\r
+ {\r
+ length <<= 8;\r
+ length += (uint32)(pduRxData->SduDataPtr[ADDR_START_INDEX + addressFormat + i]);\r
+ }\r
+\r
+ if(length <= (DCM_PROTOCAL_TP_MAX_LENGTH - SID_LEN) )\r
+ {\r
+ diagResponseCode = checkAddressRange(DCM_READ_MEMORY, memoryIdentifier, memoryAddress, length);\r
+ if( DCM_E_POSITIVERESPONSE == diagResponseCode )\r
+ {\r
+ diagResponseCode = readMemoryData(&OpStatus, memoryIdentifier, memoryAddress, length, pduTxData);\r
+ }\r
+ }\r
+ else {\r
+ diagResponseCode = DCM_E_REQUESTOUTOFRANGE;\r
+ }\r
+ }\r
+ else\r
+ {\r
+ diagResponseCode = DCM_E_INCORRECTMESSAGELENGTHORINVALIDFORMAT;\r
+ }\r
+ }\r
+ else\r
+ {\r
+ diagResponseCode = DCM_E_REQUESTOUTOFRANGE; /*UDS_REQ_0x23_10*/\r
}\r
}\r
else\r
{\r
- MemoryId = (uint8)(memoryAddress >> ((memoryAddressFormat - 1)*8));\r
- /* REVIEW JB 2012-06-05: See comment for corresponding read function */\r
- memoryAddress = memoryAddress & DCM_MEMORY_ADDRESS_MASK;\r
-\r
- if((MemoryId == dspMemory->MemoryIdValue) &&\r
- (memoryAddress >= dspMemory->pWriteMemoryInfo->MemoryAddressLow)\r
- && (memoryAddress <= dspMemory->pWriteMemoryInfo->MemoryAddressHigh)\r
- && (memoryAddress + memorySize -1 <= dspMemory->pWriteMemoryInfo->MemoryAddressHigh))\r
- {\r
- ret = TRUE;\r
- }\r
-\r
+ diagResponseCode = DCM_E_INCORRECTMESSAGELENGTHORINVALIDFORMAT;\r
}\r
- \r
- return ret;\r
-}\r
-\r
-static boolean lookupWriteMemory(uint32 memoryAddress,\r
- uint8 memoryAddressFormat,\r
- uint32 memorySize,\r
- const Dcm_DspMemoryIdInfo **MemoryIdConfigPtr)\r
-{\r
- uint8 i;\r
- const Dcm_DspMemoryIdInfo *dspMemoryInfo = DCM_Config.Dsp->DspMemory->DspMemoryIdInfo;\r
- boolean memoryFound = FALSE;\r
\r
- for(i = 0;(dspMemoryInfo->Arc_EOL == FALSE) && (memoryFound == FALSE);i++)\r
+ if(DCM_E_POSITIVERESPONSE == diagResponseCode)\r
{\r
- if(TRUE == checkWriteMemoryByAddress(DCM_Config.Dsp->DspMemory->DcmDspUseMemoryId, memoryAddress,memoryAddressFormat,memorySize,dspMemoryInfo))\r
+ pduTxData->SduLength = SID_LEN + length;\r
+ if(OpStatus == DCM_READ_PENDING)\r
{\r
- memoryFound = TRUE;\r
+ dspMemoryState = DCM_MEMORY_READ;\r
}\r
else\r
{\r
- dspMemoryInfo++;\r
+ DsdDspProcessingDone(DCM_E_POSITIVERESPONSE);\r
}\r
}\r
- if (memoryFound == TRUE)\r
+ else\r
{\r
- *MemoryIdConfigPtr = dspMemoryInfo;\r
+ DsdDspProcessingDone(diagResponseCode);\r
}\r
- \r
- return memoryFound;\r
}\r
\r
static Dcm_NegativeResponseCodeType writeMemoryData(Dcm_OpStatusType* OpStatus,\r
- const Dcm_DspMemoryIdInfo *MemoryIdConfigPtr,\r
+ uint8 memoryIdentifier,\r
uint32 MemoryAddress,\r
uint32 MemorySize,\r
uint8 *SourceData)\r
Dcm_NegativeResponseCodeType responseCode = DCM_E_POSITIVERESPONSE;\r
Dcm_ReturnWriteMemoryType writeRet;\r
writeRet = Dcm_WriteMemory(*OpStatus,\r
- MemoryIdConfigPtr->MemoryIdValue,\r
+ memoryIdentifier,\r
MemoryAddress,\r
MemorySize,\r
SourceData);\r
return responseCode;\r
}\r
\r
-void DspUdsWriteMemoryByAddress(const PduInfoType* pduRxData, PduInfoType* pduTxData)\r
-{\r
- typedef struct{\r
- uint32 MemoryAddressStart;\r
- uint32 MemoryIdValue;\r
- const Dcm_DspMemoryIdInfo *MemoryIdConfigPtr;\r
- Dcm_NegativeResponseCodeType ResponseCode;\r
- uint8 MemorySizeFormat;\r
- uint8 MemoryAddressFormat;\r
- uint32 MemorySize ;\r
- uint16 MessageLength;\r
- }DspUdsWriteMemoryType;\r
- uint8 i;\r
- DspUdsWriteMemoryType dspUdsWriteMemory;\r
- Dcm_OpStatusType OpStatus = DCM_INITIAL;\r
- dspUdsWriteMemory.MemoryAddressStart = 0;\r
- dspUdsWriteMemory.MemoryIdConfigPtr = NULL;\r
- dspUdsWriteMemory.ResponseCode = DCM_E_POSITIVERESPONSE;\r
- dspUdsWriteMemory.MemorySizeFormat = ((uint8)(pduRxData->SduDataPtr[1] & DCM_FORMAT_HIGH_MASK)) >> 4; /*@req UDS_REQ_0x3D_3 & UDS_REQ_0x3D_5*/\r
- dspUdsWriteMemory.MemoryAddressFormat = ((uint8)pduRxData->SduDataPtr[1]) & DCM_FORMAT_LOW_MASK; /*@req UDS_REQ_0x3D_3& UDS_REQ_0x3D_4*/\r
- dspUdsWriteMemory.MemorySize = 0;\r
-\r
- if((dspUdsWriteMemory.MemoryAddressFormat == 0) || (dspUdsWriteMemory.MemorySizeFormat == 0)) /*@req UDS_REQ_0x3D_14*/\r
- {\r
- dspUdsWriteMemory.ResponseCode = DCM_E_REQUESTOUTOFRANGE;\r
- }\r
- else\r
- {\r
- /*take value of MemorySize out */\r
- for(i = 0; i < dspUdsWriteMemory.MemorySizeFormat; i++)\r
- {\r
- dspUdsWriteMemory.MemorySize <<= 8;\r
- dspUdsWriteMemory.MemorySize += (uint32)(pduRxData->SduDataPtr[2 + i +dspUdsWriteMemory.MemoryAddressFormat]);\r
- }\r
- dspUdsWriteMemory.MessageLength = (uint16)(2 + dspUdsWriteMemory.MemoryAddressFormat + dspUdsWriteMemory.MemorySizeFormat + dspUdsWriteMemory.MemorySize);\r
- if(dspUdsWriteMemory.MessageLength == pduRxData->SduLength)\r
- {\r
- /*take Start Address out */\r
- for(i = 0; i < dspUdsWriteMemory.MemoryAddressFormat; i++)\r
- {\r
- dspUdsWriteMemory.MemoryAddressStart <<= 8;\r
- dspUdsWriteMemory.MemoryAddressStart += (uint32)(pduRxData->SduDataPtr[2 + i]);\r
- }\r
- if(TRUE == lookupWriteMemory(dspUdsWriteMemory.MemoryAddressStart,\r
- dspUdsWriteMemory.MemoryAddressFormat,\r
- dspUdsWriteMemory.MemorySize,\r
- &dspUdsWriteMemory.MemoryIdConfigPtr))\r
- {\r
- if (DspCheckSecurityLevel(dspUdsWriteMemory.MemoryIdConfigPtr->pReadMemoryInfo->pSecurityLevel) == TRUE)\r
- {\r
- dspUdsWriteMemory.ResponseCode = writeMemoryData(&OpStatus,\r
- dspUdsWriteMemory.MemoryIdConfigPtr, \r
- dspUdsWriteMemory.MemoryAddressStart,\r
- dspUdsWriteMemory.MemorySize,\r
- &pduRxData->SduDataPtr[2 + dspUdsWriteMemory.MemoryAddressFormat + dspUdsWriteMemory.MemorySizeFormat]);\r
- }\r
- else\r
- {\r
- dspUdsWriteMemory.ResponseCode = DCM_E_SECUTITYACCESSDENIED; /*@req UDS_REQ_0X3D_15,Dcm490*/\r
- }\r
- }\r
- else\r
- {\r
- dspUdsWriteMemory.ResponseCode = DCM_E_REQUESTOUTOFRANGE; /*@req UDS_REQ_0x3D_11,UDS_REQ_0x3D_12,Dcm489*/\r
- }\r
- }\r
- else\r
- {\r
- dspUdsWriteMemory.ResponseCode = DCM_E_INCORRECTMESSAGELENGTHORINVALIDFORMAT;/*@req UDS_REQ_0x3D_9*/\r
- } \r
- }\r
- if(DCM_E_POSITIVERESPONSE == dspUdsWriteMemory.ResponseCode)\r
- {\r
- pduTxData->SduLength = 2 + dspUdsWriteMemory.MemorySizeFormat + dspUdsWriteMemory.MemoryAddressFormat;\r
- pduTxData->SduDataPtr[1] = pduRxData->SduDataPtr[1];\r
- for(i = 0; i < dspUdsWriteMemory.MemorySizeFormat + dspUdsWriteMemory.MemoryAddressFormat; i++)\r
- {\r
- pduTxData->SduDataPtr[2 + i] = pduRxData->SduDataPtr[2 + i];\r
- if(OpStatus != DCM_PENDING)\r
- {\r
- DsdDspProcessingDone(dspUdsWriteMemory.ResponseCode);\r
- }\r
- else\r
- {\r
- dspMemoryState=DCM_MEMORY_WRITE;\r
- }\r
- }\r
- }\r
- else\r
- {\r
- DsdDspProcessingDone(dspUdsWriteMemory.ResponseCode);\r
- }\r
-}\r
-\r
static boolean checkPeriodicIdentifierBuffer(uint8 PeriodicDid,uint8 Length,uint8 *postion)\r
{\r
uint8 i;\r
return ret;\r
}\r
\r
-/* REVIEW JB 2012-06-05: Please describe the buffer algorithm because it is not obvious when looking at this function. */\r
static void ClearPeriodicIdentifierBuffer(uint8 BufferEnd,uint8 postion)\r
{\r
dspPDidRef.dspPDid[postion].PeriodicDid = dspPDidRef.dspPDid[BufferEnd ].PeriodicDid;\r
responseCode = DCM_E_REQUESTOUTOFRANGE;\r
}\r
}\r
- else if(LookupDDD(didNr,&DDidPtr) == TRUE)\r
+ else if(LookupDDD(didNr, (const Dcm_DspDDDType **)&DDidPtr) == TRUE)\r
{\r
responseCode = DCM_E_POSITIVERESPONSE;\r
}\r
if(responseCode == DCM_E_POSITIVERESPONSE)\r
{\r
dspPDidRef.dspPDid[PdidBufferNr].PeriodicDid = (uint8)didNr & DCM_DID_LOW_MASK;\r
- /* REVIEW JB 2012-06-05: Why is TxCounter set to PdidBufferNr - it seems wrong. */\r
- dspPDidRef.dspPDid[PdidBufferNr].PDidTxCounter = PdidBufferNr*3;\r
-\r
+ dspPDidRef.dspPDid[PdidBufferNr].PDidTxCounter = 0;\r
dspPDidRef.dspPDid[PdidBufferNr].PDidTxCounterNumber = periodicTransmitCounter;\r
}\r
return responseCode;\r
{\r
uint16 PdidNumber;\r
uint8 PDidLowByte;\r
- uint8 PdidBufferNr;\r
uint8 PdidPostion;\r
uint8 i;\r
if( pduRxData->SduDataPtr[1] == DCM_PERIODICTRANSMIT_STOPSENDING_MODE )\r
responseCode = DCM_E_REQUESTOUTOFRANGE;\r
break;\r
}\r
- if(pduRxData->SduDataPtr[1] != DCM_PERIODICTRANSMIT_STOPSENDING_MODE)\r
+ if((pduRxData->SduDataPtr[1] != DCM_PERIODICTRANSMIT_STOPSENDING_MODE) && responseCode == DCM_E_POSITIVERESPONSE)\r
{\r
PdidNumber = pduRxData->SduLength - 2;\r
if(1 == PdidNumber)\r
responseCode = readPeriodDidData(PDidPtr,&pduTxData->SduDataPtr[2],&DataLength);\r
pduTxData->SduLength = DataLength + 2;\r
}\r
- else if(TRUE == LookupDDD((0xF200 + (uint16)PDidLowByte),&DDidPtr))\r
+ else if(TRUE == LookupDDD((0xF200 + (uint16)PDidLowByte), (const Dcm_DspDDDType **)&DDidPtr))\r
{\r
pduTxData->SduDataPtr[1] = PDidLowByte;\r
responseCode = readDDDData(DDidPtr,&pduTxData->SduDataPtr[2],&DataLength);\r
pduTxData->SduLength = 1;\r
}\r
}\r
- else if((PdidNumber + PdidBufferNr) <= DCM_LIMITNUMBER_PERIODDATA) /*UDS_REQ_0x2A_6*/\r
+ else if(((PdidNumber + PdidBufferNr) <= DCM_LIMITNUMBER_PERIODDATA) && (responseCode == DCM_E_POSITIVERESPONSE)) /*UDS_REQ_0x2A_6*/\r
{ \r
for(i = 0;(i < PdidNumber)&&(responseCode == DCM_E_POSITIVERESPONSE);i++)\r
{\r
uint8 Num = 0;\r
Dcm_NegativeResponseCodeType responseCode = DCM_E_POSITIVERESPONSE;\r
\r
- if(FALSE == LookupDDD(DDIdentifier, &DDid))\r
+ if(FALSE == LookupDDD(DDIdentifier, (const Dcm_DspDDDType **)&DDid))\r
{\r
while((Num < DCM_MAX_DDD_NUMBER) && (dspDDD[Num].DynamicallyDid != 0 ))\r
{\r
\r
static Dcm_NegativeResponseCodeType dynamicallyDefineDataIdentifierbyAddress(uint16 DDIdentifier,const PduInfoType *pduRxData,PduInfoType *pduTxData)\r
{\r
- uint8 LengthCount;\r
- uint8 SourceCount;\r
- uint16 Length;\r
- uint8 AddressFormat;\r
- uint8 MemorySizeFormat;\r
- uint32 MemoryAddress = 0;\r
- uint16 MemorySize = 0;\r
- uint16 SourceLength = 0;\r
+ uint16 numNewDefinitions;\r
+ uint16 numEarlierDefinitions = 0;\r
Dcm_DspDDDType *DDid = NULL;\r
- const Dcm_DspMemoryIdInfo *SourceMemoryInfo = NULL;\r
uint8 Num = 0;\r
- Dcm_NegativeResponseCodeType responseCode = DCM_E_POSITIVERESPONSE;\r
+ uint8 definitionIndex;\r
+ Dcm_NegativeResponseCodeType diagResponseCode = DCM_E_POSITIVERESPONSE;\r
+ uint8 sizeFormat;\r
+ uint8 addressFormat;\r
+ uint32 memoryAddress = 0;\r
+ uint32 length = 0;\r
+ uint8 i;\r
+ uint8 memoryIdentifier = 0; /* Should be 0 if DcmDspUseMemoryId == FALSE */\r
+ uint8 addressOffset;\r
\r
- if(FALSE == LookupDDD(DDIdentifier,&DDid))\r
+ if(FALSE == LookupDDD(DDIdentifier, (const Dcm_DspDDDType **)&DDid))\r
{\r
while((Num < DCM_MAX_DDD_NUMBER) && (dspDDD[Num].DynamicallyDid != 0 ))\r
{\r
}\r
if(Num >= DCM_MAX_DDD_NUMBER)\r
{\r
- responseCode = DCM_E_REQUESTOUTOFRANGE;\r
+ diagResponseCode = DCM_E_REQUESTOUTOFRANGE;\r
}\r
else\r
{\r
}\r
else\r
{\r
- while((SourceLength < DCM_MAX_DDDSOURCE_NUMBER) && (DDid->DDDSource[SourceLength].formatOrPosition != 0 ))\r
+ while((numEarlierDefinitions < DCM_MAX_DDDSOURCE_NUMBER) && (DDid->DDDSource[numEarlierDefinitions].formatOrPosition != 0 ))\r
{\r
- SourceLength++;\r
+ numEarlierDefinitions++;\r
}\r
- if(SourceLength >= DCM_MAX_DDDSOURCE_NUMBER)\r
+ if(numEarlierDefinitions >= DCM_MAX_DDDSOURCE_NUMBER)\r
{\r
- responseCode = DCM_E_REQUESTOUTOFRANGE;\r
+ diagResponseCode = DCM_E_REQUESTOUTOFRANGE;\r
}\r
}\r
- if(responseCode == DCM_E_POSITIVERESPONSE)\r
+\r
+ if( diagResponseCode == DCM_E_POSITIVERESPONSE )\r
{\r
- AddressFormat = (uint8)pduRxData->SduDataPtr[4] & DCM_FORMAT_LOW_MASK;\r
- MemorySizeFormat = (uint8)(pduRxData->SduDataPtr[4] >> 4) & DCM_FORMAT_LOW_MASK;\r
- if((AddressFormat+MemorySizeFormat) != 0)\r
- {\r
- Length = (pduRxData->SduLength - SID_AND_ALFID_LEN5) / (AddressFormat + MemorySizeFormat);\r
- }\r
- if((AddressFormat != 0) && (MemorySizeFormat != 0) && ((SourceLength+Length) <= DCM_MAX_DDDSOURCE_NUMBER))\r
+ if( pduRxData->SduLength > DYNDEF_ALFID_INDEX )\r
{\r
- if((Length != 0)&&( Length * (AddressFormat + MemorySizeFormat) == (pduRxData->SduLength - 5) ))\r
+ sizeFormat = ((uint8)(pduRxData->SduDataPtr[DYNDEF_ALFID_INDEX] & DCM_FORMAT_HIGH_MASK)) >> 4; /*@req UDS_REQ_0x23_1 & UDS_REQ_0x23_5*/;\r
+ addressFormat = ((uint8)(pduRxData->SduDataPtr[DYNDEF_ALFID_INDEX])) & DCM_FORMAT_LOW_MASK; /*@req UDS_REQ_0x23_1 & UDS_REQ_0x23_5*/;\r
+ if((addressFormat != 0) && (sizeFormat != 0))\r
{\r
- /* REVIEW JB 2012-06-05: Use better names than i and j to increase readability */\r
- for(LengthCount = 0; (LengthCount < Length) && (responseCode == DCM_E_POSITIVERESPONSE); LengthCount++)\r
+ numNewDefinitions = (pduRxData->SduLength - (SID_LEN + SF_LEN + DDDDI_LEN + ALFID_LEN) ) / (sizeFormat + addressFormat);\r
+ if( (numNewDefinitions != 0) &&\r
+ ((SID_LEN + SF_LEN + DDDDI_LEN + ALFID_LEN + numNewDefinitions * (sizeFormat + addressFormat)) == pduRxData->SduLength) )\r
{\r
- MemoryAddress = 0;\r
- for(SourceCount = 0; SourceCount < AddressFormat; SourceCount++)\r
+ if( (numEarlierDefinitions+numNewDefinitions) <= DCM_MAX_DDDSOURCE_NUMBER )\r
{\r
- MemoryAddress = MemoryAddress << 8;\r
- MemoryAddress += (uint32)(pduRxData->SduDataPtr[5 + SourceCount + LengthCount * (AddressFormat + MemorySizeFormat)]);\r
- }\r
+ for( definitionIndex = 0; (definitionIndex < numNewDefinitions) && (diagResponseCode == DCM_E_POSITIVERESPONSE); definitionIndex++ )\r
+ {\r
\r
- /*take value of MemorySize out */\r
- MemorySize = 0;\r
- for(SourceCount = 0; SourceCount < MemorySizeFormat; SourceCount++)\r
- {\r
- MemorySize = MemorySize << 8;\r
- MemorySize += (uint32)(pduRxData->SduDataPtr[5 + SourceCount + AddressFormat + LengthCount * (AddressFormat + MemorySizeFormat)]);\r
- }\r
- if(TRUE == lookupReadMemory(MemoryAddress, AddressFormat,MemorySize,&SourceMemoryInfo))\r
- {\r
- if(DspCheckSecurityLevel(SourceMemoryInfo->pReadMemoryInfo->pSecurityLevel) == TRUE)\r
+ if( TRUE == DCM_Config.Dsp->DspMemory->DcmDspUseMemoryId ) {\r
+ memoryIdentifier = pduRxData->SduDataPtr[DYNDEF_ADDRESS_START_INDEX + definitionIndex * (sizeFormat + addressFormat)];\r
+ addressOffset = 1;\r
+ }\r
+ else {\r
+ addressOffset = 0;\r
+ }\r
+\r
+ /* Parse address */\r
+ memoryAddress = 0;\r
+ for(i = addressOffset; i < addressFormat; i++)\r
+ {\r
+ memoryAddress <<= 8;\r
+ memoryAddress += (uint32)(pduRxData->SduDataPtr[DYNDEF_ADDRESS_START_INDEX + definitionIndex * (sizeFormat + addressFormat) + i]);\r
+ }\r
+\r
+ /* Parse size */\r
+ length = 0;\r
+ for(i = 0; i < sizeFormat; i++)\r
+ {\r
+ length <<= 8;\r
+ length += (uint32)(pduRxData->SduDataPtr[DYNDEF_ADDRESS_START_INDEX + definitionIndex * (sizeFormat + addressFormat) + addressFormat + i]);\r
+ }\r
+\r
+ diagResponseCode = checkAddressRange(DCM_READ_MEMORY, memoryIdentifier, memoryAddress, length);\r
+ if( DCM_E_POSITIVERESPONSE == diagResponseCode )\r
+ {\r
+ DDid->DDDSource[definitionIndex + numEarlierDefinitions].formatOrPosition = pduRxData->SduDataPtr[DYNDEF_ALFID_INDEX];\r
+ DDid->DDDSource[definitionIndex + numEarlierDefinitions].memoryIdentifier = memoryIdentifier;\r
+ DDid->DDDSource[definitionIndex + numEarlierDefinitions].SourceAddressOrDid = memoryAddress;\r
+ DDid->DDDSource[definitionIndex + numEarlierDefinitions].Size = length;\r
+ DDid->DDDSource[definitionIndex + numEarlierDefinitions].DDDTpyeID = DCM_DDD_SOURCE_ADDRESS;\r
+ }\r
+ }\r
+ if(diagResponseCode == DCM_E_POSITIVERESPONSE)\r
{\r
- DDid->DDDSource[LengthCount + SourceLength].formatOrPosition = pduRxData->SduDataPtr[4];\r
- DDid->DDDSource[LengthCount + SourceLength].SourceAddressOrDid = MemoryAddress;\r
- DDid->DDDSource[LengthCount + SourceLength].Size = MemorySize;\r
- DDid->DDDSource[LengthCount + SourceLength].DDDTpyeID = DCM_DDD_SOURCE_ADDRESS;\r
- /*UDS_REQ_0x2C_6*/\r
+ DDid->DynamicallyDid = DDIdentifier;\r
}\r
else\r
{\r
- /*UDS_REQ_0x2C_19,DCM726*/\r
- responseCode = DCM_E_SECUTITYACCESSDENIED;\r
+ for( definitionIndex = 0; (definitionIndex < numNewDefinitions); definitionIndex++ )\r
+ {\r
+ DDid->DDDSource[definitionIndex + numEarlierDefinitions].formatOrPosition = 0x00;\r
+ DDid->DDDSource[definitionIndex + numEarlierDefinitions].memoryIdentifier = 0x00;\r
+ DDid->DDDSource[definitionIndex + numEarlierDefinitions].SourceAddressOrDid = 0x00000000;\r
+ DDid->DDDSource[definitionIndex + numEarlierDefinitions].Size = 0x0000;\r
+ DDid->DDDSource[definitionIndex + numEarlierDefinitions].DDDTpyeID = DCM_DDD_SOURCE_DEFAULT;\r
+ }\r
}\r
}\r
else\r
{\r
- /*UDS_REQ_0x2C_15,UDS_REQ_0x2C_16*/\r
- responseCode = DCM_E_REQUESTOUTOFRANGE;\r
+ diagResponseCode = DCM_E_REQUESTOUTOFRANGE;\r
}\r
}\r
- if(responseCode == DCM_E_POSITIVERESPONSE)\r
+ else\r
{\r
- DDid->DynamicallyDid = DDIdentifier;\r
+ diagResponseCode = DCM_E_INCORRECTMESSAGELENGTHORINVALIDFORMAT;\r
}\r
}\r
else\r
{\r
- /*UDS_REQ_0x2C_11*/\r
- responseCode = DCM_E_INCORRECTMESSAGELENGTHORINVALIDFORMAT;\r
+ diagResponseCode = DCM_E_REQUESTOUTOFRANGE; /*UDS_REQ_0x23_10*/\r
}\r
}\r
else\r
{\r
- /*UDS_REQ_0x2C_17, UDS_REQ_0x2C_18*/\r
- responseCode = DCM_E_REQUESTOUTOFRANGE;\r
+ diagResponseCode = DCM_E_INCORRECTMESSAGELENGTHORINVALIDFORMAT;\r
}\r
-\r
}\r
- if(responseCode == DCM_E_POSITIVERESPONSE)\r
+\r
+\r
+ if(diagResponseCode == DCM_E_POSITIVERESPONSE)\r
{\r
- pduTxData->SduDataPtr[1] = DCM_DDD_SUBFUNCTION_DEFINEBYADDRESS;\r
+ pduTxData->SduDataPtr[SF_INDEX] = DCM_DDD_SUBFUNCTION_DEFINEBYADDRESS;\r
}\r
\r
- return responseCode;\r
+ return diagResponseCode;\r
}\r
\r
\r
static Dcm_NegativeResponseCodeType CleardynamicallyDid(uint16 DDIdentifier,const PduInfoType *pduRxData, PduInfoType * pduTxData)\r
{\r
/*UDS_REQ_0x2C_5*/\r
- uint8 i;\r
- uint8 ClearCount;\r
+ sint8 i, j;\r
uint8 position;\r
- uint8 ClearNum = 0;\r
Dcm_DspDDDType *DDid = NULL;\r
Dcm_NegativeResponseCodeType responseCode = DCM_E_POSITIVERESPONSE;\r
\r
if(pduRxData->SduLength == 4)\r
{\r
- if(TRUE == LookupDDD(DDIdentifier,&DDid))\r
+ if(TRUE == LookupDDD(DDIdentifier, (const Dcm_DspDDDType **)&DDid))\r
{\r
\r
if((checkPeriodicIdentifierBuffer(pduRxData->SduDataPtr[3], dspPDidRef.PDidNr, &position) == TRUE)&&(pduRxData->SduDataPtr[2] == 0xF2))\r
}\r
else\r
{\r
- for(i = 1;i < DCM_MAX_DDD_NUMBER;i++)\r
- {\r
- if(0 == dspDDD[i].DynamicallyDid)\r
- {\r
- ClearNum = i - 1;\r
- DDid->DynamicallyDid = dspDDD[ClearNum].DynamicallyDid;\r
- dspDDD[ClearNum].DynamicallyDid = 0;\r
- for(ClearCount = 0;ClearCount < DCM_MAX_DDDSOURCE_NUMBER;ClearCount++)\r
- {\r
- /*DCM647*/\r
- DDid->DDDSource[ClearCount].DDDTpyeID = dspDDD[ClearNum].DDDSource[ClearCount].DDDTpyeID;\r
- DDid->DDDSource[ClearCount].formatOrPosition = dspDDD[ClearNum].DDDSource[ClearCount].formatOrPosition;\r
- DDid->DDDSource[ClearCount].SourceAddressOrDid = dspDDD[ClearNum].DDDSource[ClearCount].SourceAddressOrDid;\r
- DDid->DDDSource[ClearCount].Size = dspDDD[ClearNum].DDDSource[ClearCount].Size;\r
- dspDDD[ClearNum].DDDSource[ClearCount].DDDTpyeID = 0;\r
- dspDDD[ClearNum].DDDSource[ClearCount].formatOrPosition = 0;\r
- dspDDD[ClearNum].DDDSource[ClearCount].SourceAddressOrDid = 0;\r
- dspDDD[ClearNum].DDDSource[ClearCount].Size = 0;\r
- } \r
- } \r
+ memset(DDid, 0, sizeof(Dcm_DspDDDType));\r
+ for(i = DCM_MAX_DDD_NUMBER - 1;i >= 0 ;i--) { /* find the first DDDid from bottom */\r
+ if (0 != dspDDD[i].DynamicallyDid) {\r
+ for (j = 0; j <DCM_MAX_DDD_NUMBER; j++) { /* find the first empty slot from top */\r
+ if (j >= i) {\r
+ /* Rearrange finished */\r
+ pduTxData->SduDataPtr[1] = DCM_DDD_SUBFUNCTION_CLEAR;\r
+ pduTxData->SduLength = 2;\r
+ return responseCode;\r
+ }\r
+ else if (0 == dspDDD[j].DynamicallyDid) { /* find, exchange */\r
+ memcpy(&dspDDD[j], &dspDDD[i], sizeof(Dcm_DspDDDType));\r
+ memset(&dspDDD[i], 0, sizeof(Dcm_DspDDDType));\r
+ }\r
+ }\r
+ }\r
}\r
}\r
- } \r
+ }\r
+ else{\r
+ responseCode = DCM_E_REQUESTOUTOFRANGE; /* DDDid not found */\r
+ }\r
+ }\r
+ else if (pduRxData->SduDataPtr[1] == 0x03 && pduRxData->SduLength == 2){\r
+ /* clear all */\r
+ memset(dspDDD, 0, (sizeof(Dcm_DspDDDType) * DCM_MAX_DDD_NUMBER));\r
}\r
else\r
{\r
uint16 DDIdentifier = ((((uint16)pduRxData->SduDataPtr[2]) << 8) & DCM_DID_HIGH_MASK) + (pduRxData->SduDataPtr[3] & DCM_DID_LOW_MASK);\r
if(pduRxData->SduLength > 2)\r
{\r
- /* REVIEW JB 2012-06-05: Clarify that F2 and F3 is included by comment */\r
+ /* Check if DDID equals 0xF2 or 0xF3 */\r
if((pduRxData->SduDataPtr[2] & 0xF2) == 0xF2)\r
{\r
switch(pduRxData->SduDataPtr[1]) /*UDS_REQ_0x2C_2,DCM 646*/\r
static Dcm_NegativeResponseCodeType DspIOControlReturnControlToECU(const Dcm_DspDidType *DidPtr,const PduInfoType *pduRxData,PduInfoType *pduTxData)\r
{\r
Dcm_NegativeResponseCodeType responseCode = DCM_E_POSITIVERESPONSE;\r
- if(DidPtr->DspDidInfoRef->DspDidAccess.DspDidControl->DspDidReturnControlToEcu == TRUE)\r
+ if(pduRxData->SduLength > 4)\r
{\r
- if(pduRxData->SduLength > 4)\r
+ if(DidPtr->DspDidInfoRef->DspDidAccess.DspDidControl != NULL)\r
{\r
- if(DidPtr->DspDidInfoRef->DspDidAccess.DspDidControl != NULL)\r
+ if(((DidPtr->DspDidInfoRef->DspDidAccess.DspDidControl->DspDidReturnControlToEcu->DspDidControlOptionRecordSize + 7) >> 3) == (pduRxData->SduLength - 4))\r
{\r
- if(((DidPtr->DspDidControlRecordSize->DspDidControlRecordSize + 7) >> 3) == (pduRxData->SduLength - 4))\r
+ if(DidPtr->DspDidReturnControlToEcuFnc != NULL)\r
{\r
- if(DidPtr->DspDidReturnControlToEcuFnc != NULL)\r
- {\r
- DidPtr->DspDidReturnControlToEcuFnc(NULL,&pduRxData->SduDataPtr[4],&pduTxData->SduDataPtr[4],&responseCode);\r
- \r
- }\r
- else\r
- {\r
- responseCode = DCM_E_REQUESTOUTOFRANGE;\r
- }\r
+ DidPtr->DspDidReturnControlToEcuFnc(NULL,&pduRxData->SduDataPtr[4],&pduTxData->SduDataPtr[4],&responseCode);\r
+\r
}\r
else\r
{\r
}\r
else\r
{\r
- if(DidPtr->DspDidReturnControlToEcuFnc != NULL)\r
- {\r
+ responseCode = DCM_E_REQUESTOUTOFRANGE;\r
+ }\r
+ }\r
+ else\r
+ {\r
+ if(DidPtr->DspDidReturnControlToEcuFnc != NULL)\r
+ {\r
\r
- if(DidPtr->DspDidControlRecordSize != NULL)\r
- {\r
- DidPtr->DspDidReturnControlToEcuFnc(NULL,NULL,&pduTxData->SduDataPtr[4],&responseCode);\r
- pduTxData->SduLength = DidPtr->DspDidControlRecordSize->DspDidControlStatusRecordSize + 4;\r
- }\r
- else\r
- {\r
- responseCode = DCM_E_REQUESTOUTOFRANGE;\r
- }\r
+ if(DidPtr->DspDidControlRecordSize != NULL)\r
+ {\r
+ DidPtr->DspDidReturnControlToEcuFnc(NULL,NULL,&pduTxData->SduDataPtr[4],&responseCode);\r
+ pduTxData->SduLength = DidPtr->DspDidInfoRef->DspDidAccess.DspDidControl->DspDidReturnControlToEcu->DspDidControlStatusRecordSize + 4;\r
}\r
else\r
{\r
responseCode = DCM_E_REQUESTOUTOFRANGE;\r
}\r
}\r
- }\r
- else\r
- {\r
- responseCode = DCM_E_REQUESTOUTOFRANGE;\r
+ else\r
+ {\r
+ responseCode = DCM_E_REQUESTOUTOFRANGE;\r
+ }\r
}\r
if(responseCode == DCM_E_POSITIVERESPONSE)\r
{\r
- pduTxData->SduLength = DidPtr->DspDidControlRecordSize->DspDidControlStatusRecordSize + 4;\r
+ pduTxData->SduLength = DidPtr->DspDidInfoRef->DspDidAccess.DspDidControl->DspDidReturnControlToEcu->DspDidControlStatusRecordSize + 4;\r
pduTxData->SduDataPtr[3] = DCM_RETURN_CONTROL_TO_ECU;\r
}\r
\r
static Dcm_NegativeResponseCodeType DspIOControlResetToDefault(const Dcm_DspDidType *DidPtr,const PduInfoType *pduRxData,PduInfoType *pduTxData)\r
{\r
Dcm_NegativeResponseCodeType responseCode = DCM_E_POSITIVERESPONSE;\r
- if(DidPtr->DspDidInfoRef->DspDidAccess.DspDidControl->DspDidResetToDefault == TRUE)\r
+ if(pduRxData->SduLength > 4)\r
{\r
- if(pduRxData->SduLength > 4)\r
+ if(DidPtr->DspDidInfoRef->DspDidAccess.DspDidControl != NULL)\r
{\r
- if(DidPtr->DspDidInfoRef->DspDidAccess.DspDidControl != NULL)\r
+ if(((DidPtr->DspDidInfoRef->DspDidAccess.DspDidControl->DspDidResetToDefault->DspDidControlOptionRecordSize + 7) >> 3) == (pduRxData->SduLength - 4))\r
{\r
- if(((DidPtr->DspDidControlRecordSize->DspDidControlRecordSize + 7) >> 3) == (pduRxData->SduLength - 4))\r
+ if(DidPtr->DspDidReturnControlToEcuFnc != NULL)\r
{\r
- if(DidPtr->DspDidReturnControlToEcuFnc != NULL)\r
- {\r
- DidPtr->DspDidResetToDeaultFnc(NULL,&pduRxData->SduDataPtr[4],&pduTxData->SduDataPtr[4],&responseCode);\r
- }\r
- else\r
- {\r
- responseCode = DCM_E_REQUESTOUTOFRANGE;\r
- }\r
+ DidPtr->DspDidResetToDefaultFnc(NULL,&pduRxData->SduDataPtr[4],&pduTxData->SduDataPtr[4],&responseCode);\r
}\r
else\r
{\r
}\r
else\r
{\r
- if(DidPtr->DspDidResetToDeaultFnc != NULL)\r
- {\r
+ responseCode = DCM_E_REQUESTOUTOFRANGE;\r
+ }\r
+ }\r
+ else\r
+ {\r
+ if(DidPtr->DspDidResetToDefaultFnc != NULL)\r
+ {\r
\r
- if(DidPtr->DspDidControlRecordSize != NULL)\r
- {\r
- DidPtr->DspDidResetToDeaultFnc(NULL,NULL,&pduTxData->SduDataPtr[4],&responseCode);\r
- pduTxData->SduLength = DidPtr->DspDidControlRecordSize->DspDidControlStatusRecordSize + 4;\r
- }\r
- else\r
- {\r
- responseCode = DCM_E_REQUESTOUTOFRANGE;\r
- }\r
+ if(DidPtr->DspDidControlRecordSize != NULL)\r
+ {\r
+ DidPtr->DspDidResetToDefaultFnc(NULL,NULL,&pduTxData->SduDataPtr[4],&responseCode);\r
+ pduTxData->SduLength = DidPtr->DspDidInfoRef->DspDidAccess.DspDidControl->DspDidResetToDefault->DspDidControlStatusRecordSize + 4;\r
}\r
else\r
{\r
responseCode = DCM_E_REQUESTOUTOFRANGE;\r
}\r
}\r
- }\r
- else\r
- {\r
- responseCode = DCM_E_REQUESTOUTOFRANGE;\r
+ else\r
+ {\r
+ responseCode = DCM_E_REQUESTOUTOFRANGE;\r
+ }\r
}\r
if(responseCode == DCM_E_POSITIVERESPONSE)\r
{\r
- pduTxData->SduLength = DidPtr->DspDidControlRecordSize->DspDidControlStatusRecordSize+4;\r
+ pduTxData->SduLength = DidPtr->DspDidInfoRef->DspDidAccess.DspDidControl->DspDidResetToDefault->DspDidControlStatusRecordSize+4;\r
pduTxData->SduDataPtr[3] = DCM_RESET_TO_DEFAULT;\r
}\r
return responseCode;\r
static Dcm_NegativeResponseCodeType DspIOControlFreezeCurrentState(const Dcm_DspDidType *DidPtr,const PduInfoType *pduRxData,PduInfoType *pduTxData)\r
{\r
Dcm_NegativeResponseCodeType responseCode = DCM_E_POSITIVERESPONSE;\r
- if(DidPtr->DspDidInfoRef->DspDidAccess.DspDidControl->DspDidFreezeCurrentState == TRUE)\r
+ if(pduRxData->SduLength > 4)\r
{\r
- if(pduRxData->SduLength > 4)\r
+ if(DidPtr->DspDidInfoRef->DspDidAccess.DspDidControl != NULL)\r
{\r
- if(DidPtr->DspDidInfoRef->DspDidAccess.DspDidControl != NULL)\r
+ if(((DidPtr->DspDidInfoRef->DspDidAccess.DspDidControl->DspDidFreezeCurrentState->DspDidControlOptionRecordSize + 7) >> 3) == (pduRxData->SduLength - 4))\r
{\r
- if(((DidPtr->DspDidControlRecordSize->DspDidControlRecordSize + 7) >> 3) == (pduRxData->SduLength - 4))\r
+ if(DidPtr->DspDidFreezeCurrentStateFnc != NULL)\r
{\r
- if(DidPtr->DspDidFreezeCurrentStateFnc != NULL)\r
- {\r
- DidPtr->DspDidFreezeCurrentStateFnc(NULL,&pduRxData->SduDataPtr[4],&pduTxData->SduDataPtr[4],&responseCode);\r
- }\r
- else\r
- {\r
- responseCode = DCM_E_REQUESTOUTOFRANGE;\r
- }\r
+ DidPtr->DspDidFreezeCurrentStateFnc(NULL,&pduRxData->SduDataPtr[4],&pduTxData->SduDataPtr[4],&responseCode);\r
}\r
else\r
{\r
}\r
else\r
{\r
- if(DidPtr->DspDidFreezeCurrentStateFnc != NULL)\r
- {\r
+ responseCode = DCM_E_REQUESTOUTOFRANGE;\r
+ }\r
+ }\r
+ else\r
+ {\r
+ if(DidPtr->DspDidFreezeCurrentStateFnc != NULL)\r
+ {\r
\r
- if(DidPtr->DspDidControlRecordSize != 0)\r
- {\r
- DidPtr->DspDidFreezeCurrentStateFnc(NULL,NULL,&pduTxData->SduDataPtr[4],&responseCode);\r
- pduTxData->SduLength = DidPtr->DspDidControlRecordSize->DspDidControlStatusRecordSize + 4;\r
- }\r
- else\r
- {\r
- responseCode = DCM_E_REQUESTOUTOFRANGE;\r
- }\r
+ if(DidPtr->DspDidControlRecordSize != 0)\r
+ {\r
+ DidPtr->DspDidFreezeCurrentStateFnc(NULL,NULL,&pduTxData->SduDataPtr[4],&responseCode);\r
+ pduTxData->SduLength = DidPtr->DspDidInfoRef->DspDidAccess.DspDidControl->DspDidFreezeCurrentState->DspDidControlStatusRecordSize + 4;\r
}\r
else\r
{\r
responseCode = DCM_E_REQUESTOUTOFRANGE;\r
}\r
}\r
- }\r
- else\r
- {\r
- responseCode = DCM_E_REQUESTOUTOFRANGE;\r
+ else\r
+ {\r
+ responseCode = DCM_E_REQUESTOUTOFRANGE;\r
+ }\r
}\r
if(responseCode == DCM_E_POSITIVERESPONSE)\r
{\r
- pduTxData->SduLength = DidPtr->DspDidControlRecordSize->DspDidControlStatusRecordSize + 4;\r
+ pduTxData->SduLength = DidPtr->DspDidInfoRef->DspDidAccess.DspDidControl->DspDidFreezeCurrentState->DspDidControlStatusRecordSize + 4;\r
pduTxData->SduDataPtr[3] = DCM_FREEZE_CURRENT_STATE;\r
}\r
\r
static Dcm_NegativeResponseCodeType DspIOControlShortTeamAdjustment(const Dcm_DspDidType *DidPtr,const PduInfoType *pduRxData,PduInfoType *pduTxData)\r
{\r
Dcm_NegativeResponseCodeType responseCode = DCM_E_POSITIVERESPONSE;\r
- uint8 didControlOptionRecordSize = DidPtr->DspDidControlRecordSize->DspDidControlOptionRecordSize;\r
- if(DidPtr->DspDidInfoRef->DspDidAccess.DspDidControl->DspDidShortTermAdjustment == TRUE)\r
+ uint8 didControlOptionRecordSize = DidPtr->DspDidInfoRef->DspDidAccess.DspDidControl->DspDidShortTermAdjustment->DspDidControlOptionRecordSize;\r
+ if(pduRxData->SduLength > 4)\r
{\r
- if(pduRxData->SduLength > 4)\r
+ if(DidPtr->DspDidInfoRef->DspDidAccess.DspDidControl != NULL)\r
{\r
- if(DidPtr->DspDidInfoRef->DspDidAccess.DspDidControl != NULL)\r
+ if(((((DidPtr->DspDidInfoRef->DspDidAccess.DspDidControl->DspDidShortTermAdjustment->DspDidControlEnableMaskRecordSize + 7)) >> 3) + (didControlOptionRecordSize)) == (pduRxData->SduLength - 4))\r
{\r
- if(((((DidPtr->DspDidControlRecordSize->DspDidControlRecordSize + 7)) >> 3) + (didControlOptionRecordSize)) == (pduRxData->SduLength - 4))\r
+ if(DidPtr->DspDidShortTermAdjustmentFnc != NULL)\r
{\r
- if(DidPtr->DspDidShortTermAdjustmentFnc != NULL)\r
- {\r
- DidPtr->DspDidShortTermAdjustmentFnc(&pduRxData->SduDataPtr[4],&pduRxData->SduDataPtr[4 + didControlOptionRecordSize],&pduTxData->SduDataPtr[4],&responseCode);\r
- }\r
- else\r
- {\r
- responseCode = DCM_E_REQUESTOUTOFRANGE;\r
- }\r
+ DidPtr->DspDidShortTermAdjustmentFnc(&pduRxData->SduDataPtr[4],&pduRxData->SduDataPtr[4 + didControlOptionRecordSize],&pduTxData->SduDataPtr[4],&responseCode);\r
}\r
- else if((didControlOptionRecordSize) == (pduRxData->SduLength - 4))\r
+ else\r
{\r
- if(DidPtr->DspDidShortTermAdjustmentFnc != NULL)\r
- {\r
- DidPtr->DspDidShortTermAdjustmentFnc(&pduRxData->SduDataPtr[4],NULL,&pduTxData->SduDataPtr[4],&responseCode);\r
- }\r
- else\r
- {\r
- responseCode = DCM_E_REQUESTOUTOFRANGE;\r
- }\r
+ responseCode = DCM_E_REQUESTOUTOFRANGE;\r
+ }\r
+ }\r
+ else if((didControlOptionRecordSize) == (pduRxData->SduLength - 4))\r
+ {\r
+ if(DidPtr->DspDidShortTermAdjustmentFnc != NULL)\r
+ {\r
+ DidPtr->DspDidShortTermAdjustmentFnc(&pduRxData->SduDataPtr[4],NULL,&pduTxData->SduDataPtr[4],&responseCode);\r
}\r
else\r
{\r
responseCode = DCM_E_REQUESTOUTOFRANGE;\r
}\r
}\r
- else \r
+ else\r
{\r
responseCode = DCM_E_REQUESTOUTOFRANGE;\r
}\r
}\r
if(responseCode == DCM_E_POSITIVERESPONSE)\r
{\r
- pduTxData->SduLength = DidPtr->DspDidControlRecordSize->DspDidControlStatusRecordSize + 4;\r
+ pduTxData->SduLength = DidPtr->DspDidInfoRef->DspDidAccess.DspDidControl->DspDidShortTermAdjustment->DspDidControlStatusRecordSize + 4;\r
pduTxData->SduDataPtr[3] = DCM_SHORT_TERM_ADJUSTMENT;\r
}\r
\r