1 /* Copyright (C) 2013, 2014 Czech Technical University in Prague
4 * - Carlos Jenkins <carlos@jenkins.co.cr>
6 * Permission is hereby granted, free of charge, to any person
7 * obtaining a copy of this software and associated documentation
8 * files (the "Software"), to deal in the Software without
9 * restriction, including without limitation the rights to use,
10 * copy, modify, merge, publish, distribute, sublicense, and/or sell
11 * copies of the Software, and to permit persons to whom the
12 * Software is furnished to do so, subject to the following
15 * The above copyright notice and this permission notice shall be
16 * included in all copies or substantial portions of the Software.
18 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
19 * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
20 * OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
21 * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
22 * HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
23 * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
24 * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
25 * OTHER DEALINGS IN THE SOFTWARE.
27 * File : sfunction_scip.c
29 * C-MEX S-function block for RPP Serial Communication Printf.
36 * <matlabroot>/bin/mex sfunction_scip.c
43 Category: Communication
48 - { name: "Send", type: "dynamically" }
51 - { name: "ErrFlag", type: "bool" }
54 - { name: "Print format", type: "string", range: "(must include specifier for arguments)" }
56 # Description and Help is in Markdown mark-up
59 This block prints a formatted string to the SCI. The *Print format*
60 parameter is used as the format specifier for C `printf()` function.
61 Note that this value is inserted raw between the quotes during code
62 generation and thus there is no validation on it. User should always
63 put a valid specifier for the input type of the block.
65 Due to Simulink limitations, it is not posible join diferent types
66 into one vector. So one block can be used only for one type of
73 RPP API functions used:
81 #define S_FUNCTION_NAME sfunction_scip
85 static void mdlInitializeSizes(SimStruct *S)
88 * Configure parameters: 2
89 * - Printf format [setting].
91 if (!rppSetNumParams(S, 1)) {
96 * Configure input ports: 1
99 if (!ssSetNumInputPorts(S, 1)) {
102 rppAddInputVectorPort(S, 0, DYNAMICALLY_TYPED, DYNAMICALLY_SIZED);
105 * Configure output ports: 1
108 if (!ssSetNumOutputPorts(S, 1)) {
111 rppAddOutputPort(S, 0, SS_BOOLEAN);
113 /* Set standard options for this block */
114 rppSetStandardOptions(S);
118 #ifdef MATLAB_MEX_FILE
119 #define MDL_CHECK_PARAMETERS
120 static void mdlCheckParameters(SimStruct *S)
122 /* Check the parameter 1 */
123 /*if (!rppValidParamBoolean(S, 0)) {
127 /* Note that parameter 2 is not checked */
132 #ifdef MATLAB_MEX_FILE
133 #define MDL_SET_WORK_WIDTHS
134 static void mdlSetWorkWidths(SimStruct *S)
136 /* Set number of run-time parameters */
137 /*if (!ssSetNumRunTimeParams(S, 1)) {
141 /* Register the run-time parameter 1 */
142 /*ssRegDlgParamAsRunTimeParam(S, 0, 0, "p1", SS_BOOLEAN);*/
147 #ifdef MATLAB_MEX_FILE
149 static void mdlRTW(SimStruct* S)
151 /* Register parameter as a parameter setting */
152 static char_T str[128];
153 mxGetString(ssGetSFcnParam(S, 0), (char*)&str, sizeof(str)); /* Get string */
154 if (!ssWriteRTWParamSettings(S, 1,
155 SSWRITE_VALUE_QSTR, "PrintfFormat", (const char_T*)&str)) {
156 /* An error ocurred */
164 #define COMMON_MDLINITIALIZESAMPLETIMES_INHERIT
165 #define UNUSED_MDLOUTPUTS
166 #define UNUSED_MDLTERMINATE