]> rtime.felk.cvut.cz Git - arc.git/blobdiff - communication/PduR/PduR.c
Starting 'pdur2' branch with copied content from remote repository.
[arc.git] / communication / PduR / PduR.c
index 9a5ed58c59e5f98ba6869f9c2d4c786e4a79025f..c4fd6091bf6cb11d061de969757905df70082c9b 100644 (file)
 #include "McuExtensions.h"\r
 #include "debug.h"\r
 \r
-\r
 /*\r
  * The state of the PDU router.\r
  */\r
 PduR_StateType PduRState = PDUR_UNINIT; // 960, 31 PC-Lint: Borde åtgärdas\r
 \r
-const PduR_PBConfigType * PduRConfig;\r
-\r
 \r
-/* ############### Zero Cost Operation Mode ############# */\r
-/* Only define the following functions if zero cost operation\r
- * mode is not used! They are defined as macros in PduR.h otherwise. */\r
 #if PDUR_ZERO_COST_OPERATION == STD_OFF\r
 \r
+\r
+\r
+const PduR_PBConfigType * PduRConfig;\r
+\r
+\r
 /*\r
  * Initializes the PDU Router.\r
  */\r
@@ -75,50 +74,40 @@ void PduR_Init (const PduR_PBConfigType* ConfigPtr) {
        uint8 failed = 0;\r
 \r
        // Initialize buffers.\r
+       /*\r
        uint16 bufferNr = 0;\r
-       PduRRoutingPath_type *path;\r
-       PduRConfig->PduRRoutingTable->NRoutingPaths = 0;\r
-       for (uint16 i = 0; (!PduRConfig->PduRRoutingTable->PduRRoutingPath[i].PduR_Arc_EOL) && (!failed); i++) {\r
-               PduRConfig->PduRRoutingTable->NRoutingPaths++;\r
-               path = &PduRConfig->PduRRoutingTable->PduRRoutingPath[i];\r
-\r
-               if (path->PduRDestPdu.DataProvision != PDUR_NO_PROVISION) {\r
-                       // Allocate memory for new buffer.\r
-                       PduRTxBuffer_type *buffer = path->PduRDestPdu.TxBufferRef;\r
-\r
-                       if (bufferNr >= PDUR_MAX_TX_BUFFER_NUMBER) {\r
-                               DEBUG(DEBUG_LOW,"PduR_Init: Initialization of buffer failed due to erroneous configuration.\nThe number of buffer exceeded the maximum number of allowed buffers.\n");\r
-                               failed = 1;\r
-                               break;\r
-                       }\r
-                       // 586 PC-Lint (malloc) ticket #135\r
-                       if      ((buffer->Buffer = (uint8 *)malloc(buffer->Depth * sizeof(uint8) * path->SduLength)) == 0) {\r
-                               DEBUG(DEBUG_LOW,"PduR_Init: Initialization of buffer failed. Buffer space could not be allocated for buffer number %d\n", bufferNr);\r
-                               failed = 1;\r
-                               break;\r
-                       }\r
+       for (uint16 i = 0; PduRConfig->RoutingPaths[i] != NULL && (!failed); i++) {\r
+               const PduRRoutingPath_type *path = PduRConfig->RoutingPaths[i];\r
 \r
-                       buffer->First = buffer->Buffer;\r
-                       buffer->Last = buffer->Buffer;\r
+               for (uint8 j = 0; path->PduRDestPdus[j] != NULL; j++) {\r
+                       const PduRDestPdu_type *destination = path->PduRDestPdus[j];\r
 \r
 \r
-                       // Initialize the new buffer.\r
-                       buffer->BufferId = i; // Set buffer id.\r
-                       buffer->BufferType = path->PduRDestPdu.DataProvision; // Set buffer data provision mode.\r
-                       buffer->Length = path->SduLength; // Set buffer sdu length.\r
+                       if (destination->DataProvision == PDUR_TRIGGER_TRANSMIT) {\r
+                               // Allocate memory for new buffer.\r
 \r
-                       if (path->PduRDestPdu.DataProvision == PDUR_TRIGGER_TRANSMIT) {\r
-                               //memcpy(buffer->First, path->PduRDefaultValue.PduRDefaultValueElement->DefaultValueElement,path->SduLength);\r
-                               PduR_BufferQueue(buffer, path->PduRDefaultValue.PduRDefaultValueElement->DefaultValueElement);\r
-                       }\r
 \r
-                       // Save pointer to the new buffer.\r
-                       //PduR_RTable_LoIf.RoutingTable[i].TxBufferRef = &PduRBuffers[bufferNr];\r
+                               // Initialize the new buffer.\r
+                               buffer->BufferId = i; // Set buffer id.\r
+                               buffer->BufferType = destination->DataProvision; // Set buffer data provision mode.\r
+                               buffer->Length = path->SduLength; // Set buffer sdu length.\r
+\r
+                               if (destination->DataProvision == PDUR_TRIGGER_TRANSMIT) {\r
+                                       //memcpy(buffer->First, path->PduRDefaultValue.PduRDefaultValueElement->DefaultValueElement,path->SduLength);\r
+                                       PduR_BufferQueue(buffer, path->PduRDefaultValue.PduRDefaultValueElement->DefaultValueElement);\r
+                               }\r
+\r
+                               // Save pointer to the new buffer.\r
+                               //PduR_RTable_LoIf.RoutingTable[i].TxBufferRef = &PduRBuffers[bufferNr];\r
+\r
+                               DEBUG(DEBUG_LOW,"Initialized buffer %d. Id: %d, Type: %d, Depth: %d\n", bufferNr, buffer->BufferId, buffer->BufferType, buffer->Depth);\r
+                               bufferNr++;\r
+\r
+                       }\r
 \r
-                       DEBUG(DEBUG_LOW,"Initialized buffer %d. Id: %d, Type: %d, Depth: %d\n", bufferNr, buffer->BufferId, buffer->BufferType, buffer->Depth);\r
-                       bufferNr++;\r
                }\r
        }\r
+       */\r
 \r
        if (failed) {\r
                // TODO Report PDUR_E_INIT_FAILED to Dem.\r
@@ -134,6 +123,7 @@ void PduR_Init (const PduR_PBConfigType* ConfigPtr) {
        }\r
 }\r
 \r
+/*\r
 void PduR_BufferInc(PduRTxBuffer_type *Buffer, uint8 **ptr) {\r
        (*ptr) = (*ptr) + Buffer->Length;\r
 \r
@@ -142,7 +132,7 @@ void PduR_BufferInc(PduRTxBuffer_type *Buffer, uint8 **ptr) {
        if ( *ptr >= ( Buffer->Buffer + (Buffer->Depth * Buffer->Length) ) ) {\r
                *ptr = Buffer->Buffer;\r
        }\r
-       //*val = (*val + 1) % Buffer->Depth;\r
+       //  *val = (*val + 1) % Buffer->Depth;\r
 }\r
 \r
 void PduR_BufferQueue(PduRTxBuffer_type *Buffer, const uint8 * SduPtr) {\r
@@ -201,6 +191,8 @@ uint8 PduR_BufferIsFull(PduRTxBuffer_type *Buffer) {
        McuE_ExitCriticalSection(state);\r
        return rv;\r
 }\r
+*/\r
+\r
 \r
 \r
 #if PDUR_VERSION_INFO_API == STD_ON\r
@@ -216,17 +208,15 @@ uint32 PduR_GetConfigurationId (void) {
        //PduR_DevCheck(0,1,0x18,E_NOT_OK);\r
        return PduRConfig->PduRConfigurationId;\r
 }\r
-#endif // End of not Zero Cost Operation Mode\r
 \r
 Std_ReturnType PduR_CancelTransmitRequest(PduR_CancelReasonType PduCancelReason, PduIdType PduId) {\r
        // TODO Implement!\r
-       (void)PduCancelReason;\r
-       (void)PduId;\r
        return E_NOT_OK;\r
 }\r
 \r
 void PduR_ChangeParameterRequest(PduR_ParameterValueType PduParameterValue, PduIdType PduId) {\r
        // TODO Implement!\r
-       (void)PduParameterValue;\r
-       (void)PduId;\r
+\r
 }\r
+\r
+#endif\r