[Previous] [Next] [Contents] [Index]


    Remote Target Simulation

This chapter describes how to run a simulator on a target and connect it to the SDT simulator interface (SimUI) on the host via TCP/IP communication.

Table of Contents 

Target Simulation

Overview

A simulator executable (called simulator) communicates with the SDT tools, e.g. the Simulator UI (SimUI), via the SDT communication mechanism (the PostMaster). By using some special features it is possible to run the simulator on a target system (called target), while the SDT tools and Postmaster run on a host system (called host) separate from the target. This set-up is known as target simulation. This gives the possibility to test a simulator in its correct environment and still get the trace and debug possibilities offered by SDT.

For instance, the target could be a VME147 bus system running VxWorks, and the host is a Sun workstation running SunOS 5. The simulator running on the target is built using a special library, instead of the ordinary simulator library containing the simulator kernel. The special library contains the kernel for a simulator on VxWorks, as well as a communication interface to the host. On the host, the simulator is replaced by a gateway executable (called gateway) that communicates with the simulator on the target over the TCP sockets connection. Figure 464 shows the set-up for target simulation.

Figure 464  : Target simulation set-up

Extracted pic [3]

Architecture

Simulators, as well as other executables communicating via the Postmaster, has a set of layers as shown in Figure 465, where the layers are represented by the files that implement them. All units (the Simulator, Postmaster and SimUI) are located on the same host machine.

Figure 465  : Architecture of an ordinary simulator

Extracted pic [1]

sctpost.c, post.o and a few other files are then linked into the simulator kernel used for making the simulator.

The basic principle of this target simulation is to direct the communication between the simulator and the Postmaster over a TCP sockets connection. This re-direction must be transparent to the simulator and to the Postmaster.

To direct the messages between the Simulator Monitor and the Postmaster through the TCP sockets, a new layer, implemented in the file tlayer.c, is introduced between sctpost.c and post.o according to Figure 466.

Figure 466  : tlayer.c is introduced

Extracted pic [2]

For the target, tlayer.c emulates post.o (the same interface), and for the host, tlayer.c emulates sctpost.c (the same interface). (In Windows NT there are other communication mechanisms on host than UNIX sockets.)

The Configuration File and Simulator UI Command Extension

All configuration is made on host side in a file called tarsim.cfg. This file is searched by host.sct in a directory specified by the environment variables (searched in this order): $TARSIMPATH, $PWD, $HOME, $sdtdir.

In Windows NT, the only searched variables are %TARSIMPATH% and %sdtdir%. You set the environment variable %TARSIMPATH% as described below. You can also use the environment variable %sdtdir%, if you prefer having one single tarsim.cfg and want to put it there.

  1. Open the System Control Panel and select the Environment tab.
  2. In the Variable field enter TARSIMPATH, and in the Value field enter the directory (including logical disk drive) where tarsim.cfg is located.
  3. Press Set and close down the System Control Panel.

The syntax of tarsim.cfg is described below. In the delivery, a sample tarsim.cfg is supplied.


Example 164 : A sample tarsim.cfg      

The last implemented command in tarsim.cfg is SDLPATH.

The reason for this is that when you generate C code from an SDL diagram with SDT, the absolute path to the various SDL source files is hardcoded into the C file. This path is passed to the MSC and SDL Editor if you have tracing to those. This can lead to difficulties if you have generated the code to the target system somewhere in the directory hierarchy where SDT editors cannot read. Provided you have a flat structure of your source code (i.e. all SDL files to one system in the same directory), you can instead in tarsim.cfg specify a new path where the editors should search for your source files. It is then up to you to make sure that both the original and the new path contains the same source code.

You must specify an absolute path. Example on UNIX:

The trailing path (the last slash) is optional; the parser will try to find it anyway and report problems upon invocation.

Tarsim Shell (UNIX only)

On UNIX, there is a very basic shell included in host.sct.

If you start host.sct without the target running, you will enter a shell where only the commands INIT (try contacting target again) and EXIT (quit session) are applicable. If you know your target is running and still do not get contact, please check that the specified IP address and PORT of the target in tarsim.cfg are correct. PORT is for the target hardcoded in tlayer.h, the header file for tlayer.c.

During simulation you can enter the tarsim shell by entering a ":" (colon). You can only leave the simulation if the simulator is not running with GO or FOREVER. If so, first stop the simulation with the Break button.

After entering the ":" you will see a welcome text to the shell. You can enter the command HELP to see the full command set, or STATUS to see the current simulation setup. You exit the shell by entering EXIT.

Note: 

Be sure you are still in the tarsim shell when entering EXIT, since it is the same command for exiting the simulation. You can see if you are in the shell by the fact that all text begin with a colon as the first character in the text window. There is a time-out in the shell, after one minute of inactivity you get back to the simulator again.

