![]() |
![]() |
![]() |
![]() |
![]() |
Targeting
Preparations - File Structure
- Create a new empty directory <cmicrotutorial> in your home directory or on your local hard disk. This directory will be denoted by <MyTutorial> in the following.
- Copy the directory
<installation>/sdt/examples/cmicrotutorial/<platform>/pager
(including all files and subdirectories) to your new <MyTutorial> directory and remove all write protections.- In the Organizer, open the Pager system (Pager.sdt) found in <MyTutorial>/pager/system.
Using the Targeting Expert
- Select the system symbol in the Organizer view.
- Start the Targeting Expert from the Generate menu. The Targeting Expert will generate a default partitioning diagram model (see Partitioning Diagram Model File) and will check the directory structure.
- As the target directory specified in the Organizer does not exist yet, you will be prompted if it should be created. Press the Yes button.
A sub-directory structure is added in the target directory afterwards by the Targeting Expert. For further information see Target Sub-Directory Structure.
The work flow of the Targeting Expert is divided into four steps.
- Step 1: Select the Desired Component
- Step 2: Select the Type of Integration
- Step 3: Configure the Build Process
- Step 4: Make the Component
The very first time you are using the Targeting Expert, an assistant is automatically started showing you how to proceed. When you have closed the assistant, you can always re-start it by choosing the menu option Help > Assistant.
The Help Viewer will be displayed and show the appropriate manual page if you click on one of the numbered boxes.
Step 1: Select the Desired Component
- Click on the component in the partition diagram model.
The complete SDL system is (per default) generated into the component "component".
The component can be given any name you like if the system is deployed using the Deployment Editor. For more detailed information on how to deploy a system, see The Deployment Editor.
Background Information
- More details about partitioning diagram models can be found in Partitioning Diagram Model File.
- For further information concerning the selectable entries in the partitioning diagram model, please see Targeting Work Flow.
Step 2: Select the Type of Integration
- Press the left most combo box in the integration tool bar of the main window (or click the component entry in the partitioning diagram model using the right mouse button). This is shown in Figure 181.
- A tree structure containing all the pre-defined integrations is shown in the popup menu displayed. Select Light Integrations > Application TEST.
The SDL system is now checked for correctness and the automatic configuration is done.
Although only the automatic configuration files sdl_cfg.h and ml_mcf.h are needed the SDL to C compiler also generates the files: component.c, component.ifc, and component.sym.
After the SDL to C compiler has finished, the Targeting Expert:
- generates the file env.c and lists all the SDL signals from and to the environment (see event log). A manual adaptation is needed for each signal before the generated files and the library files can be compiled. This is necessary as the Targeting Expert only generates a skeleton with the used signals.
- How to edit the env.c, is described in Edit the Environment File.
- generates default Target Tester options (file sdtmt.opt)
- generates a default manual configuration (file ml_mcf.h)
Background Information
If you want to do an integration not given in the SDL Suite distribution, please select the entry <user defined> in the integration popup menu. Then you are able to do all settings needed for the used hardware. You are also able to set up your own integration accessible in the integration popup menu.
- component.c
Describes the SDL system's behavior in C functions.- component.ifc
The header file for the environment functions. E.g. it provides PIDs and type definitions for signals.- component.sym
Provides information on SDL symbols. Necessary for tracing the SDL system with the SDL Target Tester.- sdl_cfg.h
The automatic configuration file for the Cmicro Kernel. For instance, if you use a timer, the file contains a define, which turns the timer implementation on.Edit the Environment File
In this section you will learn how to fill in the environment functions in the file env.c.
In the following section the Targeting Expert starts a text editor. Per default the built-in editor is used. This can be changed in the Tools > Customize menu.
- Find the lines from the global section:
/* BEGIN User Code (global section)*//* It is possible to define some global variables here *//* or to include other header files. */
- This tutorial describes a console application. It will use the screen and the keyboard to communicate with the user. It is necessary to include the used header file(s).
- For a better style some defines are used. Further some global variables and functions have to be implemented. The functions are called, if there should be something simulated in the environment, like a display. After the line
/* or to include other header files. */
the following code needs to be inserted:#if defined(MICROSOFT_C)#include <conio.h>#else#include <stdio.h>#endif#define key_was_pressed 1#define key_not_pressed 0int KeySignalPresent = 0;char LastKeyPressed;xInitEnv()
- We like to have a welcome message displayed when the system is started. This can be done like this in the function xInitEnv()
printf("-------- Welcome to Pager system--------\n\n");printf("get message : 0 to 4\n");printf("scroll right: r\n");printf("scroll left : l\n");printf("delete : d\n\n");The code must be inserted between
/* BEGIN User Code (init section) *//* END User Code (init section) */xInEnv()
- Now you have to handle the data from the environment. In this tutorial it means you have to handle the input from the keyboard!
- The possible handling of the data:
- If a key has been pressed the digits 0-4 are recognized as a message and the letters 'r', 'l' and 'd' are the commands for scrolling and deleting.
- Please go to the code position of the function xInEnv() with the following lines:
/* BEGIN User Code (variable section)*//* It is possible to define some variables here *//* or to insert a functionality which must be polled */- Below these lines insert the following code:
char my_inkey;KeySignalPresent = key_not_pressed;#if defined(XMK_UNIX)my_inkey = 0;if((my_inkey = getchar_unlocked()) != 0){KeySignalPresent=key_was_pressed;}#elif defined(MICROSOFT_C)if (kbhit()){my_inkey=_getch();KeySignalPresent=key_was_pressed;}#endifif (KeySignalPresent==key_was_pressed){if ((my_inkey == 'r') ||(my_inkey == 'l') ||(my_inkey == 'd') ||((my_inkey>='0')&&(my_inkey<='4')))LastKeyPressed = my_inkey;elseLastKeyPressed=0;}elseLastKeyPressed = 0;
- Find the following lines of code in the function xInEnv()
/* BEGIN User Code <ScrollRight>_1 */if (i_have_to_send_signal_ScrollRight)/* END User Code <ScrollRight>_1 */
- In step 2 we implemented the variable LastKeyPressed. In step 4 we assigned it the value of my_inkey which has the value of the last key pressed. Modify the if() statement into:
if (LastKeyPressed == 'r')- Find the following line of code in the function xInEnv()
GLOBALPID(Who_should_receive_signal_ScrollRight,0));
- Select the XPTID_Keypad entry in this dialog to copy it into the clipboard. Then paste it into the env.c as shown below.
GLOBALPID(XPTID_Keypad,0));- The function returns, and the signal is treated.
- Find the following lines in the function xInEnv()
/* BEGIN User Code <ScrollLeft>_1 */if (i_have_to_send_signal_ScrollLeft)/* END User Code <ScrollLeft>_1 */if (LastKeyPressed == 'l')- Find the following line of code in the function xInEnv()
GLOBALPID(Who_should_receive_signal_ScrollLeft,0));GLOBALPID(XPTID_Keypad,0));- Find the following lines of code in the function xInEnv()
/* BEGIN User Code <Delete>_1 */if (i_have_to_send_signal_Delete)/* END User Code <Delete>_1 */if (LastKeyPressed == 'd')- Find the following line of code in the function xInEnv()
GLOBALPID(Who_should_receive_signal_Delete,0));GLOBALPID(XPTID_Keypad,0));- Because we do not use a real target hardware, but simulate the Pager system, we have to predefine some messages.
Find the following lines of code in the function xInEnv()/* BEGIN User Code <ReceivedMsg>_1 */if (i_have_to_send_signal_ReceivedMsg)/* END User Code <ReceivedMsg>_1 */if ((LastKeyPressed>='0')&&(LastKeyPressed<='4'))- Go to the next empty "User Code" section and insert following lines:
char *p;xmk_var.Param1.MyText = (SDL_Charstring)NULL;switch(LastKeyPressed){case '0':p = " Hello user";xmk_var.Param1.TelNumber = 12345;break;case '1':p = " How do you feel doing targeting?";xmk_var.Param1.TelNumber = 555555;break;case '2':p = " Targeting is all so easy!";xmk_var.Param1.TelNumber = 987654;break;case '3':p = " I only wanted to check if it works.";xmk_var.Param1.TelNumber = 45454;break;case '4':p = " ... and it works very fine!";xmk_var.Param1.TelNumber = 911911;break;default :break;}xAss_SDL_Charstring(&(xmk_var.Param1.MyText), p, XASS_AC_ASS_FR);
This way of "receiving" messages is of course just a helper function because we do not use a real interface here!
- The line xmk_var.Param1.MyText = (SDL_Charstring)NULL;
- means that the element MyText of the parameter message which is a parameter of the signal ReceivedMsg is set to null.
- The Signal ReceivedMsg and the parameter message are declared in the SDL system.
- The line xAss_SDL_Charstring(&(xmk_var.Param1.MyText), p, XASS_AC_ASS_FR); allocates memory for the pointer p.
- Find the following line of code in the function xInEnv()
GLOBALPID(Who_should_receive_signal_ReceivedMsg,0));GLOBALPID(XPTID_PagerCtrl,0));xOutEnv()
- Find the following code section:
case CurrentMsg :{/* BEGIN User Code <CurrentMsg>_1 *//* Use (yPDP_CurrentMsg)xmk_TmpDataPtr to access the signal's parameters *//* ATTENTION: the data needs to be copied. Otherwise it *//* will be lost when leaving xOutEnv *//* END User Code <CurrentMsg>_1 *//* BEGIN User Code <CurrentMsg>_2 *//* Do your environment actions here. */xmk_result = XMK_TRUE; /* to tell the caller that *//* signal is consumed *//* END User Code <CurrentMsg>_2 */}
- This code fragment handles the signal CurrentMsg. The chosen message is displayed on the screen (telnumber, message, current message position and the total number of messages). Insert the following code after: /* Do your environment actions here. */
printf("\r ");printf( "\rCurrentMessage: %6d %s (%d/%d)",((yPDP_CurrentMsg)xmk_TmpDataPtr)->Param3.TelNumber,((yPDP_CurrentMsg)xmk_TmpDataPtr)->Param3.MyText+1,((yPDP_CurrentMsg)xmk_TmpDataPtr)->Param1,((yPDP_CurrentMsg)xmk_TmpDataPtr)->Param2);xFree(&(((yPDP_CurrentMsg)xmk_TmpDataPtr)->Param3.MyText));- Find the following code in the function xOutEnv():
case ServiceMsg :{/* BEGIN User Code <ServiceMsg>_1 *//* Use (yPDef_Close*)xmk_TmpDataPtr to accessthe signal's parameters *//* ATTENTION: the data needs to be copied.Otherwise it *//* will be lost when leaving xOutEnv *//* END User Code <ServiceMsg>_1 *//* BEGIN User Code <ServiceMsg>_2 *//* Do your environment actions here. */xmk_result = TRUE; /* to tell the caller that *//* signal is consumed *//* END User Code <ServiceMsg>_2 */}
- The code fragment handles the signal ServiceMsg. The handling of the data is same as in the step before. So insert the following code after: /* Do your environment actions here. */
printf("\r ");printf( "\rServiveMessage: %s",((yPDP_ServiceMsg)xmk_TmpDataPtr)->Param1+1);xFree(&(((yPDP_ServiceMsg)xmk_TmpDataPtr)->Param1));- Find the following code section in the function xOutEnv():
case ShortBeep :{/* BEGIN User Code <ShortBeep>_1 *//* END User Code <ShortBeep>_1 *//* BEGIN User Code <ShortBeep>_2 *//* Do your environment actions here. */xmk_result = XMK_TRUE; /* to tell the caller that *//* signal is consumed *//* END User Code <ShortBeep>_2 */}break ;
- The code fragment handles the signal ShortBeep. A beep sounds when the pager receives a message or you do something which is not allowed. After the code /* BEGIN User Code <ShortBeep>_1 */ insert
putchar(07);- Find the following code section in the function xOutEnv():
case LongBeep :{/* BEGIN User Code <LongBeep>_1 *//* END User Code <LongBeep>_1 *//* BEGIN User Code <LongBeep>_2*//* Do your environment actions here. */xmk_result = XMK_TRUE; /* to tell the caller that *//* signal is consumed *//* END User Code <LongBeep>_2*/}break ;putchar(07);putchar(07);Closing the Environment
In this tutorial there is no need to close the environment. In other cases, e.g. microprocessor hardware, it is probably necessary to do so.
Have a look in the file env.c, find code like this in the function xCloseEnv():
/* BEGIN User Code (close section) *//* Do the actions here to close your environment *//* END User Code (close section) */Insert any code you need to have here.
Step 3: Configure the Build Process
- Press the items below the Application TEST in the partitioning diagram. If it is necessary to add or remove settings for your job, you can edit the settings.
- Click Save to close the dialog.
For this section of the tutorial there it is not necessary to modify anything, though we will do some modifications later in section Run Target EXE without Tester.
Background Information
Short description of the different areas:
- Compiler / Linker / Make
- In this area it is possible to configure all the settings used for the Compiler, Linker and Make tools.
- Something special regarding Additional Compiler. For example, you have to use an ANSI C- compiler to compile the generated files, and it is necessary to link the objects with the object from one file, which needs to be compiled with a C++ compiler. In this instance you could enter the regarding file and the used compiler in the section Additional Compiler.
- For more information see: Configure Compiler, Linker and Make.
- Target Library
- In this area it is possible to set defines and values to scale the target library. For more information see Configure and Scale the Target Library.
- All settings will be stored in the file ml_mcf.h.
- Target Tester
- In this area it is possible to set defines and values to scale the functionality of the tester. For more information see Configure the SDL Target Tester (Cmicro only).
- All settings will be stored in the file ml_mcf.h.
- Host Connection
- In this area it is possible to set the parameter of the connection to the host. For example, it contains the description of the message coding and the name of the executable, etc. The configuration of the Host Connection is always stored in the file sdtmt.opt. This file is mandatory for the SDL Target Tester. For more information see: Configure the Host (Cmicro only).
Step 4: Make the Component
- In the dialog which is displayed by default (when the Application TEST is selected) you have to select two check boxes. Analyze / Generate Code and Environment functions.
- Click on the button Full Make to start the code generation and make.
After the SDL to C compiler has finished the code generation, the Targeting Expert will re-generate the env.c (and keep your modifications). Afterwards it generates a makefile with the given settings and the code will be compiled and linked.
http://www.ibm.com/rational |
![]() |
![]() |
![]() |
![]() |