Products & Services Solutions Academia Support User Community Company

Learn more about Real-Time Workshop   

Manual Download and Execution

Introduction

If you did not specify automatic downloading, you must use Wind River Systems Tornado tools to download and start the program.

Resetting Wind River Systems VxWorks System

Reset the VxWorks system by pressing control-x on the host console or power-cycling the VxWorks chassis. This ensures that no dangling processes or stale data exist in the system.

Downloading Files

To download the real-time program, use the VxWorks ld routine from within the Wind River Systems WindSh™ (wind shell). The WindSh shell can also be run from the command line or from within the Tornado development environment.

For example, if you want to download the file vx_equal.lo, which is in the /home/my_working_dir directory, use the following commands at the WindSh prompt.

cd "/home/my_working_dir"
ld <vx_equal.lo

You will also need to load the StethoScope libraries if the StethoScope option was selected during the build. The Tornado User's Guide describes the ld library routine.

Starting the Program

The real-time program defines a function, rt_main(), which spawns the tasks to execute the model code, and communicate with the Simulink engine if you selected external mode during the build procedure. It also initializes StethoScope if you selected this option during the build procedure.

The rt_main function is defined in the rt_main.c application module. This module is located in the matlabroot/rtw/c/tornado directory.

The rt_main function takes six arguments, and is defined by the following ANSI[1] C function prototype:

    RT_MODEL * (*model_name)(void),
    char_T      *optStr,
    char_T      *scopeInstallString,
    int_T        scopeFullNames,
    int_T        priority,
    int_T        port

The following table lists the arguments to this function.

Arguments to the rt_main RT_MODEL

Argument

Description

model_name

Pointer to the entry point function in the generated code. This function has the same name as the Simulink model. It registers the local functions that implement the model code by adding function pointers to the model's rtM.

optStr

Options string used to specify a stop time (-tf) and whether to wait (-w) in external mode for a message from the Simulink engine before starting the simulation. An example options string is

"-tf 20 -w"

The -tf option overrides the stop time that was set during code generation. If the value of the -tf option is inf, the program runs indefinitely.

scopeInstallString

Character string that determines which signals are installed to StethoScope. Possible values are

  • NULL — Install no signals. This is the default value.

  • "*" — Install all signals.

  • "[A-Z]*" — Install signals from blocks whose names start with an uppercase letter.

Specifying any other string installs signals from blocks whose names start with that string.

scopeFullNames

Determines whether StethoScope uses full hierarchical block names for the signals it accesses or just the individual block name. Possible values are

  • 1 Use full block names.

  • 0 Use individual block names. This is the default value.

It is important to use full block names if your program has multiple instances of a model or S-function.

priority

Priority of the program's highest priority task (tBaseRate). Not specifying any value (or specifying a value of 0) assigns tBaseRate to the default priority, 30.

port

Port number that the external mode sockets connection should use. The valid range is 256 to 65535. The port number defaults to 17725.

Passing optStr by Using the Template Makefile

You can also pass the -w and -tf options (see optStr in the preceding table) to rt_main by using the PROGRAM_OPTS macro in tornado.tmf. PROGRAM_OPTS passes a string of the form

-opt1 val1 -opt2 val2

In the following examples, the PROGRAM_OPTS directive sets an infinite stop time and instructs the program to wait for a message from the Simulink engine before starting the simulation. The argument string must be delimited by single quotes nested within double quotes:

PROGRAM_OPTS = "'-tf inf -w'"

Including the single quotes ensures that the argument string is passed to the target program correctly under both Microsoft Windows and The Open Group UNIX platforms.

Calling rt_main

To begin program execution, call rt_main from the WindSh prompt. For example,

sp(rt_main, vx_equal, "-tf 20 -w", "*", 0, 30, 17725)


[1] ANSI is a registered trademark of the American National Standards Institute, Inc.

  


Related Products & Applications

Learn more about Simulink through this collection of videos, articles, technical literature and the Getting Started with Simulink Guide.

 © 1984-2010- The MathWorks, Inc.    -   Site Help   -   Patents   -   Trademarks   -   Privacy Policy   -   Preventing Piracy   -   RSS