SMSG_WTEXT is a general-purpose procedure that makes requests of the Service Request Processor (SRP) by sending a message with text string to the SRP.
The format for using the SMSG_WTEXT procedure is:
xxx SMSG_WTEXT req_code, acc_code, offset, length, handle
Parameter Description
Request Code The request code for the particular PLC reference data type (see below).
Access Code The access code for this user reference type (see below).
Offset The zero-based offset from the beginning of the specified user reference data.
Length The number of data words to transfer.
Handle A user identification for this transfer. The procedure sends a message and a text string defined as SMSG_TXT$.
Note
The current size of the data in the text string SMSG_TXT$ must be in the range 0 through 256 bytes.
The SRP response message from a call to SMSG_WTEXT may be obtained by using the PROCESS_MESSAGE statement, which can be used periodically, or by an interrupt procedure invoked by the response.
Before using SMSG_WTEXT, the PLC program name, which is the same as the
Logicmaster 90 folder name used to create the program, and block name must first be put into the shared string variable SMSG_TXT$. If %L data is to be accessed, its sub-block name must be added to SMSG_TXT$ starting at character position 9.
The request and access codes for PLC memory types are:
Table 5-4. Request and Access Codes for PLC Memory Types
User Reference Request Code Access Code Use
%L R_PBMEM$ 2 ACC_CODE$(1:) Read %L
(Series 90-70) W_PBMEM$ 2 ACC_CODE$(1:) Write %L
%P R_TMEM$ 1 ACC_CODE$(2:) Read %P
(Series 90-70) W_TMEM$ 1 ACC_CODE$(2:) Write %P
%I R_SMEM$ 3 ACC_CODE$(3:) Read %I
W_SMEM$ 3 ACC_CODE$(3:) Write %I
%Q R_SMEM$ 3 ACC_CODE$(4:) Read %Q
W_SMEM$ 3 ACC_CODE$(4:) Write %Q
%R R_SMEM$ 3 ACC_CODE$(5:) Read %R
W_SMEM$ 3 ACC_CODE$(5:) Write %R
%T R_SMEM$ 3 ACC_CODE$(6:) Read %T
W_SMEM$ 3 ACC_CODE$(6:) Write %T
%M R_SMEM$ 3 ACC_CODE$(7:) Read %M
W_SMEM$ 3 ACC_CODE$(7:) Write %M
%AI R_SMEM$ 3 ACC_CODE$(8:) Read %AI
W_SMEM$ 3 ACC_CODE$(8:) Write %AI
%AQ R_SMEM$ 3 ACC_CODE$(9:) Read %AQ
W_SMEM$ 3 ACC_CODE$(9:) Write %AQ
%SA R_SMEM$ 3 ACC_CODE$(10:) Read %SA
%SB R_SMEM$ 3 ACC_CODE$(11:) Read %SB
%SC R_SMEM$ 3 ACC_CODE$(12:) Read %SC
%S R_SMEM$ 3 ACC_CODE$(13:) Read %S
1 R_TMEM = Read task memory;
W_TMEM = Write task memory.
2 R_PBMEM = Read program block memory;
W_PBMEM = Write program block memory.
3 R_SMEM = Read system memory;
W_SMEM = Write system memory.
In the following example, the SMSG_WTEXT procedure is used to read %L20. GEN_MSG is the PLC program name/folder name, and LMEM is the program subblock name associated with the particular %L memory that is to be read. R_PBMEM$ is the request code used to read %L memory. ACC_CODE$(1:) is used for %L memory, 19 is the offset from the beginning of %L memory to %L20, 1 is the number of %L registers to read, and 123 is a code that the MegaBasic program can use to recognize the PLC response message for this request if PROCESS_MESSAGE returns more than one message. Note that SMSG_TEXT$ is shared from the GENERIC.PGM package and is the actual text string sent by SMSG_WTEXT.
220 SMSG_TEXT$(1:8) = “GEN_MSG” + chr$(0) 230 SMSG_TEXT$(9:5) = “LMEM” + chr$(0)
330 SMSG_WTEXT R_PBMEM$, ACC_CODE$(1:), 19, 1, 123
In the next example, the SMSG_WTEXT procedure is used to write %P15-%P19.
GEN_MSG is the PLC program name/folder name. W_TMEM$ is the request code needed to write %P memory. ACC_CODE$(2:) is used for %P memory, 14 is the offset from the beginning of %P memory to %P15, 5 is the number of %P registers to write, and 26 is the handle. Note that a block name is not necessary for %P memory.
220 SMSG_TEXT$(1:8) = “GEN_MSG” + chr$(0) 225 SMSG_TEXT$(9:) = SEND_P$
330 SMSG_WTEXT W_TMEM$, ACC_CODE$(2:), 14, 5, 26
Section 4: Access to PLC Fault Tables and PLC Status
READ_FLT.PGM provides access to the PLC and I/O fault tables from a MegaBasic program. In addition, PRN_FLT.PGM and TEST_FLT.PGM explain how to use the fault information supplied by READ_FLT.PGM. PRN_FLT.PGM provides several routines that break down and print information contained in the fault records.
TEST_FLT.PGM explains how to use the functions and procedures from the other two files to read and display the fault table information.
To use the functions, procedures, and data structure definitions supplied in READ_FLT.PGM, add the line:
xxx Access “READ_FLT.pgm”
at the beginning of a MegaBasic program or in the PROLOGUE section of a user-written package. The READ_FLT.PGM file must be loaded to the PCM RAM Disk before running the MegaBasic program which accesses it. The file is located in the \PCOP or
\PCOP\EXAMPLES.PCM directory of your PC hard disk, depending on which release of PCOP or TERMF you use.
Note
In PCOP version 2.04 and earlier, READ_FLT.PGM, PRN_FLT.PGM, and TEST_FLT.PGM are called RD_FLT.PGM, PR_FLT.PGM, and
RP_TEST.PGM, respectively.
The functions and procedures found in READ_FLT.PGM are listed below:
Table 5-5. READ_FLT.PGM Functions and Procedures
Function/Procedure Description
READ_FAULT_TBL A procedure that reads the table header information and zero (0) or more fault records from the I/O or PLC fault table.
RDEL_FAULT_TBL A procedure that reads and deletes the first fault record in either fault table.
FLT_PRESENT%( ) A function that reads PLC short status information and returns the fault table present boolean from the PLC status word for either fault table.
FLT_CHANGED%( ) A function that reads PLC short status information and returns the fault table changed boolean from the PLC status word for either fault table.
WORD%( ) A function that converts the first two bytes of a string to an integer.
Although some Series 90 PLC services require the requester to be a programmer (i.e., a device authorized to change the PLC program), none of the procedures or functions in this section requires it. As a result, there is no interference between these functions or procedures and Logicmaster 90 software, except that the use of RDEL_FAULT_TBL will cause faults to disappear from the Logicmaster 90 fault table displays, and the
Logicmaster 90 clear fault table function may cause the MegaBasic program to miss faults.
Several shared structure definitions and constants are also defined in READ_FLT.PGM.
These include:
Table 5-6. READ_FLT.PGM Shared Definitions and Constants
Constant/Structure Description
IO_FLT_TBL A constant (1) used to indicate the selection of the I/O fault table in the above functions and procedures. These functions and procedures default to the I/O fault table when the table selection parameter is omitted.
PLC_FLT_TBL A constant (2) used to indicate the selection of the PLC fault table in the above functions and procedures.
PLC_FAULT_HDR$ A string variable of length 12 containing the header information from the PLC fault table. This string is filled in as a result of a call to the READ_FAULT_TBL procedure that explicitly selects the PLC_FLT_TBL.
IO_FAULT_HDR$ A string variable of length 12 containing the header information from the I/O fault table. This string is filled in as a result of a call to the READ_FAULT_TBL procedure that selects the default IO_FLT_TBL.
SHORT_STATUS$ A string variable of length 12 containing the data returned by a short status request to the PLC CPU. This variable is updated by every call to FLT_PRESENT% or
FLT_CHANGED% and may also be updated by a SYSREAD. CLEAR_TS$ A structure definition of the header records from either
fault table.
SS_NUM_CONTROL_PROGS$ A structure definition of the short status record.
TS_SEC$ A structure definition of time stamp fields.
IO_FT$ A structure definition of the I/O fault table records.
IORA_SEG$ A structure definition of the I/O reference address field of the I/O fault record.
IOFA_RACK$ A structure definition of the I/O fault address field of the I/O fault record.
PLC_FT$ A structure definition of the PLC fault table records.
PLCFA_RACK$ A structure definition of the PLC fault address field of the PLC fault record.
These structures are predefined in READ_FLT.PGM. Any field of these structures can be accessed by name; for example:
IO_FLT_RECS$(I%*42:42).IO_FLT_ADD$.IOFA_RACK$
Other examples can be found in PRN_FLT.PGM and TEST_FLT.PGM. PRN_FLT.PGM shows the use of the structures defined in READ_FLT.PGM. Refer to a listing of PRN_FLT.PGM for examples of the use of these structures. TEST_FLT.PGM provides an example of the use of READ_FLT.PGM and PRN_FLT.PGM.