Tutorial This tutorial runs through a simplified scenario, for both Ada and C++ development. It is a quick introduction to the toolset. In addition, the narrative in this chapter can be useful as a reference, especially for users relatively new to Apex Embedded development.
- Invoke Apex
- Embedded Development Using Ada
- Set up the Target to Run/Debug Your Application
- Run and Debug
Invoke Apex
% rational_dir/apex/bin/apexinit
Rational_dir is the installation directory for Apex. Once Apex is started, you do not have to enter the full pathname again.
Embedded Development Using AdaCreate a Working View For Your Ada Application
For this tutorial, create the working view, hello.ss/practice.wrk, in your home directory.
- 1 . Move to your home directory by typing ~ (tilde) in the Rational Apex startup box and clicking the Visit button. Apex opens a new directory viewer for the subsystem.
- 2 . Select File > New > New Subsystem. Enter the full pathname of the subsystem you wish to create in the Subsystem Full Name field. The dialog may already have the desired directory name in the field. If this is the case, you need only add the subsystem name (hello). The .ss extension is added for you automatically.
With the Visit the new subsystem check box selected (its default setting), create the subsystem and close the dialog box by clicking the OK button. Apex opens a new directory viewer for the subsystem.
- 3 . Select File > New > New View. Enter practice in the Name field of the New View dialog.
Leave the View Type button set to Working because you are creating a working view. In the Model Selection section, select the Cross checkbox.
Now, click on the Navigation icon next to the Model field. Set the Language button to Ada95. Set the Target button to Tornado and your target. You see one or more available model views. Select a view with Imports in its name. Click the OK button.
Leave all other controls in the New View dialog box set to their default settings, and click on OK or APPLY. When the view has been created, Apex opens a new directory viewer for that view.
Two separate windows, the Jobs window and the Output window, are updated for most Apex operations. These are useful to track command progress. You can move these windows away from the windows you are working in to avoid obscuring them.
Compile and Link
- 1 . Create and Compile Your Application
Use a simple program that prints "Hello, world" as your test program.
- a .
Select File > New > New Ada. The New Ada dialog box is displayed.i Change the settings of the buttons labelled Package and Spec to Procedure and Body.
ii Enter the name hello in the Name field. hello is the name of the Ada file you are creating. It is not necessary to add any filename extensions. As you develop the hello application, Apex creates and uses filenames based on the simple name hello as appropriate.
iii Select the Visit checkbox, then create the file by clicking the OK button. Apex creates an Ada procedure body named hello.2.ada and displays it in an Ada editor window.
- b .
Edit the file to contain the following:
with text_io procedure hello is begin text_io.put_line("Hello, world!"); end hello;
- c .
Compile and Link Your Ada ApplicationSelect Compile > Link to create an executable.
Note: It is not necessary to compile first. Apex compiles any units necessary before linking. You can link the executable in the file editor or from the directory viewer.
- d .
Click the Close button to close the editor.
Set up the Target to Run/Debug Your ApplicationBefore running your program you must select one of the available Tornado targets. The following are the steps to do this.
- a .
Start the Tornado Launcher or Tornado executable if using Tornado 3.0 AESelect Tools > Tornado_Launch and bring up the Tornado Launch dialog. Click on OK to launch. The Apex Tornado Launch dialog disappears and the Wind River Launch or Tornado dialog is displayed.
- b .
Start a Target ServerThis is done from the Wind River dialog.
- c .
Query the Target Server from ApexFrom within your Tornado view, select Tools > Target_Control... and bring up the Target Control dialog. Click Get Tornado Target List. This adds all registered Tornado targets to the Target Control dialog list of targets. You should see entries similar to the following:
TORNADO target_1_174@power TORNADO target_1_175@solarisc
Note: This step can be repeated at any time to update the list of Tornado targets.
- d .
Select a Tornado TargetIn the Target Control dialog, select your chosen Tornado Target. Click Select. Note that if there is only one target this step is not necessary as that target was automatically selected during the Get Tornado Target List action.
Run and DebugThere are two ways to run your application, with and without the debugger.
To run the application without the debugger, highlight either hello.2.ada or the linked executable in your directory viewer. Select File > Run. The Run dialog comes up. This dialog offers a multitude of options to control execution. The default options are adequate for this tutorial. Click OK.
An xterm appears, running NIST's expect. All I/O goes through this new xterm. When your program completes, exit from the xterm. One way to exit is to press Control-c in the window.
To run your application under the debugger, select File > Debug. By default, the Auto Load Program toggle is on. Your application is downloaded automatically by the debugger. Select OK. This brings up the Apex Debugger GUI allowing you to debug your code.
When you are done with the debugging session, pull down File > Exit Debugger from within the debugger GUI.
Rational Software Corporation http://www.rational.com support@rational.com techpubs@rational.com Copyright © 1993-2002, Rational Software Corporation. All rights reserved. |