TSM scripts send and receive messages to and from DIPs through TSM. TSM packages and unpackages the message for TSM scripts. That is, TSM scripts only work with the data part of the message while TSM takes care of either adding or removing the header part, depending on whether the message is sent or received by the script. When sending a message, TSM sends the data from the specified script memory area, and when receiving message, TSM places the data received from a DIP into the specified script memory area.
A TSM script is responsible for:
The four functions, dbase, dipterm, dipname, and dipnum, are involved with interaction with DIPs. For additional information on these instructions, see TAS script instructions.
dbase (type.dip,mcont_field,ctype.dst,mbyte,type.src,nbyte)
Both the sending and receiving of data is done through the dbase instruction. The dbase instruction first sends the data, then waits for a response from the specified DIP. Responses or messages from DIPs other than the specified DIP are thrown away by TSM. Note that the data received from the DIP, ctype.dst, is specified before the data sent to the DIP, type.src.
The dbase instruction, when used in the case of DynaDIPs, allows the DIP argument to be the DIP name as well as the DIP number (see dipnum). The DIP name is specified using the TSM script language syntax for character strings.
dipterm (type.dip[,flag])
dipterm instructs TSM to send a message to the specified DIP when the TSM script terminates. As with the dbase instruction, dipterm allows the DIP argument to be the DIP name as well as the DIP number. The dipterm instruction is normally used to perform necessary cleanup after a script terminates.
The dipterm message is defined as the C-structure struct ms_univ (see mesg.h ). The following example show the message structure.
/* message structure for dipterm message */
struct ms_univ {
struct mbhdr hd;
long arg[4];
};
The arg[0], as shown in dipterm Message Structure, displays why the script terminated. As defined in tsm_dip.h, there are several causes for a script to terminate.
arg[1] is set to the value specified in the quit or exec instructions.
dipname (ctype.dst,type.src)
The dipname function takes a DIP number and converts it to the corresponding DIP name.
The returned DIP name character string is stored in the specified destination address. The destination area should be 16 bytes: 15 characters for the DIP name plus 1 character for the null termination symbol.
dipname is primarily for converting the DIP number returned when a DIP interrupt occurs. This allows scripts working at the DIP-name level to continue by converting the DIP number of the DIP that interrupted them. dipname returns a negative value if an error occurs during translation.
dipnum (type.dst,ctype.src)
dipnum converts a DIP name to its corresponding DIP number. dipnum returns a negative value if an error occurs during translation.
At this point, you have completed the necessary steps to send and receive messages to the DIP from a TSM script.