SPI Programming Manual (G06.24+, H06.03+, J06.03+)

SPI Programming in TACL
SPI Programming Manual427506-006
8-30
Interprocess Communication
Interprocess Communication
An application requester written in TACL should open the management process for
each subsystem using the READ option of #REQUESTER, and should use
#APPENDV and #EXTRACTV to send commands and decode responses.
If you are writing a subsystem, it is recommended that you run TACL specifying its IN
and OUT files as $RECEIVE, and then use an #INPUTV/#REPLYV loop protected by a
suitable exception handler.
For more information about these features, see the
TACL Programmers Guide
.
Example: Printing or Displaying the Status
Structure of the Subsystem Control Point
(SCP)
Example 8-1 is a TACL program that prints or displays the status structure of the
Subsystem Control Point (SCP). The SCP process was chosen because it is
commonly found running on most nodes under the name $ZNET. Because SCP
adheres to the extended SPI protocol, it uses ZCOM data definitions. These definitions
are described in the
SPI Common Extensions Manual
.
The first step is to load the appropriate definition files. This task takes the greatest
amount of execution time. If you frequently use TACL for SPI, you should preload the
ZSPIDEF.
subsysTACL definitions so that your TACL functions do not need to do so.
The second step is to create an SPI buffer and initialize the SSID STRUCT with the
correct value. Then the macro constructs the request, using #SSINIT and #SSPUT.
Note that OBJNAME is a variable-length character string, so that a length preceding
the value is required.
The third step opens the SPI server, sends the request, gets the reply, and then closes
the server. (If you are going to do many requests, you should keep the server open
rather than continually opening and closing it for each request.)
The fourth step prepares the buffer for use again by using
ZSPI^TKN^RESET^BUFFER. Then the macro checks the return token,
ZSPI^TKN^RETCODE, for successful completion of the command. The #SETMANY
call that separates the results returned from #SSGET, and the INDEX 1 option is
specified so that it does not matter where in the buffer the return token has been
placed. The COUNT parameter is skipped (_), because this value is always 1.
Finally the desired data is extracted from the reply and, in this case, displayed. Here
#SSGETV is used because a STRUCT is retrieved.
The error handling in this example is rudimentary. The error text causes TACL to stop
executing the macro and point to the error text.