]> rtime.felk.cvut.cz Git - pes-rpp/rpp-simulink.git/blobdiff - rpp/blocks/tlc_c/sfunction_fraytransmit.tlc
Change license to MIT
[pes-rpp/rpp-simulink.git] / rpp / blocks / tlc_c / sfunction_fraytransmit.tlc
index 3ce05084e46cd9e5d20e468c3fb5cbd5e069b063..11b5d1e9f81c3593f9a8e83207fd54cbdc13c3f7 100644 (file)
@@ -3,10 +3,26 @@
 %% Authors:
 %%     - Michal Horn <hornmich@fel.cvut.cz>
 %%
-%% This document contains proprietary information belonging to Czech
-%% Technical University in Prague. Passing on and copying of this
-%% document, and communication of its contents is not permitted
-%% without prior written authorization.
+%% Permission is hereby granted, free of charge, to any person
+%% obtaining a copy of this software and associated documentation
+%% files (the "Software"), to deal in the Software without
+%% restriction, including without limitation the rights to use,
+%% copy, modify, merge, publish, distribute, sublicense, and/or sell
+%% copies of the Software, and to permit persons to whom the
+%% Software is furnished to do so, subject to the following
+%% conditions:
+
+%% The above copyright notice and this permission notice shall be
+%% included in all copies or substantial portions of the Software.
+
+%% THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+%% EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
+%% OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+%% NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
+%% HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+%% WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
+%% FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
+%% OTHER DEALINGS IN THE SOFTWARE.
 %%
 %% File : sfunction_fraytransmit.tlc
 %% Abstract:
@@ -26,6 +42,7 @@
 
     %% Ensure required header files are included
     %<RppCommonBlockTypeSetup(block, system)>
+    %<LibAddToCommonIncludes("rpp/rpp.h")>
 
 %endfunction
 
   %assign payloadPreambleIndicatorTr_val = LibBlockParameterValue(payloadPreambleIndicatorTr, 0)
   %assign singleTransmit_val                    = LibBlockParameterValue(singleTransmit, 0)
   %assign slotId_val                                    = LibBlockParameterValue(slotId, 0)
+  %assign bufferId_val                                          = LibBlockParameterValue(bufferId, 0)
+
+  %if EXISTS(::rpp_fr_bufferId_%<bufferId_val>_flg) == 1
+    %<LibBlockReportError(block, "Buffer ID is already used by another FlexRay block.")>
+  %endif
+  %assign ::rpp_fr_bufferId_%<bufferId_val>_flg = 1
 
   %openfile buffer
   {
+    // Buffer %<bufferId_val>
        %if channel_val == 1U
          .channel = FR_CHANNEL_A,
        %elseif channel_val == 2U
                %% Get parameters
         %assign slotId_val = LibBlockParameterValue(slotId, 0)
         %assign maxPayload_val = LibBlockParameterValue(maxPayload, 0)
+        %assign bufferId_val = LibBlockParameterValue(bufferId, 0)
 
         %% Get IO signals
         %assign message = LibBlockInputSignal(0, "", "", 0)
         %assign err_flag = LibBlockOutputSignal(0, "", "", 0)
 
-               rpp_sci_printf("sending message %#x on slot %d.\n", %<message>, %<slotId_val>);
+               rpp_sci_printf("sending message %#x on slot %d from buffer %d.\n", %<message>, %<slotId_val>, %<bufferId_val>);
 
-               retVal = rpp_fr_transmit_lpdu(0, %<slotId_val>, &%<message>, %<maxPayload_val>*2);
+               retVal = rpp_fr_transmit_lpdu(0, %<bufferId_val>, &%<message>, %<maxPayload_val>*2);
                if (retVal == FAILURE) {
-                       rpp_sci_printf("Sending a message to slot %#x failed.\n", %<slotId_val>);
+                       rpp_sci_printf("Sending a message from buffer %#x failed.\n", %<bufferId_val>);
                        %<err_flag> = TRUE;
                }
     %endif