Main Content

Use C/C++ S-Functions as Sim Viewing Devices in External Mode

A sim viewing device encapsulates processing and viewing of signals received from the target system in external mode. During simulation in external mode, the target system uploads the appropriate input values to the sim viewing device in the Simulink® model. The sim viewing device then conditions the input signals as needed and renders the signals on the screen. A sim viewing device runs only on the host, generating no code in the target system and, therefore, allowing extra processing of displayed signals without burdening the generated code. You can use your S-function as a sim viewing device in external mode if it satisfies the following conditions.

  • The S-function has no output ports.

  • The S-function contains no states.

  • The generated code does not require the conditioned signals produced by the S-function.

To specify a C MEX S-function as a sim viewing device, set the SS_OPTION_SIM_VIEWING_DEVICE option in the mdlInitializeSizes function. For example

 ssSetOptions(S, SS_OPTION_SIM_VIEWING_DEVICE);

When simulating a model in Rapid Accelerator mode with signal logging enabled, no data is logged for antenna elements or To Workspace blocks that are inside of a sim viewing device.

External mode compatible S-functions are selected, and the trigger is armed, by using the External Signal & Triggering dialog box. For more information see External Mode Simulation with TCP/IP or Serial Communication (Simulink Coder).

See Also

Related Topics