LOG and DEBUG has the same syntax and meaning as in
tarsim.cfg
.

Addresses like TARGET and HOST, as well as the COM and SDLPATH statements, cannot be changed from the shell.

An additional facility for the logging is GREP, which gives a possibility to filter out up to 5 strings that you want to log and skip the rest.

To clear all GREP's and log everything:

To add a string (this example looks for MSCE, i.e. signals to the MSC Editor):

Strings are not case sensitive by default. To search for the exact string MyPath/demo.sdt, prefix it with `=':

If you want to log everything except, for instance, signals to the SDL Editor you can use the prefix `!':

Note: 

If you have GREP MSC active and then enter GREP !MSC, status will be changed of the previously entered argument, so you cannot enter two contradictions and have both active.

You can also combine the inverse and exact functions:

Up to five GREP arguments can be active simultaneously and each can be up to 25 characters long.

If the GREP buffer is full, empty the old with GREP *.

You can empty the buffer and enter new argument in one statement:

Executing and Terminating the Tools

When the simulator and gateway have been started, the simulator can be controlled from the Simulator UI on the host in the same way as an ordinary simulator. Differences may be seen in execution performance and in the printing of log messages. Using Open in the File menu in the SimUI, you specify the simulator file host.sct. After you have chosen this file, host.sct will try to establish contact with the target, according to settings in tarsim.cfg. This file must be in the same directory as host.sct, and SDT should also be started from this directory. (Setting Source Directory in the Organizer does not help SimUI find the target simulation file dependencies.)

The simulator on the target can be stopped by typing <Ctrl+C> on the console. It is though recommended only to stop the target by pressing the Exit button in the SimUI. The host.sct will then, before it finishes, send a stop signal to the target, and give it a chance to close all open file descriptors for TCP sockets. If not, you can get a bind error if you try to restart the target simulator without rebooting the target system.

The gateway on the host is terminated by issuing the command Exit or Quit in the SimUI.

Known Problems

Source Code Files

Source code for the target contains of all the standard SDT Master Library, with the change that post.o does not contain any Postmaster, but a TCP socket communication program.

Both host and target use the same tlayer.c file, with the compile flags -DTARGET and -DHOST, respectively. Also the flag -DTCP need to be specified in both ends to get TCP functionality.

All other files in sctworld.o needs the flags -DTARGETSIM,
-D/compiler/, -D/rtos/, -DSCTDEBCLCOM and
-DXMAIN_NAME=sdlmain
.

See the specific integrations for the RTOS and compiler specific flags.

The source file structure in tlayer.c is also documented in the top of tlayer.c in a comment.

To make the target you will need tlayer.c and tcp.c, along with the .h files which are supplied. A makefile is also provided.

Special Information about Windows NT

Compiling

Both target and host has been tested on Windows NT 4.0 and compiled with Borland C++ v5.0.

In the directory sdt/sdtdir/remsim/wini386 is a file called remsim.ide which is a Borland project file for generating targets. (Normally you will probably not run the target under Windows NT anyway; this is just for demo purposes).

The host part is called host.exe and is loaded into the SimUI the same way as on UNIX.

Both parts must be compiled as 32 bit applications, the target as a console and the host as a window application.

Non-supported Features

Due to the fact that there are no stdout or stderr when you run a Windows GUI application, together with the difficulties to determine the right directory to write to a file in, all debugging and logging facilities has been excluded. That means that the entries DEBUG, GREP and LOG in tarsim.cfg will be ignored. There is no extra Target Simulation Shell as on UNIX (which is not needed when you cannot do any message logging). None of this affects the target simulation as such.

Other Known Limitations

It is considerably slower to do a remote simulation in Windows NT than on UNIX, even with the same system, same options, and running target and host on the same machine. There are ways to speed up the simulation. Recommended is to give set-tr 0 as the first command in SimUI. Then all textual tracing is stopped. Instead you can ask for the value of certain variables of interest. MSC trace and SDL trace works OK; MSC is the quicker of the two.

You can of course do a normal host simulation on the NT machine and then you have no limitations. Target simulation is not recommended to be used more than for the final fine tuning into the target environment.

It is especially important in Windows to use the option SDLPATH in tarsim.cfg if the target has been compiled on another system. The parser in host.exe can read NFS syntax "/path/" and will convert it to Windows/DOS syntax "\path\". The thing that cannot be fixed automatically is the correct logical drive letter. Hence you can specify where your SDL source files are with:

in tarsim.cfg. Of course the source files must be the same as the ones the target was compiled from.


[Previous] [Next] [Contents] [Index]