*/\r
typedef struct {\r
ISO15765TransferControlType iso15765;\r
- PduInfoType *bufferPduRouter; // The PDUR make an instance of this.\r
+ PduInfoType *pdurBuffer; // The PDUR make an instance of this.\r
PduLengthType pdurBufferCount; // Number of bytes in PDUR buffer.\r
- PduLengthType pduLenghtTotalBytes; // Total length of the PDU.\r
- PduLengthType pduTransferedBytesCount; // Counter ongoing transfer.\r
+ PduLengthType transferTotal; // Total length of the PDU.\r
+ PduLengthType transferCount; // Counter ongoing transfer.\r
CanIfSduType canFrameBuffer; // Temp storage of SDU data.\r
CanTp_TransferInstanceMode mode; // CanTp030.\r
} CanTp_ChannelPrivateType;\r
rxRuntimeParams->iso15765.framesHandledCount = 0;\r
rxRuntimeParams->iso15765.nextFlowControlCount = 0;\r
rxRuntimeParams->pdurBufferCount = 0;\r
- rxRuntimeParams->pduLenghtTotalBytes = 0;\r
- rxRuntimeParams->pduTransferedBytesCount = 0;\r
+ rxRuntimeParams->transferTotal = 0;\r
+ rxRuntimeParams->transferCount = 0;\r
rxRuntimeParams->mode = CANTP_RX_WAIT; /** @req CANTP030 */\r
- rxRuntimeParams->bufferPduRouter = NULL;\r
+ rxRuntimeParams->pdurBuffer = NULL;\r
}\r
\r
// - - - - - - - - - - - - - -\r
txRuntimeParams->iso15765.framesHandledCount = 0;\r
txRuntimeParams->iso15765.nextFlowControlCount = 0;\r
txRuntimeParams->pdurBufferCount = 0;\r
- txRuntimeParams->pduLenghtTotalBytes = 0;\r
- txRuntimeParams->pduTransferedBytesCount = 0;\r
+ txRuntimeParams->transferTotal = 0;\r
+ txRuntimeParams->transferCount = 0;\r
txRuntimeParams->mode = CANTP_TX_WAIT; /** @req CANTP030 */\r
- txRuntimeParams->bufferPduRouter = NULL;\r
+ txRuntimeParams->pdurBuffer = NULL;\r
\r
}\r
\r
\r
while ((*bytesWrittenSuccessfully < segmentSize) && error == FALSE) {\r
// Copy the data that resides in the buffer.\r
- if (rxRuntime->bufferPduRouter != NULL) {\r
+ if (rxRuntime->pdurBuffer != NULL) {\r
while ((*bytesWrittenSuccessfully < segmentSize ) &&\r
- (rxRuntime->bufferPduRouter->SduLength > rxRuntime->pdurBufferCount)) {\r
- rxRuntime->bufferPduRouter->SduDataPtr[rxRuntime->pdurBufferCount++]\r
+ (rxRuntime->pdurBuffer->SduLength > rxRuntime->pdurBufferCount)) {\r
+ rxRuntime->pdurBuffer->SduDataPtr[rxRuntime->pdurBufferCount++]\r
= segment[(*bytesWrittenSuccessfully)++];\r
}\r
}\r
// We need to request a new buffer from the SDUR.\r
// qqq: TODO: We should do a timeout here.\r
ret = PduR_CanTpProvideRxBuffer(rxConfig->PduR_PduId, /** @req CANTP079 */ /** @req CANTP080 */ /** @req CANTP064 */\r
- rxRuntime->pduLenghtTotalBytes,\r
- &rxRuntime->bufferPduRouter);\r
+ rxRuntime->transferTotal,\r
+ &rxRuntime->pdurBuffer);\r
if (ret == BUFREQ_OK) {\r
- VALIDATE( rxRuntime->bufferPduRouter->SduDataPtr != NULL,\r
+ VALIDATE( rxRuntime->pdurBuffer->SduDataPtr != NULL,\r
SERVICE_ID_CANTP_TRANSMIT, CANTP_E_INVALID_RX_BUFFER );\r
rxRuntime->pdurBufferCount = 0; // The buffer is emptied.\r
} else if (ret == BUFREQ_BUSY) {\r
- rxRuntime->pduTransferedBytesCount += *bytesWrittenSuccessfully;\r
+ rxRuntime->transferCount += *bytesWrittenSuccessfully;\r
error = TRUE;\r
break;\r
} else {\r
break;\r
}\r
} else {\r
- rxRuntime->pduTransferedBytesCount += segmentSize; //== bytesWrittenSuccessfully\r
+ rxRuntime->transferCount += segmentSize; //== bytesWrittenSuccessfully\r
ret = BUFREQ_OK;\r
break;\r
}\r
{\r
sduData[indexCount++] = ISO15765_TPCI_FC\r
| ISO15765_FLOW_CONTROL_STATUS_CTS;\r
- spaceFreePduRBuffer = rxRuntime->bufferPduRouter->SduLength -\r
+ spaceFreePduRBuffer = rxRuntime->pdurBuffer->SduLength -\r
rxRuntime->pdurBufferCount;\r
if (rxConfig->CanTpAddressingFormant == CANTP_EXTENDED) { /** @req CANTP094 *//** @req CANTP095 */\r
computedBs = spaceFreePduRBuffer / MAX_PAYLOAD_SF_EXT_ADDR + 1; // + 1 is for local buffer.\r
| ISO15765_FLOW_CONTROL_STATUS_WAIT;\r
pduInfo.SduLength = indexCount;\r
break;\r
- case BUFREQ_OVFL: //* qqq req: CanTp 081 */\r
+ case BUFREQ_OVFL: /** @req CANTP081 */\r
sduData[indexCount++] = ISO15765_TPCI_FC\r
| ISO15765_FLOW_CONTROL_STATUS_OVFLW;\r
pduInfo.SduLength = indexCount;\r
rxRuntime->mode = CANTP_RX_WAIT;\r
} else {\r
currentSegmentMaxSize = CANIF_PDU_MAX_LENGTH - indexCount;\r
- bytesLeftToCopy = rxRuntime->pduLenghtTotalBytes\r
- - rxRuntime->pduTransferedBytesCount;\r
+ bytesLeftToCopy = rxRuntime->transferTotal\r
+ - rxRuntime->transferCount;\r
if (bytesLeftToCopy < currentSegmentMaxSize) {\r
currentSegmentSize = bytesLeftToCopy; // 1-5.\r
} else {\r
sendFlowControlFrame(rxConfig, rxRuntime, ret); /** @req CANTP082 */\r
}\r
} else if (ret == BUFREQ_OK) {\r
- bytesLeftToTransfer = rxRuntime->pduLenghtTotalBytes - rxRuntime->pduTransferedBytesCount;\r
+ bytesLeftToTransfer = rxRuntime->transferTotal - rxRuntime->transferCount;\r
if (bytesLeftToTransfer > 0) {\r
rxRuntime->iso15765.framesHandledCount++;\r
COUNT_DECREMENT(rxRuntime->iso15765.nextFlowControlCount);\r
// Always copy from the PDUR buffer data to the canFrameBuffer because if\r
// we are unlucky the application give us very small buffers.\r
consecutiveFrameMaxPayload = CANIF_PDU_MAX_LENGTH - indexCount;\r
- remaningSduDataSize = txRuntime->pduLenghtTotalBytes\r
- - txRuntime->pduTransferedBytesCount;\r
+ remaningSduDataSize = txRuntime->transferTotal\r
+ - txRuntime->transferCount;\r
\r
// Calculate number of valid bytes that reside in this CF.\r
if ( remaningSduDataSize < consecutiveFrameMaxPayload ) {\r
}\r
copyCount = txRuntime->canFrameBuffer.byteCount; // maybe some bytes already reside in the buffer that we need to handle before proceeding with application buffer data.\r
while (copyCount < consecutiveFrameActualPayload) {\r
- if ( txRuntime->bufferPduRouter->SduLength > txRuntime->pdurBufferCount ) {\r
+ if ( txRuntime->pdurBuffer->SduLength > txRuntime->pdurBufferCount ) {\r
txRuntime->canFrameBuffer.data[copyCount] =\r
- txRuntime->bufferPduRouter->SduDataPtr[txRuntime->pdurBufferCount++];\r
+ txRuntime->pdurBuffer->SduDataPtr[txRuntime->pdurBufferCount++];\r
copyCount++;\r
txRuntime->canFrameBuffer.byteCount++;\r
} else {\r
BufReq_ReturnType pdurResp = PduR_CanTpProvideTxBuffer(txConfig->PduR_PduId, /** @req CANTP226 */ /** @req CANTP086 */ /** @req CANTP117 */\r
- &txRuntime->bufferPduRouter, 0);\r
+ &txRuntime->pdurBuffer, 0);\r
if (pdurResp == BUFREQ_OK) {\r
txRuntime->pdurBufferCount = 0;\r
continue;\r
// the scenario where the CAN queue is full.\r
txRuntime->iso15765.framesHandledCount++;\r
COUNT_DECREMENT(txRuntime->iso15765.nextFlowControlCount);\r
- txRuntime->pduTransferedBytesCount += txRuntime->canFrameBuffer.byteCount;\r
+ txRuntime->transferCount += txRuntime->canFrameBuffer.byteCount;\r
txRuntime->canFrameBuffer.byteCount = 0;\r
- DEBUG( DEBUG_MEDIUM, "pduTransferedBytesCount:%d\n", txRuntime->pduTransferedBytesCount);\r
+ DEBUG( DEBUG_MEDIUM, "transferCount:%d\n", txRuntime->transferCount);\r
}\r
} else {\r
DEBUG( DEBUG_MEDIUM, "Unexpected error, should not happen!\n");\r
static INLINE void handleConsecutiveFrameSent(\r
const CanTp_TxNSduType *txConfig, CanTp_ChannelPrivateType *txRuntime) {\r
\r
- if (txRuntime->pduLenghtTotalBytes <= txRuntime->pduTransferedBytesCount) {\r
+ if (txRuntime->transferTotal <= txRuntime->transferCount) {\r
// Transfer finished!\r
txRuntime->iso15765.state = IDLE;\r
txRuntime->mode = CANTP_TX_WAIT;\r
txRuntime->iso15765.BS = txPduData->SduDataPtr[indexCount++];\r
txRuntime->iso15765.nextFlowControlCount = txRuntime->iso15765.BS;\r
txRuntime->iso15765.STmin = txPduData->SduDataPtr[indexCount++];\r
+ DEBUG( DEBUG_MEDIUM, "txRuntime->iso15765.STmin = %d\n", txRuntime->iso15765.STmin);\r
ret = sendConsecutiveFrame(txConfig, txRuntime);\r
if (ret == E_OK) {\r
handleConsecutiveFrameSent(txConfig, txRuntime);\r
uint8 *data = NULL;\r
PduLengthType bytesWrittenToSduRBuffer;\r
\r
- DEBUG( DEBUG_MEDIUM, "handleSingleFrame called!\n");\r
+\r
if (rxRuntime->iso15765.state != IDLE) {\r
DEBUG( DEBUG_MEDIUM, "Single frame received and channel not IDLE!\n");\r
}\r
pduLength = getPduLength(&rxConfig->CanTpAddressingFormant, SINGLE_FRAME,\r
rxPduData);\r
\r
- VALIDATE_NO_RV( rxRuntime->bufferPduRouter->SduDataPtr != NULL,\r
+ VALIDATE_NO_RV( rxRuntime->pdurBuffer->SduDataPtr != NULL,\r
SERVICE_ID_CANTP_RX_INDICATION, CANTP_E_INVALID_RX_LENGTH );\r
\r
if (rxConfig->CanTpAddressingFormant == CANTP_STANDARD) { /** @req CANTP094 *//** @req CANTP095 */\r
} else {\r
data = &rxPduData->SduDataPtr[2];\r
}\r
- rxRuntime->pduLenghtTotalBytes = pduLength;\r
+ rxRuntime->transferTotal = pduLength;\r
rxRuntime->iso15765.state = SF_OR_FF_RECEIVED_WAITING_PDUR_BUFFER;\r
rxRuntime->mode = CANTP_RX_PROCESSING;\r
rxRuntime->iso15765.stateTimeoutCount =\r
(void) initRx15765RuntimeData(rxConfig, rxRuntime); /** @req CANTP124 */\r
pduLength = getPduLength(&rxConfig->CanTpAddressingFormant, FIRST_FRAME,\r
rxPduData);\r
- rxRuntime->pduLenghtTotalBytes = pduLength;\r
+ rxRuntime->transferTotal = pduLength;\r
\r
- VALIDATE_NO_RV( rxRuntime->pduLenghtTotalBytes != 0,\r
+ VALIDATE_NO_RV( rxRuntime->transferTotal != 0,\r
SERVICE_ID_CANTP_RX_INDICATION, CANTP_E_INVALID_RX_LENGTH );\r
\r
// Validate that that there is a reason for using the segmented transfers and\r
\r
Std_ReturnType ret;\r
if (txConfig->CanTpAddressingMode == CANTP_EXTENDED) {\r
- if ( txRuntime->pduLenghtTotalBytes > MAX_PAYLOAD_CF_EXT_ADDR ) {\r
+ if ( txRuntime->transferTotal > MAX_PAYLOAD_CF_EXT_ADDR ) {\r
VALIDATE( txConfig->CanTpTxTaType == CANTP_FUNCTIONAL,\r
SERVICE_ID_CANTP_TRANSMIT, CANTP_E_INVALID_TATYPE );\r
}\r
- if (txRuntime->pduLenghtTotalBytes > MAX_PAYLOAD_CF_EXT_ADDR) {\r
+ if (txRuntime->transferTotal > MAX_PAYLOAD_CF_EXT_ADDR) {\r
if (txConfig->CanTpTxTaType == CANTP_PHYSICAL) {\r
*iso15765Frame = FIRST_FRAME;\r
ret = E_OK;\r
ret = E_OK;\r
}\r
} else {\r
- if ( txRuntime->pduLenghtTotalBytes > MAX_PAYLOAD_CF_EXT_ADDR ) {\r
+ if ( txRuntime->transferTotal > MAX_PAYLOAD_CF_EXT_ADDR ) {\r
VALIDATE( txConfig->CanTpTxTaType == CANTP_FUNCTIONAL,\r
SERVICE_ID_CANTP_TRANSMIT, CANTP_E_INVALID_TATYPE );\r
}\r
- if (txRuntime->pduLenghtTotalBytes > MAX_PAYLOAD_CF_STD_ADDR) {\r
+ if (txRuntime->transferTotal > MAX_PAYLOAD_CF_STD_ADDR) {\r
if (txConfig->CanTpTxTaType == CANTP_PHYSICAL) {\r
*iso15765Frame = FIRST_FRAME;\r
ret = E_OK;\r
if (txConfig->CanTpAddressingMode == CANTP_EXTENDED) { /** @req CANTP094 *//** @req CANTP095 */\r
sduData[indexCount++] = (uint8) txConfig->CanTpNTa->CanTpNTa; // Target address.\r
}\r
- sduData[indexCount++] = ISO15765_TPCI_SF | txRuntime->pduLenghtTotalBytes;\r
- for (int i = 0; i < txRuntime->pduLenghtTotalBytes; i++) {\r
- sduData[indexCount++] = txRuntime->bufferPduRouter->SduDataPtr[i];\r
+ sduData[indexCount++] = ISO15765_TPCI_SF | txRuntime->transferTotal;\r
+ for (int i = 0; i < txRuntime->transferTotal; i++) {\r
+ sduData[indexCount++] = txRuntime->pdurBuffer->SduDataPtr[i];\r
}\r
\r
pduInfo.SduDataPtr = sduData;\r
sduData[indexCount++] = (uint8) txConfig->CanTpNTa->CanTpNTa; // Target address.\r
}\r
sduData[indexCount++] = ISO15765_TPCI_FF | (uint8)(\r
- (txRuntime->pduLenghtTotalBytes & 0xf00) >> 8);\r
- sduData[indexCount++] = (uint8)(txRuntime->pduLenghtTotalBytes & 0xff);\r
+ (txRuntime->transferTotal & 0xf00) >> 8);\r
+ sduData[indexCount++] = (uint8)(txRuntime->transferTotal & 0xff);\r
for (i = 0; indexCount < CANIF_PDU_MAX_LENGTH; i++) {\r
- sduData[indexCount++] = txRuntime->bufferPduRouter->SduDataPtr[i];\r
+ sduData[indexCount++] = txRuntime->pdurBuffer->SduDataPtr[i];\r
txRuntime->pdurBufferCount++;\r
- if (txRuntime->pdurBufferCount > txRuntime->bufferPduRouter->SduLength) {\r
+ if (txRuntime->pdurBufferCount > txRuntime->pdurBuffer->SduLength) {\r
// qqq: TODO: Report failure - this is unexpected.\r
}\r
- txRuntime->pduTransferedBytesCount++;\r
+ txRuntime->transferCount++;\r
}\r
pduInfo.SduDataPtr = sduData;\r
pduInfo.SduLength = indexCount;\r
ISO15765FrameType iso15765Frame = INVALID_FRAME;\r
\r
pdurResp = PduR_CanTpProvideTxBuffer(txConfig->PduR_PduId,\r
- &txRuntime->bufferPduRouter, 0); /** @req CANTP226 */ /** @req CANTP186 */\r
+ &txRuntime->pdurBuffer, 0); /** @req CANTP226 */ /** @req CANTP186 */\r
//if (txRuntime->iso15765.stateTimeoutCount != 0) { qqq: WHY WAS THIS DONE?\r
- VALIDATE( txRuntime->bufferPduRouter->SduDataPtr != NULL,\r
+ VALIDATE( txRuntime->pdurBuffer->SduDataPtr != NULL,\r
SERVICE_ID_CANTP_TRANSMIT, CANTP_E_INVALID_TX_BUFFER );\r
if (pdurResp == BUFREQ_OK) {\r
res = calcRequiredProtocolFrameType(txConfig, txRuntime, &iso15765Frame);\r
if (txRuntime->mode != CANTP_TX_PROCESSING) {\r
txRuntime->pdurBufferCount = 0;\r
txRuntime->pdurBufferCount = 0;\r
- txRuntime->pduTransferedBytesCount = 0;\r
+ txRuntime->transferCount = 0;\r
txRuntime->iso15765.framesHandledCount = 0;\r
- //txRuntime->iso15765->framesHandledCount = 0;\r
- txRuntime->pduLenghtTotalBytes = CanTpTxInfoPtr->SduLength; /** @req CANTP225 */\r
+ txRuntime->transferTotal = CanTpTxInfoPtr->SduLength; /** @req CANTP225 */\r
txRuntime->iso15765.stateTimeoutCount =\r
CANTP_CONVERT_MS_TO_MAIN_CYCLES(txConfig->CanTpNcs);\r
txRuntime->mode = CANTP_TX_PROCESSING;\r
handleSingleFrame(rxConfigParams, runtimeParams, CanTpRxPduPtr);\r
}\r
else\r
- DEBUG( DEBUG_MEDIUM, "Single frame received on ISO15765-Tx flow control - is ingnored!\n");\r
+ DEBUG( DEBUG_MEDIUM, "Single frame received on ISO15765-Tx flow control - is ignored!\n");\r
break;\r
}\r
case FIRST_FRAME: {\r
\r
// - - - - - - - - - - - - - -\r
\r
-void CanTp_Shutdown() /** req : CanTp202 **//** req : CanTp200 **//** req : CanTp211 **/ /** @req CANTP010 */\r
+void CanTp_Shutdown() /** req : CanTp202 **//** req : CanTp200 **//** req : CanTp211 **//** @req CANTP010 */\r
{\r
VALIDATE_NO_RV( CanTpRunTimeData.internalState == CANTP_ON,\r
SERVICE_ID_CANTP_SHUTDOWN, CANTP_E_UNINIT ); /** @req CANTP031 */\r
txRuntimeListItem->mode = CANTP_TX_WAIT;\r
break;\r
}\r
- case TX_WAIT_CAN_TP_TRANSMIT_PENDING:\r
+ case TX_WAIT_CAN_TP_TRANSMIT_PENDING: {\r
(void) canTpTransmitHelper(txConfigListItem, txRuntimeListItem);/** @req CANTP184 */ /** @req CANTP089 */\r
break;\r
- case TX_WAIT_SEND_CONSECUTIVE_FRAME:\r
- ret = sendConsecutiveFrame(txConfigListItem, txRuntimeListItem);\r
- /* qqq: TODO: We have a CAN error, put in log-file? */\r
- if ( ret == E_OK ) {\r
- handleConsecutiveFrameSent(txConfigListItem, txRuntimeListItem);\r
+ }\r
+ case TX_WAIT_SEND_CONSECUTIVE_FRAME: {\r
+ TIMER_DECREMENT (rxRuntimeListItem->iso15765.stateTimeoutCount); // Make sure that STmin timer has expired.\r
+ if (txRuntimeListItem->iso15765.stateTimeoutCount == 0) {\r
+ ret = sendConsecutiveFrame(txConfigListItem, txRuntimeListItem);\r
+ if ( ret == E_OK ) {\r
+ handleConsecutiveFrameSent(txConfigListItem, txRuntimeListItem);\r
+ } else {\r
+ DEBUG( DEBUG_MEDIUM, "ERROR: Consecutive frame could not be sent!\n");\r
+ PduR_CanTpTxConfirmation(txConfigListItem->PduR_PduId,\r
+ (NotifResultType) NTFRSLT_E_NOT_OK); /** @req CANTP204 */\r
+ txRuntimeListItem->iso15765.state = IDLE;\r
+ txRuntimeListItem->mode = CANTP_TX_WAIT;\r
+ }\r
} else {\r
- DEBUG( DEBUG_MEDIUM, "ERROR: Consecutive frame could not be sent!\n");\r
- PduR_CanTpTxConfirmation(txConfigListItem->PduR_PduId,\r
- (NotifResultType) NTFRSLT_E_NOT_OK); /** @req CANTP204 */\r
- txRuntimeListItem->iso15765.state = IDLE;\r
- txRuntimeListItem->mode = CANTP_TX_WAIT;\r
+ DEBUG( DEBUG_MEDIUM, "Waiting for STmin timer to expire!\n");\r
}\r
break;\r
+ }\r
case TX_WAIT_FLOW_CONTROL:\r
//DEBUG( DEBUG_MEDIUM, "Waiting for flow control!\n");\r
if (txRuntimeListItem->iso15765.stateTimeoutCount == 0) {\r
rxRuntimeListItem->canFrameBuffer.data,\r
rxRuntimeListItem->canFrameBuffer.byteCount,\r
&bytesWrittenToSduRBuffer);\r
- bytesRemaining = rxRuntimeListItem->pduLenghtTotalBytes -\r
- rxRuntimeListItem->pduTransferedBytesCount;\r
+ bytesRemaining = rxRuntimeListItem->transferTotal -\r
+ rxRuntimeListItem->transferCount;\r
if (bytesRemaining > 0) {\r
sendFlowControlFrame( rxConfigListItem, rxRuntimeListItem, ret ); /** @req CANTP224 (Busy or CTS) */\r
}\r
//\r
// This function implements the requirement @DCM139 when\r
// transition from one session to another.\r
-// qqq, strange observation: If S3 timeout we will not change security mode to\r
-// locked and that is how I interper the requirement.\r
//\r
void changeDiagnosticSession(Dcm_DslRunTimeProtocolParametersType *runtime,\r
Dcm_SesCtrlType newSession) {\r
+\r
+ /** @req DCM139 **/\r
+\r
switch (runtime->sessionControl) {\r
case DCM_DEFAULT_SESSION: // "default".\r
break;\r
\r
// - - - - - - - - - - -\r
\r
-Std_ReturnType DslGetActiveProtocol(Dcm_ProtocolType *protocolId) {\r
+Std_ReturnType DslGetActiveProtocol(Dcm_ProtocolType *protocolId) { /** @req DCM340 **/\r
Std_ReturnType ret = E_NOT_OK;\r
const Dcm_DslProtocolRowType *activeProtocol = NULL;\r
activeProtocol = DcmDslRunTimeData.activeProtocol;\r
\r
// - - - - - - - - - - -\r
\r
-void DslSetSecurityLevel(Dcm_SecLevelType secLevel) {\r
+void DslSetSecurityLevel(Dcm_SecLevelType secLevel) { /** @req DCM020 **/\r
const Dcm_DslProtocolRowType *activeProtocol = NULL;\r
Dcm_DslRunTimeProtocolParametersType *runtime = NULL;\r
activeProtocol = DcmDslRunTimeData.activeProtocol;\r
\r
// - - - - - - - - - - -\r
\r
-Std_ReturnType DslGetSecurityLevel(Dcm_SecLevelType *secLevel) {\r
+Std_ReturnType DslGetSecurityLevel(Dcm_SecLevelType *secLevel) { /** @req DCM020 **//** @req DCM338 **/\r
Std_ReturnType ret = E_NOT_OK;\r
const Dcm_DslProtocolRowType *activeProtocol = NULL;\r
Dcm_DslRunTimeProtocolParametersType *runtime = NULL;\r
\r
// - - - - - - - - - - -\r
\r
-void DslSetSesCtrlType(Dcm_SesCtrlType sesCtrl) {\r
+void DslSetSesCtrlType(Dcm_SesCtrlType sesCtrl) { /** @req DCM022 **/\r
const Dcm_DslProtocolRowType *activeProtocol = NULL;\r
Dcm_DslRunTimeProtocolParametersType *runtime = NULL;\r
activeProtocol = DcmDslRunTimeData.activeProtocol;\r
\r
// - - - - - - - - - - -\r
\r
-Std_ReturnType DslGetSesCtrlType(Dcm_SesCtrlType *sesCtrlType) {\r
+Std_ReturnType DslGetSesCtrlType(Dcm_SesCtrlType *sesCtrlType) { /** @req DCM022 **//** @req DCM339 **/\r
Std_ReturnType ret = E_NOT_OK;\r
const Dcm_DslProtocolRowType *activeProtocol = NULL;\r
Dcm_DslRunTimeProtocolParametersType *runtime = NULL;\r
}\r
}\r
\r
+// - - - - - - - - - - -\r
+\r
/*\r
* This function is called from the DSD module to the DSL when\r
* a response to a diagnostic request has been copied into the\r
const Dcm_DslProtocolRowType *protocolRow = NULL;\r
Dcm_DslRunTimeProtocolParametersType *runtime = NULL;\r
\r
+\r
+\r
DEBUG( DEBUG_MEDIUM, "DslDsdProcessingDone rxPduIdRef=%d\n", rxPduIdRef);\r
\r
if (findRxPduIdParentConfigurationLeafs(rxPduIdRef, &protocolRx, &mainConnection,\r
imask_t state = McuE_EnterCriticalSection();\r
switch (responseResult) {\r
case DSD_TX_RESPONSE_READY:\r
- runtime->externalTxBufferStatus = DSD_PENDING_RESPONSE_SIGNALED;\r
+ runtime->externalTxBufferStatus = DSD_PENDING_RESPONSE_SIGNALED; /** @req DCM114 **/\r
break;\r
case DSD_TX_RESPONSE_SUPPRESSED:\r
releaseExternalRxTxBuffersHelper(rxPduIdRef);\r
const Dcm_DslProtocolRowType *protocolRow = NULL;\r
Dcm_DslRunTimeProtocolParametersType *runtime = NULL;\r
\r
+ /** @req DCM119 **/\r
imask_t state = McuE_EnterCriticalSection();\r
if (findRxPduIdParentConfigurationLeafs(protocol->DslRunTimeProtocolParameters->diagReqestRxPduId, &protocolRx, &mainConnection, &connection, &protocolRow, &runtime)) {\r
if (runtime->localTxBuffer.status == NOT_IN_USE) {\r
- runtime->localTxBuffer.status = PROVIDED_TO_DSD; // For readability (yes, it will later be overwritten).\r
+ runtime->localTxBuffer.status = PROVIDED_TO_DSD;\r
runtime->localTxBuffer.buffer[0] = SID_NEGATIVE_RESPONSE;\r
runtime->localTxBuffer.buffer[1] = protocol->DslProtocolRxBufferID->pduInfo.SduDataPtr[2];\r
- runtime->localTxBuffer.buffer[2] = responseCode; // 0x78.\r
+ runtime->localTxBuffer.buffer[2] = responseCode;\r
runtime->localTxBuffer.PduInfo.SduDataPtr = runtime->localTxBuffer.buffer;\r
runtime->localTxBuffer.PduInfo.SduLength = 3;\r
- runtime->localTxBuffer.status = DCM_TRANSMIT_SIGNALED; // In the DslProvideTxBuffer 'callback' this state signals it is the local buffer we are intressted in sending.\r
- PduR_DcmTransmit(mainConnection->DslProtocolTx->DcmDslProtocolTxPduId, &(runtime->localTxBuffer.PduInfo));\r
+ runtime->localTxBuffer.status = DCM_TRANSMIT_SIGNALED; // In the DslProvideTxBuffer 'callback' this state signals it is the local buffer we are interested in sending.\r
+ PduR_DcmTransmit(mainConnection->DslProtocolTx->DcmDslProtocolTxPduId,\r
+ &(runtime->localTxBuffer.PduInfo));/** @req DCM115, the P2ServerMin has not been implemented. **/\r
}\r
}\r
McuE_ExitCriticalSection(state);\r
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -\r
// Implements 'void Dcm_Init(void)' for DSL.\r
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -\r
-void DslInit(void) {\r
+void DslInit(void) { /** @req DCM037 - for DSL submodule. **/\r
const Dcm_DslProtocolRowType *listEntry = NULL;\r
Dcm_DslRunTimeProtocolParametersType *runtime = NULL;\r
\r
runtime->externalTxBufferStatus = DCM_IDLE;\r
runtime->localRxBuffer.status = DCM_IDLE;\r
runtime->localTxBuffer.status = DCM_IDLE;\r
- runtime->securityLevel = DCM_SEC_LEV_LOCKED;\r
+ runtime->securityLevel = DCM_SEC_LEV_LOCKED; /** @req DCM033 **/\r
runtime->sessionControl = DCM_DEFAULT_SESSION;\r
listEntry->DslProtocolRxBufferID->externalBufferRuntimeData->status\r
= BUFFER_AVAILABLE;\r
if (runtime->sessionControl != DCM_DEFAULT_SESSION) { // Timeout if tester present is lost.\r
DECREMENT(runtime->S3ServerTimeoutCount);\r
if (runtime->S3ServerTimeoutCount == 0) {\r
- changeDiagnosticSession(runtime, DCM_DEFAULT_SESSION);\r
+ changeDiagnosticSession(runtime, DCM_DEFAULT_SESSION); /** @req DCM140 **/\r
}\r
}\r
switch (runtime->externalTxBufferStatus) { // #### TX buffer state. ####\r
if (DCM_Config.Dsl->DslDiagResp != NULL) {\r
if (DCM_Config.Dsl->DslDiagResp->DslDiagRespForceRespPendEn == TRUE) {\r
if (runtime->responsePendingCount != 0) {\r
- DEBUG( DEBUG_MEDIUM, "No response withing timeout, sending response pending!\n");\r
- sendResponse(protocolRowEntry, DCM_E_RESPONSEPENDING);\r
+ sendResponse(protocolRowEntry, DCM_E_RESPONSEPENDING); /** @req DCM024 **/\r
DECREMENT( runtime->responsePendingCount );\r
} else {\r
- DEBUG( DEBUG_MEDIUM, "Sent all response pending, now sending general reject!\n");\r
- sendResponse(protocolRowEntry, DCM_E_GENERALREJECT);\r
+ sendResponse(protocolRowEntry, DCM_E_GENERALREJECT); /** @req DCM120 **/\r
releaseExternalRxTxBuffers(protocolRowEntry, runtime);\r
}\r
} else {\r
// Make sure that response pending or general reject have not been issued,\r
// if so we can not transmit to PduR because we would not know from where\r
// the Tx confirmation resides later.\r
- DEBUG( DEBUG_MEDIUM, "Current polite index=debug_count=%d\n", debug_count);\r
DEBUG( DEBUG_MEDIUM, "state DSD_PENDING_RESPONSE_SIGNALED!\n");\r
if (runtime->localTxBuffer.status == NOT_IN_USE) {\r
+ int ii;\r
const Dcm_DslProtocolRxType *protocolRx = NULL;\r
const Dcm_DslMainConnectionType *mainConnection = NULL;\r
const Dcm_DslConnectionType *connection = NULL;\r
const Dcm_DslProtocolRowType *protocolRow = NULL;\r
if (findRxPduIdParentConfigurationLeafs(runtime->diagReqestRxPduId, &protocolRx, &mainConnection, &connection, &protocolRow, &runtime)) {\r
const uint32 txPduId = mainConnection->DslProtocolTx->DcmDslProtocolTxPduId;\r
- DEBUG( DEBUG_MEDIUM, "runtime->externalTxBufferStatus enter state DSD_PENDING_RESPONSE_SIGNALED.\n", txPduId);\r
+ DEBUG( DEBUG_MEDIUM, "runtime->externalTxBufferStatus enter state DCM_TRANSMIT_SIGNALED.\n" );\r
runtime->externalTxBufferStatus = DCM_TRANSMIT_SIGNALED;\r
- DEBUG( DEBUG_MEDIUM, "Calling PduR_DcmTransmit with txPduId = %d from DslMain\n", txPduId);\r
+\r
+ DEBUG( DEBUG_MEDIUM, "DO NOT CHECK INTO REPO: **** FAKING DSD RESPONSE TO BE 50 bytes !!!!! ********\n", txPduId);\r
+ runtime->diagnosticResponseFromDsd.SduLength = runtime->diagnosticRequestFromTester.SduLength;\r
+ for (ii=0; ii<runtime->diagnosticRequestFromTester.SduLength; ii++) {\r
+ runtime->diagnosticResponseFromDsd.SduDataPtr[ii] =\r
+ runtime->diagnosticRequestFromTester.SduDataPtr[ii];\r
+ }\r
+\r
+\r
PduR_DcmTransmit(txPduId, &runtime->diagnosticResponseFromDsd); /** @req DCM237 **//* Will trigger PduR (CanTP) to call DslProvideTxBuffer(). */\r
} else {\r
+ DEBUG( DEBUG_MEDIUM, "***** WARNING, THIS IS UNEXPECTED !!! ********.\n" );\r
const uint32 txPduId = protocolRowEntry->DslConnection->DslMainConnection->DslProtocolTx->DcmDslProtocolTxPduId;\r
DEBUG( DEBUG_MEDIUM, "runtime->externalTxBufferStatus enter state DSD_PENDING_RESPONSE_SIGNALED.\n", txPduId);\r
runtime->externalTxBufferStatus = DCM_TRANSMIT_SIGNALED;\r
// received a FF or a single frame and needs to obtain a buffer from the\r
// receiver so that received data can be forwarded.\r
\r
-BufReq_ReturnType DslProvideRxBufferToPdur(PduIdType dcmRxPduId,\r
+BufReq_ReturnType DslProvideRxBufferToPdur(PduIdType dcmRxPduId, /** @req DCM094 **/\r
PduLengthType tpSduLength, const PduInfoType **pduInfoPtr) {\r
BufReq_ReturnType ret = BUFREQ_NOT_OK;\r
const Dcm_DslProtocolRxType *protocolRx = NULL;\r
&connection, &protocolRow, &runtime)) {\r
const Dcm_DslBufferType *externalRxBuffer =\r
protocolRow->DslProtocolRxBufferID;\r
- if (externalRxBuffer->pduInfo.SduLength >= tpSduLength) { // First validate that we have a chance receiving the chunk of data.\r
+ if (externalRxBuffer->pduInfo.SduLength >= tpSduLength) { /** @req DCM443 **/\r
if ((runtime->externalRxBufferStatus == NOT_IN_USE)\r
&& (externalRxBuffer->externalBufferRuntimeData->status\r
== BUFFER_AVAILABLE)) {\r
runtime->diagnosticRequestFromTester.SduLength = tpSduLength;\r
//*pduInfoPtr = &(externalRxBuffer->pduInfo);\r
*pduInfoPtr = &(runtime->diagnosticRequestFromTester);\r
- runtime->externalRxBufferStatus = PROVIDED_TO_PDUR;\r
+ runtime->externalRxBufferStatus = PROVIDED_TO_PDUR; /** @req DCM342 **/\r
ret = BUFREQ_OK;\r
} else {\r
DEBUG( DEBUG_MEDIUM, "Local buffer available!\n");\r
// The buffer is in use by the PduR, we can not help this because then\r
// we would have two different Rx-indications with same PduId but we\r
// will not know which buffer the indication should free.\r
- ret = BUFREQ_BUSY;\r
+ ret = BUFREQ_BUSY; /** @req DCM445 **/\r
}\r
}\r
} else {\r
- ret = BUFREQ_OVFL; // Required size is too big.\r
+ ret = BUFREQ_OVFL; /** @req DCM444 **/\r
}\r
if (ret == BUFREQ_OK) {\r
- stopS3SessionTimer(runtime); /** req: DCM141 **/\r
+ stopS3SessionTimer(runtime); /** @req DCM141 **/\r
}\r
}\r
McuE_ExitCriticalSection(state);\r
// received the diagnostic request, copied it to the provided buffer and need to indicate\r
// this to the DCM (DSL) module via propritary API.\r
\r
-void DslRxIndicationFromPduR(PduIdType dcmRxPduId, NotifResultType result) {\r
+void DslRxIndicationFromPduR(PduIdType dcmRxPduId, NotifResultType result) { /** @req DCM093 **/\r
const Dcm_DslProtocolRxType *protocolRx = NULL;\r
const Dcm_DslMainConnectionType *mainConnection = NULL;\r
const Dcm_DslConnectionType *connection = NULL;\r
Std_ReturnType higherLayerResp;\r
imask_t state;\r
\r
- // qqq: handle the actual result code.\r
+ /** @req DCM345, this needs to be verified when connection to CanIf works. **/\r
+\r
if (findRxPduIdParentConfigurationLeafs(dcmRxPduId, &protocolRx, &mainConnection,\r
&connection, &protocolRow, &runtime)) {\r
timeParams = protocolRow->DslProtocolTimeLimit;\r
// We need to find out in what buffer we can find our Rx data (it can\r
// be either in the normal RX-buffer or the 'extra' buffer for implementing\r
// the Concurrent "Test Present" functionality.\r
+ state = McuE_EnterCriticalSection();\r
if (runtime->externalRxBufferStatus == PROVIDED_TO_PDUR) {\r
- if (isTesterPresentCommand(\r
- &(protocolRow->DslProtocolRxBufferID->pduInfo))) {\r
- state = McuE_EnterCriticalSection();\r
- startS3SessionTimer(runtime, protocolRow); /** @req DCM141 **//** @req DCM112 **//** @req DCM113 **/\r
- runtime->externalRxBufferStatus = NOT_IN_USE;\r
- protocolRow->DslProtocolRxBufferID->externalBufferRuntimeData->status = BUFFER_AVAILABLE;\r
- McuE_ExitCriticalSection(state);\r
- } else {\r
- if (runtime->protocolStarted == FALSE) {\r
- higherLayerResp = StartProtocolHelper(\r
- protocolRow->DslProtocolID);\r
- if (higherLayerResp == E_OK) {\r
- runtime->protocolStarted = TRUE;\r
- DcmDslRunTimeData.activeProtocol = protocolRow;\r
+ if ( result == NTFRSLT_OK ) { /** @req DCM111 **/\r
+ if (isTesterPresentCommand(\r
+ &(protocolRow->DslProtocolRxBufferID->pduInfo))) {\r
+ startS3SessionTimer(runtime, protocolRow); /** @req DCM141 **//** @req DCM112 **//** @req DCM113 **/\r
+ runtime->externalRxBufferStatus = NOT_IN_USE;\r
+ protocolRow->DslProtocolRxBufferID->externalBufferRuntimeData->status = BUFFER_AVAILABLE;\r
+ } else {\r
+ if (runtime->protocolStarted == FALSE) {\r
+ higherLayerResp = StartProtocolHelper(\r
+ protocolRow->DslProtocolID); /** @req DCM036 **/\r
+ if (higherLayerResp == E_OK) {\r
+ runtime->protocolStarted = TRUE;\r
+ DcmDslRunTimeData.activeProtocol = protocolRow;\r
+ }\r
}\r
- }\r
- if (runtime->protocolStarted == TRUE) {\r
- if (runtime->diagnosticActiveComM == FALSE) {\r
- ComM_DCM_ActivateDiagnostic(); /* @DCM163 */\r
- runtime->diagnosticActiveComM = TRUE;\r
+ if (runtime->protocolStarted == TRUE) {\r
+ if (runtime->diagnosticActiveComM == FALSE) {\r
+ ComM_DCM_ActivateDiagnostic(); /* @DCM163 */\r
+ runtime->diagnosticActiveComM = TRUE;\r
+ }\r
+ runtime->stateTimeoutCount = DCM_CONVERT_MS_TO_MAIN_CYCLES(\r
+ timeParams->TimStrP2ServerMax); /* See 9.2.2. */\r
+ runtime->externalRxBufferStatus = PROVIDED_TO_DSD; /** @req DCM241 **/\r
+ runtime->externalTxBufferStatus = PROVIDED_TO_DSD; /** @req DCM241 **/\r
+ timeParams = protocolRow->DslProtocolTimeLimit;\r
+ runtime->stateTimeoutCount = DCM_CONVERT_MS_TO_MAIN_CYCLES(\r
+ timeParams->TimStrP2ServerMax); /* Reinitiate timer, see 9.2.2. */\r
+ runtime->responsePendingCount = DCM_Config.Dsl->DslDiagResp->DslDiagRespMaxNumRespPend;\r
+ runtime->diagnosticResponseFromDsd.SduDataPtr\r
+ = protocolRow->DslProtocolTxBufferID->pduInfo.SduDataPtr;\r
+ runtime->diagnosticResponseFromDsd.SduLength\r
+ = protocolRow->DslProtocolTxBufferID->pduInfo.SduLength;\r
+ DEBUG( DEBUG_MEDIUM, "DsdDslDataIndication(DcmDslProtocolTxPduId=%d, dcmRxPduId=%d)\n",\r
+ mainConnection->DslProtocolTx->DcmDslProtocolTxPduId, dcmRxPduId);\r
+ runtime->diagReqestRxPduId = dcmRxPduId;\r
+ DsdDslDataIndication( // qqq: We are in a critical section, how much time will this consume?\r
+ &(runtime->diagnosticRequestFromTester),\r
+ protocolRow->DslProtocolSIDTable,\r
+ protocolRx->DslProtocolAddrType,\r
+ mainConnection->DslProtocolTx->DcmDslProtocolTxPduId,\r
+ &(runtime->diagnosticResponseFromDsd),\r
+ dcmRxPduId);\r
}\r
- state = McuE_EnterCriticalSection();\r
- runtime->stateTimeoutCount = DCM_CONVERT_MS_TO_MAIN_CYCLES(\r
- timeParams->TimStrP2ServerMax); /* See 9.2.2. */\r
- runtime->externalRxBufferStatus = PROVIDED_TO_DSD;\r
- runtime->externalTxBufferStatus = PROVIDED_TO_DSD; // Used in main.\r
- timeParams = protocolRow->DslProtocolTimeLimit;\r
- runtime->stateTimeoutCount = DCM_CONVERT_MS_TO_MAIN_CYCLES(\r
- timeParams->TimStrP2ServerMax); /* Reinitiate timer, see 9.2.2. */\r
- runtime->responsePendingCount = DCM_Config.Dsl->DslDiagResp->DslDiagRespMaxNumRespPend; // qqq ugly.\r
- McuE_ExitCriticalSection(state);\r
- runtime->diagnosticResponseFromDsd.SduDataPtr\r
- = protocolRow->DslProtocolTxBufferID->pduInfo.SduDataPtr;\r
- runtime->diagnosticResponseFromDsd.SduLength\r
- = protocolRow->DslProtocolTxBufferID->pduInfo.SduLength;\r
- DEBUG( DEBUG_MEDIUM, "DsdDslDataIndication(DcmDslProtocolTxPduId=%d, dcmRxPduId=%d)\n",\r
- mainConnection->DslProtocolTx->DcmDslProtocolTxPduId, dcmRxPduId);\r
- runtime->diagReqestRxPduId = dcmRxPduId;\r
- DsdDslDataIndication(\r
- &(runtime->diagnosticRequestFromTester),\r
- protocolRow->DslProtocolSIDTable,\r
- protocolRx->DslProtocolAddrType,\r
- mainConnection->DslProtocolTx->DcmDslProtocolTxPduId,\r
- &(runtime->diagnosticResponseFromDsd),\r
- dcmRxPduId);\r
}\r
+ } else { /** @req DCM344 **/\r
+ // The indication was not equal to NTFRSLT_OK, release the resources and no forward to DSD.\r
+ runtime->externalRxBufferStatus = NOT_IN_USE;\r
+ protocolRow->DslProtocolRxBufferID->externalBufferRuntimeData->status = BUFFER_AVAILABLE;\r
}\r
} else {\r
// It is the local buffer that was provided to the PduR, that buffer\r
// is only used for tester present reception in parallel to diagnostic\r
// requests.\r
- state = McuE_EnterCriticalSection();\r
if (runtime->localRxBuffer.status == PROVIDED_TO_PDUR) {\r
- if (isTesterPresentCommand(&(runtime->localRxBuffer.PduInfo))) {\r
- startS3SessionTimer(runtime, protocolRow); /** @req DCM141 **//** @req DCM112 **//** @req DCM113 **/\r
+ if ( result == NTFRSLT_OK ) { // Make sure that the data in buffer is valid.\r
+ if (isTesterPresentCommand(&(runtime->localRxBuffer.PduInfo))) {\r
+ startS3SessionTimer(runtime, protocolRow); /** @req DCM141 **//** @req DCM112 **//** @req DCM113 **/\r
+ }\r
}\r
runtime->localRxBuffer.status = NOT_IN_USE;\r
}\r
- McuE_ExitCriticalSection(state);\r
}\r
+ McuE_ExitCriticalSection(state);\r
}\r
}\r
\r
// it has detected that the pending request has been answered by DSD\r
// (or any other module?).\r
\r
-BufReq_ReturnType DslProvideTxBuffer(PduIdType dcmTxPduId,\r
+BufReq_ReturnType DslProvideTxBuffer(PduIdType dcmTxPduId, /** @req DCM092 **/\r
const PduInfoType **pduInfoPtr, PduLengthType length) {\r
BufReq_ReturnType ret = BUFREQ_NOT_OK;\r
const Dcm_DslProtocolTxType *protocolTx = NULL;\r
&connection, &protocolRow, &runtime)) {\r
switch (runtime->externalTxBufferStatus) { // ### EXTERNAL TX BUFFER ###\r
case DCM_TRANSMIT_SIGNALED: {\r
+ /** @req DCM346 - length verification is already done if this state is reached. **/\r
*pduInfoPtr = &(protocolRow->DslProtocolTxBufferID->pduInfo);\r
- runtime->externalTxBufferStatus = PROVIDED_TO_PDUR;\r
+ runtime->externalTxBufferStatus = PROVIDED_TO_PDUR; /** @req DCM349 **/\r
ret = BUFREQ_OK;\r
break;\r
}\r
case PROVIDED_TO_PDUR: {\r
ComM_DCM_InactivateDiagnostic();\r
startS3SessionTimer(runtime, protocolRow); // @DCM141\r
- releaseExternalRxTxBuffers(protocolRow, runtime);\r
- /*\r
- protocolRow->DslProtocolTxBufferID->externalBufferRuntimeData->status\r
- = BUFFER_AVAILABLE;\r
- protocolRow->DslProtocolRxBufferID->externalBufferRuntimeData->status\r
- = BUFFER_AVAILABLE;\r
- runtime->externalTxBufferStatus = DCM_IDLE;\r
- runtime->externalRxBufferStatus = DCM_IDLE;\r
- */\r
- DEBUG( DEBUG_MEDIUM, "Released external buffer sucessfully!\n");\r
+ releaseExternalRxTxBuffers(protocolRow, runtime); /** @req DCM118 **//** @req DCM353 **//** @req DCM354 **/\r
externalBufferReleased = TRUE;\r
-\r
+ DEBUG( DEBUG_MEDIUM, "Released external buffer OK!\n");\r
DsdDataConfirmation(mainConnection->DslProtocolTx->DcmDslProtocolTxPduId, result); /** @req DCM117 **//** @req DCM235 **/\r
-\r
-\r
break;\r
}\r
default:\r
if (externalBufferReleased == FALSE) {\r
switch (runtime->localTxBuffer.status) { // ### LOCAL TX BUFFER ###\r
case PROVIDED_TO_PDUR:\r
- DEBUG( DEBUG_MEDIUM, "Released local buffer buffer!\n");\r
+ DEBUG( DEBUG_MEDIUM, "Released local buffer buffer OK!\n");\r
runtime->localTxBuffer.status = DCM_IDLE;\r
break;\r
default:\r
- DEBUG( DEBUG_MEDIUM, "WARNING! DslTxConfirmation could not release any buffer!\n");\r
+ DEBUG( DEBUG_MEDIUM, "WARNING! DslTxConfirmation could not release external or local buffer!\n");\r
break;\r
}\r
}\r