-%% Copyright (C) 2013 Czech Technical University in Prague
+%% Copyright (C) 2013, 2014 Czech Technical University in Prague
%%
%% Authors:
%% - Michal Horn <hornmich@fel.cvut.cz>
%%
-%% This program is free software; you can redistribute it and/or modify
-%% it under the terms of the GNU General Public License as published by
-%% the Free Software Foundation; either version 2 of the License, or
-%% (at your option) any later version.
-%%
-%% This program is distributed in the hope that it will be useful,
-%% but WITHOUT ANY WARRANTY; without even the implied warranty of
-%% MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-%% GNU General Public License for more details.
-%%
-%% You should have received a copy of the GNU General Public License
-%% along with this program. If not, see <http://www.gnu.org/licenses/>.
+%% 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:
%include "common.tlc"
-
%% Function: BlockTypeSetup ====================================================
%function BlockTypeSetup(block, system) void
%% 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
{
- %if %<channel_val>==1
+ // Buffer %<bufferId_val>
+ %if channel_val == 1U
.channel = FR_CHANNEL_A,
- %elseif %<channel_val>==2
+ %elseif channel_val == 2U
.channel = FR_CHANNEL_B,
%else
- .channel = FR_CHANNEL_AB,
+ .channel = FR_CHANNEL_AB,
%endif
.cycleCounterFiltering = %<cycleCounterFiltering_val>,
+ .fidMask = 0,
.isTx = TRUE,
.maxPayload = %<maxPayload_val>,
.msgBufferInterrupt = %<msgBufferInterrupt_val>,
.payloadPreambleIndicatorTr = %<payloadPreambleIndicatorTr_val>,
+ .rejectNullFrames = FALSE,
+ .rejectStaticSegment = FALSE,
.singleTransmit = %<singleTransmit_val>,
.slotId = %<slotId_val>
},
%closefile buffer
- %assign ::fray_buffer_config = "%<::fray_buffer_config> %<buffer>"
- %assign ::fray_buffer_count = %<::fray_buffer_count> + 1
+
+ %if ISEQUAL(::rpp_fray_buffer_key_slot, "")
+ %assign ::rpp_fray_buffer_key_slot = "%<buffer>"
+ %else
+ %assign ::rpp_fray_buffer_config = "%<::rpp_fray_buffer_config> %<buffer>"
+ %endif
+ %assign ::rpp_fray_buffer_count = %<::rpp_fray_buffer_count> + 1
+
%endfunction
%if !SLibCodeGenForSim()
%if EXISTS(::rpp_fray_config_present) == 0
- LibBlockReportError([],"FlexRay config block not present!")
+ %<LibBlockReportError(block, "FlexRay config block not present!")>
%endif
%endif
%endfunction
%if !SLibCodeGenForSim()
%% 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>, 1);
+ 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