*\r
* This source code is free software; you can redistribute it and/or modify it\r
* under the terms of the GNU General Public License version 2 as published by the\r
- * Free Software Foundation; See <http://www.gnu.org/licenses/old-licenses/gpl-2.0.txt>.\r
+ * Free Software Foundation; See <http://www.gnu.org/licenses/old-licenses/gpl-2.0.txt>. \r
*\r
* This program is distributed in the hope that it will be useful, but\r
* WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY\r
return;\r
}\r
\r
+ rxRuntime->iso15765.framesHandledCount++; // First expected is one (1) according to Movimento Puma.\r
rxRuntime->iso15765.state = SF_OR_FF_RECEIVED_WAITING_PDUR_BUFFER;\r
rxRuntime->mode = CANTP_RX_PROCESSING;\r
rxRuntime->iso15765.stateTimeoutCount =\r
txRuntime->mode = CANTP_TX_WAIT;\r
break;\r
case FIRST_FRAME:\r
+ txRuntime->iso15765.stateTimeoutCount = CANTP_CONVERT_MS_TO_MAIN_CYCLES(txConfig->CanTpNbs * 1000); /*CanTp: 264*/\r
txRuntime->iso15765.state = TX_WAIT_FLOW_CONTROL;\r
res = sendFirstFrame(txConfig, txRuntime); /* req: CanTp 232 */\r
if (res == E_OK) {\r
case SINGLE_FRAME: {\r
if (rxConfigParams != NULL)\r
handleSingleFrame(rxConfigParams, runtimeParams, CanTpRxPduPtr);\r
- else\r
- DEBUG( DEBUG_LOW, "Single frame received on ISO15765-Tx flow control - is ingnored!\n");\r
+ else\r
+ DEBUG( DEBUG_MEDIUM, "Single frame received on ISO15765-Tx flow control - is ingnored!\n");\r
break;\r
}\r
case FIRST_FRAME: {\r
if (rxConfigParams != NULL)\r
handleFirstFrame(rxConfigParams, runtimeParams, CanTpRxPduPtr);\r
- else\r
- DEBUG( DEBUG_LOW, "First frame received on ISO15765-Tx flow control - is ignored!\n");\r
+ else\r
+ DEBUG( DEBUG_MEDIUM, "First frame received on ISO15765-Tx flow control - is ignored!\n");\r
break;\r
}\r
case CONSECUTIVE_FRAME: {\r
if (rxConfigParams != NULL)\r
handleConsecutiveFrame(rxConfigParams, runtimeParams, CanTpRxPduPtr);\r
- else\r
- DEBUG( DEBUG_LOW, "Consecutive frame received on ISO15765-Tx flow control - is ignored!\n");\r
+ else\r
+ DEBUG( DEBUG_MEDIUM, "Consecutive frame received on ISO15765-Tx flow control - is ignored!\n");\r
break;\r
}\r
case FLOW_CONTROL_CTS_FRAME: {\r
if (txConfigParams != NULL)\r
handleFlowControlFrame(txConfigParams, runtimeParams, CanTpRxPduPtr);\r
+ else\r
+ DEBUG( DEBUG_MEDIUM, "Consecutive frame received on ISO15765-Tx flow control - is ignored!\n");\r
break;\r
}\r
case INVALID_FRAME: {\r
\r
void CanTp_MainFunction() /** req : CanTp213 **/\r
{\r
- BufReq_ReturnType ret;\r
+ BufReq_ReturnType ret;\r
CanTpFifoQueueItem item;\r
PduLengthType bytesWrittenToSduRBuffer;\r
\r
}\r
break;\r
case TX_WAIT_FLOW_CONTROL:\r
- if (txRuntimeListItem->iso15765.stateTimeoutCount == 0)\r
+ if (txRuntimeListItem->iso15765.stateTimeoutCount == 0) {\r
+ DEBUG( DEBUG_MEDIUM, "State TX_WAIT_FLOW_CONTROL timed out!\n");\r
PduR_CanTpTxConfirmation(txConfigListItem->PduR_CanTpTxPduId,\r
NTFRSLT_NOT_OK); /* qqq: req: CanTp: 185. */\r
+ txRuntimeListItem->iso15765.state = IDLE;\r
+ }\r
break;\r
default:\r
break;\r
;\r
}\r
\r
-void _DsdDslDataIndication(const PduInfoType *pduRxData,\r
- const Dcm_DsdServiceTableType *protocolSIDTable,\r
- Dcm_ProtocolAddrTypeType addrType,\r
- PduIdType rxPduIdRef,\r
- PduInfoType *pduTxData) {\r
- DEBUG( DEBUG_MEDIUM, "_DsdDslDataIndication called!\n");\r
-\r
- DEBUG( DEBUG_MEDIUM, "pduRxData->SduLength = %d\n", pduRxData->SduLength );\r
- for (int i=0; i < pduRxData->SduLength; i++) {\r
- DEBUG( DEBUG_MEDIUM, "Data[%d] = %02x\n", i, pduRxData->SduDataPtr[i] );\r
- }\r
-\r
- uint8 *p;\r
-\r
- pduTxData->SduLength = 5;\r
- p = pduTxData->SduDataPtr;\r
-\r
-\r
- for (int i=0; i<pduTxData->SduLength; i++) {\r
- *p = i;\r
- p++;\r
- }\r
-\r
- // Simulate a diagnostic response.\r
- DslDsdProcessingDone(rxPduIdRef, DSD_TX_RESPONSE_READY);\r
-\r
-}\r
-\r
// ################# HELPER FUNCTIONS START #################\r
\r
//\r
\r
// - - - - - - - - - - -\r
\r
+#if 1\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
+ switch (runtime->sessionControl) {\r
+ case DCM_DEFAULT_SESSION: // "default".\r
+ break;\r
+\r
+ case DCM_PROGRAMMING_SESSION:\r
+ case DCM_EXTENDED_DIAGNOSTIC_SESSION:\r
+ case DCM_SAFTEY_SYSTEM_DIAGNOSTIC_SESSION:\r
+ case DCM_ALL_SESSION_LEVEL:\r
+ runtime->securityLevel = DCM_SEC_LEV_LOCKED; // "0x00".\r
+ break;\r
+\r
+ default:\r
+ // TODO: Log this error.\r
+ DEBUG(DEBUG_MEDIUM, "Old session invalid")\r
+ break;\r
+ }\r
+\r
+ switch (newSession) {\r
+ case DCM_DEFAULT_SESSION: // "default".\r
+ case DCM_PROGRAMMING_SESSION:\r
+ case DCM_EXTENDED_DIAGNOSTIC_SESSION:\r
+ case DCM_SAFTEY_SYSTEM_DIAGNOSTIC_SESSION:\r
+ case DCM_ALL_SESSION_LEVEL:\r
+ runtime->sessionControl = newSession;\r
+ break;\r
+\r
+ default:\r
+ // TODO: Log this error.\r
+ DEBUG(DEBUG_MEDIUM, "New session invalid")\r
+ break;\r
+ }\r
+}\r
+#else\r
//\r
// This function implements the requirement @DCM139 when\r
// transition from one session to another.\r
break;\r
}\r
}\r
-\r
+#endif\r
\r
// - - - - - - - - - - -\r
\r
Dcm_DslRunTimeProtocolParametersType *runtime = NULL;\r
\r
DEBUG( DEBUG_MEDIUM, "DslDsdProcessingDone!\n");\r
+\r
if (findParentConfigurationLeafs(rxPduIdRef, &protocolRx, &mainConnection,\r
&connection, &protocolRow, &runtime)) {\r
imask_t state = McuE_EnterCriticalSection();\r
if (runtime->localTxBuffer.status == NOT_IN_USE) {\r
const uint32 txPduId =\r
protocolRowEntry->DslConnection->DslMainConnection->DslProtocolTx->PduR_DcmDslTxPduId;\r
+ DEBUG( DEBUG_MEDIUM, "runtime->externalTxBufferStatus enter state DSD_PENDING_RESPONSE_SIGNALED.", txPduId);\r
runtime->externalTxBufferStatus = DCM_TRANSMIT_SIGNALED;\r
+ DEBUG( DEBUG_MEDIUM, "Calling PduR_DcmTransmit with txPduId = %d\n", txPduId);\r
PduR_DcmTransmit(txPduId, &runtime->diagnosticResponseFromDsd); /** @req DCM237 **//* Will trigger PduR (CanTP) to call DslProvideTxBuffer(). */\r
}\r
break;\r
case DCM_TRANSMIT_SIGNALED:\r
- DEBUG( DEBUG_MEDIUM, "state DSD_PENDING_RESPONSE_SIGNALED!\n");\r
+ //DEBUG( DEBUG_MEDIUM, "state DSD_PENDING_RESPONSE_SIGNALED!\n");\r
break;\r
case PROVIDED_TO_PDUR: // The valid data is being transmitted by TP-layer.\r
- DEBUG( DEBUG_MEDIUM, "state DSD_PENDING_RESPONSE_SIGNALED!\n");\r
+ //DEBUG( DEBUG_MEDIUM, "state DSD_PENDING_RESPONSE_SIGNALED!\n");\r
break;\r
default:\r
break;\r
const Dcm_DslProtocolRowType *protocolRow = NULL;\r
Dcm_DslRunTimeProtocolParametersType *runtime = NULL;\r
\r
- DEBUG( DEBUG_MEDIUM, "DslProvideRxBufferToPdur called!\n");\r
+ DEBUG( DEBUG_MEDIUM, "DslProvideRxBufferToPdur called!\n");\r
imask_t state = McuE_EnterCriticalSection();\r
if (findParentConfigurationLeafs(dcmRxPduId, &protocolRx, &mainConnection,\r
&connection, &protocolRow, &runtime)) {\r
if ((runtime->externalRxBufferStatus == NOT_IN_USE)\r
&& (externalRxBuffer->externalBufferRuntimeData->status\r
== BUFFER_AVAILABLE)) {\r
- DEBUG( DEBUG_MEDIUM, "External buffer available!\n");\r
+ DEBUG( DEBUG_MEDIUM, "External buffer available!\n");\r
// ### EXTERNAL BUFFER IS AVAILABLE; GRAB IT AND REMEBER THAT WE OWN IT! ###\r
externalRxBuffer->externalBufferRuntimeData->status\r
= BUFFER_BUSY;\r
runtime->externalRxBufferStatus = PROVIDED_TO_PDUR;\r
ret = BUFREQ_OK;\r
} else {\r
- DEBUG( DEBUG_MEDIUM, "Local buffer available!\n");\r
+ DEBUG( DEBUG_MEDIUM, "Local buffer available!\n");\r
if (runtime->externalRxBufferStatus == PROVIDED_TO_DSD) {\r
// ### EXTERNAL BUFFER IS IN USE BY THE DSD, TRY TO USE LOCAL BUFFER! ###\r
if (runtime->localRxBuffer.status == NOT_IN_USE) {\r
McuE_ExitCriticalSection(state);\r
runtime->diagnosticResponseFromDsd.SduDataPtr = protocolRow->DslProtocolTxBufferID->pduInfo.SduDataPtr;\r
runtime->diagnosticResponseFromDsd.SduLength = protocolRow->DslProtocolTxBufferID->pduInfo.SduLength;\r
- _DsdDslDataIndication(\r
- //&protocolRow->DslProtocolRxBufferID->pduInfo,\r
+ DsdDslDataIndication(\r
&(runtime->diagnosticRequestFromTester),\r
protocolRow->DslProtocolSIDTable,\r
protocolRx->DslProtocolAddrType,\r
mainConnection->DslProtocolTx->PduR_DcmDslTxPduId,\r
- //&protocolRow->DslProtocolTxBufferID->pduInfo);\r
&(runtime->diagnosticResponseFromDsd));\r
\r
}\r