Tornado Reference : Tornado Tools

wtxtcl

NAME

wtxtcl - the Tornado TCL shell

SYNOPSIS

wtxtcl [file]

DESCRIPTION

wtxtcl is the Tornado TCL shell. This shell provides all the TCL facilities plus the WTX TCL APIs.

INTRODUCTION

The WTX Tcl API provides a binding of the WTX protocol to the Tcl language. This allows Tcl scripts to be written that interact with the WTX environment. Every WTX protocol request is available to the Tcl interface. The names of all WTX Tcl API commands are derived from the protocol request names according to the conventions discussed in the Tornado API Programmer's Guide: Coding Conventions . In other words, underscores are removed and all words but the first are capitalized. For example, WTX_MEM_READ becomes wtxMemRead.

The Tcl API is accessible directly by means of the wtxtcl tool, from WindSh by typing ?, in CrossWind by using tcl, and in launch and the browser when these tools are started with the -T option.

ERROR MESSAGES

A wtxtcl command can return one of several types of errors:

A WTX error
See the reference for WTX in the online Tornado API Reference for a list of WTX errors.

A Tcl command parameter parsing error
See host/src/libwpwr/wtxtcl/wtparse.c, which is the file where these errors are generated.

A wtxtcl error
See the listings in the ERRORS section of the function documentation for examples.

MEMORY BLOCKS

The memBlockXxx routines implement a memory block data type. The goal is to allow efficient management of blocks of target memory provided by WTX from Tcl programs. In particular, the memory blocks are not converted to string form except when a Tcl program requests it.

WTX routines that return (or accept) blocks of target memory must supply block handles provided by this library.

Blocks have both a "logical" size, specified by their creator, and an allocation size. The allocation size is the amount of heap memory allotted for the block data. The routines obtain memory to enlarge blocks in chunks.

Blocks are coded for the endianness of the target that supplied them, and the memBlockSet and memBlockGet routines automatically swap 16- and 32-bit quantities when they are stored to or retrieved from a block.

USING A SCRIPT FILE

Specifying a file in the wtxtcl command line makes wtxtcl use this file as script file.

wtxtcl then executes all specified procedures from the script file. This does not act like a sourced file in that wtxtcl exits after having executed the script file.

Example

First write the myWtxTcl.tcl script

    # myWtxTcl.tcl - user defined WTX / TCL script file
    #
    # modification history
    # --------------------
    # 01a,02jun98,fle written
    #*/
    
    #
    # DESCRIPTION
    # This tcl script file contains user-defined WTX-TCL procedures
    #

    ##########################################################################
    #
    # cpuNumGet - gets the CPU number of the specified <tgtSvr>
    #
    # SYNOPSIS
    #   cpuNumGet tgtSvr
    #
    # PARAMETERS
    #   tgtSvr : the target server to get CPU number from
    #
    # RETURNS: The CPU number or -1 on error
    #
    # ERRORS: N/A
    #

    proc cpuNumGet { tgtSvr } {
        set cpuNum -1

        if { [catch "wtxToolAttach $tgtSvr" tgtSvrName] } {
            return $cpuNum
        }

        if { [catch "wtxTsInfoGet" tsInfo] } {
            return $cpuNum
        }

        wtxToolDetach
        set cpuNum [lindex [lindex $tsInfo 2] 0]

        return $cpuNum
    }

    ##########################################################################
    #
    # main - command to execute at wtxtcl startup
    #

    puts stdout [cpuNumGet $argv]
Then launch wtxtcl with the file name as argument and the target server name as the argument to myWtxTcl.tcl

    wtxtcl myWtxTcl.tcl
    -1

    wtxtcl myWtxTcl.tcl vxsim0
    61

SEE ALSO

wtxtcl, WTX entry in the online Tornado API Reference , Tornado API Programmer's Guide: The WTX Protocol , Tornado User's Guide