S A N K H Y A Copyright (c) 2002 Sankhya Technologies Private Limited. All rights reserved. SANKHYA Varadhi: Building and Running Varadhi OSE Demo Applications =================================================================== This directory contains demo programs that use SANKHYA Varadhi on OSE 4.4.1. In order to test the demo program, you should copy this directory to your own work area, change directory to one of the demo directories and follow the steps mentioned below to build and execute it. Varadhi OSE applications are OSE Autostarted Monolith applications. Prerequisite: OSE 4.4.1 environment should be setup before using Varadhi. The following assumes that the compiler and make tool is available in the path. a. OSE SoftKernel (sfk-win32) Host : x86 PC Host OS : Windows NT 4.0 / Windows 2000 Tools : VC++ 6.0. b. OSE PPC (Windows Host) Host : x86 PC Host OS : Windows NT 4.0 / Windows 2000 Tools : g++ 2.95.2 adapted for OSE, Cygwin 1.1.2, Binutils 2.9.1, Newlib 1.8.2 adapted for OSE and VC++ 6.0. c. OSE PPC (Unix Host) Host OS : Solaris 2.6 and above on Sun Sparc Workstation, Linux 2.0.x and above on x86 Linux PC Tools : g++ 2.95.2 adapted for OSE and Newlib adapted for OSE The following OSE 4.4.1 environment should be setup. OSE_ROOT - Points to the install location of OSE 4.4.1 LM_LICENSE_FILE - Points to the OSE 4.4.1 License File The development tools location should be added to the PATH variable as mentioned below. a. OSE SoftKernel (sfk-win32) i) Update the PATH variable In Windows Command Prompt C:\> set PATH=%OSE_ROOT%win32\bin;%OSE_ROOT%sfk-win32\lib; %OSE_ROOT%sfk-win32\bsp-win32\lib;%PATH% ii) If VC++ environment is not set, use vcvars32.bat file provided by VC++ to set VC++ environment. b. OSE PPC (Windows Host) i) Set the GCC_EXEC_PREFIX variable to pick GNU g++ tools. GCC_EXEC_PREFIX should point to the location where gcc-lib is installed. In Windows Command Prompt C:\> set GCC_EXEC_PREFIX=%OSE_ROOT%win32\lib\gcc-lib\ ii) Update the PATH variable In Windows Command Prompt C:\> set PATH=%OSE_ROOT%win32\powerpc-eabi\bin; %OSE_ROOT%win32\bin;%PATH% Note: Cygwin path should also be set. iii) Update the OSE_ROOT variable to Unix Path instead of DOS format. For example, if OSE_ROOT variable is set to C:\Programs Files\OSE\OSE4.4.1\, then change it as below. In Windows Command Prompt C:\> set OSE_ROOT=C:/Programs Files/OSE/OSE4.4.1/ iv) If VC++ environment is not set, use vcvars32.bat file provided by VC++ to set VC++ environment. c. OSE PPC (Unix Host) i) Set the GCC_EXEC_PREFIX variable to pick GNU g++ tools. GCC_EXEC_PREFIX should point to the location where gcc-lib is installed. For example, on Solaris, use the following to set the variable In csh % setenv GCC_EXEC_PREFIX $OSE_ROOT/solaris2/lib/gcc-lib/ ii) Update the PATH variable In csh % setenv PATH "$OSE_ROOT/solaris2/powerpc-eabi/bin: $OSE_ROOT/solaris2/bin:"$PATH 1. Set up the Varadhi Host environment Varadhi tools require the following environment variables to be set. * VARADHI - Directory path pointing to the root of installation. * VARADHI_HOST - Host platform name like sol2, linux and win32. In order to set these variables and PATH variable, source varadhi.csh in the SANKHYA Varadhi installation root directory. On Windows host, run varadhi.cmd instead. In csh % source /varadhi.csh In Windows Command Prompt C:\> \varadhi.cmd where is the directory where Varadhi is installed. By default Varadhi is installed under /opt/sankhya/varadhi in Unix and C:\sankhya\varadhi in Windows NT/2000. 2. Copy the demo program(s) to your work area. To build and run the demo, it is better to copy the demo to a work directory and build/run from there. This will make sure that the original installation directory doesn't get modified accidentally. Determine a work directory (for e.g. my_varadhi) where you will run the demos and change directory to it. In csh % cd % set WORK_DIR=`pwd` % cp -r $VARADHI/samples/ose . In Windows Command Prompt C:\> cd \> set WORK_DIR= %WORK_DIR%\> xcopy /s %VARADHI%\samples\ose . 3. Create and Setup a Varadhi Target Platform Varadhi can be customized for a particular target configuration using vconf. On Unix, Varadhi configuration files are provided under $VARADHI/etc/config directory to create various Varadhi Target Platforms. On Windows NT/2000 host, the location is %VARADHI%\etc\config directory. For example, to create a Varadhi platform for OSE SoftKernel on Windows, that supports C++ Exception and with no support for static allocation of Heap memory, use the following. 3.a Change directory to your workspace. In Windows Command Prompt C:\> cd %WORK_DIR% 3.b Invoke vconf with two config files, one providing configuration options for the ORB and another one that specifies the target platform (OSE SoftKernel). In Windows Command Prompt %WORK_DIR%\> vconf defaults sfkw32-ose This will create a Varadhi Platform under 'varadhi' sub-directory. 3.c Setup the Varadhi Target Platform Environment The above configuration places a Windows batch file in the 'varadhi' sub-directory. Run the batch file to setup the Varadhi Target Environment. In Windows Command Prompt %WORK_DIR%\> cd varadhi %WORK_DIR%\varadhi\> platform.bat This will set the following variable. * VARADHI_PLATFORM - Directory path pointing to the root of the created Target platform. 3.d Build the platform using "nmake" in the 'src' directory of the newly created Varadhi Platform. In Windows Command Prompt %WORK_DIR%\varadhi> cd src %WORK_DIR%\varadhi\src> nmake The configuration that is built with 'sfkw32-ose' configuration file enables stdout/stderr output via OSE dbgprintf() calls. To create a Varadhi platform for OSE PPC on Windows, that has no C++ Exception support and with support for static allocation of Heap memory, use the following. 3.e Change directory to your workspace. In Windows Command Prompt C:\> cd %WORK_DIR% 3.f Invoke vconf with three config files, one providing configuration options for the ORB, another one specifing the target platform (OSE PPC on Cygwin) and another one for licensing. In Windows Command Prompt %WORK_DIR%\> vconf static ppc-gcc-cygwin-ose license This will create a Varadhi Platform under 'varadhi' sub-directory. 3.g Setup the Varadhi Target Platform Environment The above configuration places a Windows batch file in the 'varadhi' sub-directory. Run the batch file to setup the Varadhi Target Environment. In Windows Command Prompt %WORK_DIR%\> cd varadhi %WORK_DIR%\varadhi\> platform.bat This will set the following variable. * VARADHI_PLATFORM - Directory path pointing to the root of the created Target platform. 3.h Build the platform using "make" in the 'src' diectory of the newly created Varadhi Platform. In Windows Command Prompt %WORK_DIR%\varadhi\> cd src %WORK_DIR%\varadhi\src> make The configuration that is built with 'ppc-gcc-cygwin-ose' configuration file selects 'krn-8xx' as the OSE PPC Kernel, "ppc860" as the target CPU, "eth0" as the Ethernet Interface, Serial Port 1 as the dbgprintf() output port and "SMCUART" as the Serial Device Name. Change these configuration if you are using different Kernel/CPU, Ethernet Interface or Serial Device/Port. This configuration also disables C++ Exception support. 4. Build the demo program 4.a Edit the Configuration in the OSE configuration dmake makefile. OSE "dmake" makefiles are provided for building the demo application. The userconf.mk file provided with the demo needs to be modified for your system. makefile_sr.mk - dmake makefile for building the Server Program. makefile_cl.mk - dmake makefile for building the Client Program. userconf.mk - Configuration file for OSE Environment varadhi_ose.mk - Configuration file for SANKHYA Varadhi Environment Typically, the following parameters need to be changed. Refer to "OSE Examples and Makefiles User's Guide" for more information. COMPILER - Select the target compiler. For SoftKernel on Windows, use "MSVC". For OSE PPC, use "GCC". BOARD - Select the OSE Kernel for which the demo is built. For SoftKernel on Windows, use "WIN32". For OSE PPC, select the board entry avilable for your target. For example, select "MOTOROLA_MBX860" for Motorola MBX860 target. OSEROOT - OSEROOT specifies the install location of OSE 4.4.1 This needs to be changed to the install location. INET - Selects the OSE Internet Protocol stack connection. For SoftKernel on Windows, select "api" to use the Host Stack. For OSE PPC, select "OSE" to use the OSE Stack. USE_ETH - Specifies whether Ethernet Interface should be used or not. If INET is selected as "api", then set this to "no". Otherwise, select "yes". DBGPRINTF_PORT - Specifies the media that dbgprintf() call should use. For SoftKernel on Windows, select "native". For OSE PPC, select the access port according to your system. ETH_IP_ADDR - Sets Ethernet IP Address ETH_ADDR - Sets Ethernet MAC Address DEFAULT_GATEWAY - Sets the Default Gateway address DNS_IP_ADDR - Sets the Address of the DNS server DNS_DOMAIN - Sets the default Domain Name. 4.b Specify the Location of Varadhi Naming Server 'ns'. The demo applications use Varadhi Naming Server to bind and resolve Object Reference. Typically, the Naming Server ('ns') runs on the host system. The initial reference for the Naming Server is registered via the config files using vconf while building the Platform. This is done as below. (See defaults.cfg) declare NameService -type service -id "IDL:omg.org/CosNaming/NamingContext:1.0" -default "127.0.0.1:2069" -action register The Varadhi applications will contact the NameServer in this address. To override, "-ORBInitRef" ORB option can be used. In Varadhi OSE applications, the commandline arguments are specified via an 'Environment' variable (VARADHI_OSE_ARGV) in the makefiles. $(ECHO)PROC_VARIABLE(varadhi_ose_main, VARADHI_OSE_ARGV, $(QUOTE)client -ORBInitRef NameService=127.0.0.1:2069$(QUOTE)) $(ECHOEND) >> $@ Modify the value in the address part to the IP address and Port number where 'ns' is run. 4.c Build the client and server. To build the demo program on Unix, change directory to the "make" sub-directory of a particular demo directory and use dmake to build both the Server and Client. For example, In csh % cd $WORK_DIR/names/make % dmake -f makefile_sr.mk all % dmake -f makefile_cl.mk all To build the demo program on Windows NT/2000, change directory to the "make" sub-directory of a particular demo directory and use dmake to build both the Server and Client. For example, In Windows Command Prompt %WORK_DIR%\> cd names\make %WORK_DIR%\names\make> dmake -f makefile_sr.mk all %WORK_DIR%\names\make> dmake -f makefile_cl.mk all Note: This assumes that VC++ paths are properly set before. This will build server.ext and client.exe for OSE SoftKernel on Windows, and server.elf and client.elf for OSE PPC. 5. Running the demo program on OSE SoftKernel on Windows To run the demo program, first Varadhi NamingServer 'ns' should be started on the host in the port number mentioned in the -ORBInitRef ORB option explained in 4.b. After starting the Varadhi Nameserver, start the 'server' application and then run the 'client' application. For example, to run the "names" demo program, follow the steps below. a. Start the NamingServer In Windows Command Prompt > start ns This will start the Nameserver that listens on port 2069. To use other port numbers instead of 2069, use VaradhiPORT option as below. In Windows Command Prompt > start ns --VaradhiPORT 2809 & b. Start the Server Application In Windows Command Prompt %WORK_DIR%\names\make> cd ..\obj\WIN32\SERVER %WORK_DIR%\names\obj\WIN32\SERVER\> start server c. Run the Client Application In Windows Command Prompt %WORK_DIR%\names\obj\WIN32\SERVER\> cd ..\CLIENT %WORK_DIR%\names\obj\WIN32\CLIENT\> client 6. Running the demo program on OSE PPC To run the demo program, first Varadhi NamingServer 'ns' should be started on the host in the port number mentioned in the -ORBInitRef ORB option explained in 4.b. After starting the Varadhi Nameserver, download either the OSE PPC 'server' application or the 'client' application into the target. Run the other application (client or server) in another PPC target board, or on the host machine after building it for that host. For example, to run the "names" demo program with the 'server' running in the target board (Motorola MBX860) and client running on the host system, follow the steps below. a. Start the NamingServer In csh % ns & In Windows Command Prompt > start ns This will start the Nameserver that listens on port 2069. To use other port numbers instead of 2069, use VaradhiPORT option as below. In csh % ns --VaradhiPORT 2809 & In Windows Command Prompt > start ns --VaradhiPORT 2809 b. Download and Execute the Server Application in the target Download the server.elf file under names/obj/MOTOROLA_MBX860/SERVER directory (names\obj\MOTOROLA_MBX860\SERVER on Windows) into the target using OCD debugger or other methods mentioned for MOTOROLA_MBX860 board. Since Varadhi OSE applications are Autostarted Monoliths, the system entry point is OSE provided 'main'. The Varadhi OSE application should be started at CRT entry point (_start). c. Run the Client Application in the host In csh % client In Windows Command Prompt > client If the NameServer is listening on different port, other than the default port number 2069, or if it is running in a different host other than the host where 'client' is to be started, then the address of the NameServer should be specified using the -ORBInitRef option as below. In csh % client -ORBInitRef NameService=:2809 In Windows Command Prompt > client -ORBInitRef NameService=:2809 where - IP address of the host where NameServer is running. Short description of the demo programs ====================================== names: Names is a demo program that uses Varadhi NameServer, 'ns', to locate and invoke operation on a server object. The server binds an Object to the Varadhi NameServer and the client resolves it to get the Object Reference of the server (Adder) object. The server adds two numbers and returns the result. stringseq: A simple client/server demo that illustrates the use of String Sequence. The server stores a string sequence and client sets and gets values from it.