1 /* Copyright (C) 2013 Czech Technical University in Prague
4 * - Carlos Jenkins <carlos@jenkins.co.cr>
6 * Redistribution and use in source and binary forms, with or without
7 * modification, are permitted provided that the following conditions are
10 * 1. Redistributions of source code must retain the above copyright
11 * notice, this list of conditions and the following disclaimer.
13 * 2. Redistributions in binary form must reproduce the above copyright
14 * notice, this list of conditions and the following disclaimer in the
15 * documentation and/or other materials provided with the
18 * 3. Neither the name of the copyright holder nor the names of its
19 * contributors may be used to endorse or promote products derived
20 * from this software without specific prior written permission.
22 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
23 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
24 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
25 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
26 * HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
27 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
28 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
29 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
30 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
31 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
32 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
34 * File : sfunction_printf.c
36 * C-MEX S-function block for RPP Serial Communication Printf.
43 * <matlabroot>/bin/mex sfunction_printf.c
47 #define S_FUNCTION_NAME sfunction_printf
51 static void mdlInitializeSizes(SimStruct *S)
54 * Configure parameters: 2
55 * - Printf format [setting].
57 if (!rppSetNumParams(S, 1)) {
62 * Configure input ports: 1
65 if (!ssSetNumInputPorts(S, 1)) {
68 rppAddInputVectorPort(S, 0, DYNAMICALLY_TYPED, DYNAMICALLY_SIZED);
71 * Configure output ports: 1
74 if (!ssSetNumOutputPorts(S, 1)) {
77 rppAddOutputPort(S, 0, SS_BOOLEAN);
79 /* Set standard options for this block */
80 rppSetStandardOptions(S);
84 #ifdef MATLAB_MEX_FILE
85 #define MDL_CHECK_PARAMETERS
86 static void mdlCheckParameters(SimStruct *S)
88 /* Check the parameter 1 */
89 /*if (!rppValidParamBoolean(S, 0)) {
93 /* Note that parameter 2 is not checked */
98 #ifdef MATLAB_MEX_FILE
99 #define MDL_SET_WORK_WIDTHS
100 static void mdlSetWorkWidths(SimStruct *S)
102 /* Set number of run-time parameters */
103 /*if (!ssSetNumRunTimeParams(S, 1)) {
107 /* Register the run-time parameter 1 */
108 /*ssRegDlgParamAsRunTimeParam(S, 0, 0, "p1", SS_BOOLEAN);*/
113 #ifdef MATLAB_MEX_FILE
115 static void mdlRTW(SimStruct* S)
117 /* Register parameter as a parameter setting */
118 static char_T str[128];
119 mxGetString(ssGetSFcnParam(S, 0), (char*)&str, sizeof(str)); /* Get string */
120 if (!ssWriteRTWParamSettings(S, 1,
121 SSWRITE_VALUE_QSTR, "PrintfFormat", (const char_T*)&str)) {
122 /* An error ocurred */
130 #define COMMON_MDLINITIALIZESAMPLETIMES_INHERIT
131 #define UNUSED_MDLOUTPUTS
132 #define UNUSED_MDLTERMINATE