/* Function: rppValidParamRange ================================================
* Abstract:
- * Validate that given numeric parameters is between given range.
+ * Validate that given parameter is scalar, numeric and between given range.
*/
static bool rppValidParamRange(SimStruct* S, int_T parIdx, int_T mn, int_T mx)
{
}
+/* Function: rppValidParamBoolean ==============================================
+ * Abstract:
+ * Validate that given parameter is boolean (logical).
+ */
+static bool rppValidParamBoolean(SimStruct* S, int_T parIdx)
+{
+ const mxArray* raw = ssGetSFcnParam(S, parIdx);
+ if(!mxIsLogicalScalar(raw)) {
+ ssSetErrorStatus(S, "Parameter to S-function must be a scalar.");
+ return false;
+ }
+
+ return true;
+}
+
+
/*
*==============================================================================
*= BEGIN EXAMPLE CODE AND FUNCTIONS DOCUMENTATION =
--- /dev/null
+/* Copyright (C) 2013 Czech Technical University in Prague
+ *
+ * Authors:
+ * - Carlos Jenkins <carlos@jenkins.co.cr>
+ *
+ * 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/>.
+ *
+ * File : sfunction_scis.c
+ * Abstract:
+ * C-MEX S-function block for RPP Serial Communication send.
+ *
+ * References:
+ * header.c
+ * trailer.c
+ *
+ * Compile with:
+ * <matlabroot>/bin/mex sfunction_scis.c
+ */
+
+
+#define S_FUNCTION_NAME sfunction_scis
+#include "header.c"
+
+
+static void mdlInitializeSizes(SimStruct *S)
+{
+ /*
+ * Configure parameters: 1
+ * - Use printf.
+ */
+ if(!rppSetNumParams(S, 1)) {
+ return;
+ }
+
+ /*
+ * Configure input ports: 1
+ * - Data.
+ */
+ if(!ssSetNumInputPorts(S, 1)) {
+ return;
+ }
+ rppAddInputPort(S, 0, SS_UINT8);
+
+ /*
+ * Configure output ports: 1
+ * - Error flag.
+ */
+ if(!ssSetNumOutputPorts(S, 1)) {
+ return;
+ }
+ rppAddOutputPort(S, 0, SS_BOOLEAN);
+
+ /* Set standard options for this block */
+ rppSetStandardOptions(S);
+}
+
+
+#ifdef MATLAB_MEX_FILE
+#define MDL_CHECK_PARAMETERS
+static void mdlCheckParameters(SimStruct *S)
+{
+ /* Check the parameter 1 */
+ if(!rppValidParamBoolean(S, 0)) {
+ return;
+ }
+}
+#endif
+
+
+#ifdef MATLAB_MEX_FILE
+#define MDL_SET_WORK_WIDTHS
+static void mdlSetWorkWidths(SimStruct *S)
+{
+ /* Set number of run-time parameters */
+ if(!ssSetNumRunTimeParams(S, 1)) {
+ return;
+ }
+
+ /* Register the run-time parameter 1 */
+ ssRegDlgParamAsRunTimeParam(S, 0, 0, "p1", SS_UINT8);
+
+ /* Note that parameter 2 is for TLC, not runtime, so not declared */
+}
+#endif
+
+
+#define COMMON_MDLINITIALIZESAMPLETIMES_INHERIT
+#define UNUSED_MDLOUTPUTS
+#define UNUSED_MDLTERMINATE
+#include "trailer.c"