OSI/MHS Management Programming Manual
Examples
OSI/MHS Management Programming Manual—424824-001
C-12
SPI Example in TAL
-------------------------------------------------------------
PROC Init^Cmd^Buffer ( Cmd, ObjType );
INT Cmd;
INT ObjType;
BEGIN
INT MaxResp;
SSErr := SSInit ( Spi^Buffer,
zMHS^Val^BufLen,
MHS^Val^SSID,
zSpi^Val^CmdHdr,
Cmd,
ObjType );
IF (SSErr <> zSpi^Err^OK) THEN
BEGIN
Write^Term^With^Num ( "SSInit failed", SSErr );
CALL Abend;
END;
--
-- Set the zSpi^Tkn^MaxResp token value to -1 to indicate that
-- we want as many response records per SPI response as will
-- fit in the buffer.
--
MaxResp := -1;
SSErr := SSPutTkn( Spi^Buffer,
zSpi^Tkn^MaxResp,
MaxResp );
IF (SSErr <> zSpi^Err^OK) THEN
BEGIN
Write^Term^With^Num ( "SSPutTkn failed", SSErr );
CALL Abend;
END;
END; -- PROC Init^Cmd^Buffer
? PAGE "Reset pointer to Initial position in SPI Buffer"
-------------------------------------------------------------
--
-- RESET^SPIBUF - Reset to initial position in SPI buffer.
--
-- GLOBALS. Spi^Buffer . Buffer to reset
-- SSErr . Set in this procedure
-- INPUT. None
-- OUTPUT. None
--
-------------------------------------------------------------
PROC Reset^SpiBuf;
BEGIN
INT Init^Buffer;
--
-- Reset SPI buffer length to the length of our buffer
-- and set position at beginning of buffer.
--
--
-- The buffer length is the second word in the SPI buffer.
--
Spi^Buffer [1] := $MIN ( Spi^Buffer [1],
zMHS^Val^BufLen );