Main Content

extmodeEvent

External mode event trigger

Description

example

errorCode = extmodeEvent(eventId, simulationTime) informs the external mode abstraction layer of the occurrence of an event.

eventId is the sample time ID of the model, for example, 0 for base rate, 1 for first subrate, and so on.

The function:

  • Samples all signals associated with a given sample time.

  • Stores signal values in a new packet buffer.

  • Passes the packet buffer to the underlying transport layer for subsequent transmission to the development computer.

Use this function with other external mode functions to enable communication between Simulink® and the target application during an external mode simulation.

For correct sampling of signal values, run the function immediately after model_step() for the corresponding sample time ID. You can invoke the function with different sample time IDs in separate threads because the function is thread-safe.

The extmodeBackgroundRun function performs the transmission of signal values to the development computer.

Examples

Set Up External Mode Communication

For a pseudo-code example that shows how you can provide external mode communication by using the function with related functions, see External Mode Abstraction Layer.

Input Arguments

collapse all

Sample time ID of the model, which is 0 for base rate, 1 for first subrate, 2 for second subrate, and so on.

Time when event occurs.

Output Arguments

collapse all

Error code, returned as an extmodeErrorCode_T enumeration with one of these values:

  • EXTMODE_SUCCESS (0) –– No error detected.

  • EXTMODE_INV_ARG (-1) –– Arguments invalid.

  • EXTMODE_NOT_INITIALIZED (-9) –– External mode not initialized yet.

  • EXTMODE_NO_MEMORY (-10) –– No memory available on the target hardware.

Version History

Introduced in R2018a