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

SPI Programming Examples
SPI Programming Manual427506-006
E-48
Example E-11: A Simple SPI Server in TAL
IF <> THEN !error handling
BEGIN
IF > THEN
BEGIN
CALL fileinfo (rcv^file^num, l^err);
IF l^err > 0 THEN
BEGIN
CALL debug;
continue := false;
END;
END ELSE
BEGIN
CALL debug;
continue := false;
END;
END;
END; !initialization
?PAGE "PROC process^spi^buffer"
PROC process^spi^buffer;
!==========================================================================!
! Proc : process^spi^buffer !
! Function : This procedure will format responses for successful !
! processing of spi^command. !
!==========================================================================!
BEGIN
INT
l^err,
l^idx,
l^len,
l^start^idx;
! determine if this is a valid SPI message
IF (l^err := verify^msg (spi^buffer^size)) THEN
BEGIN
CALL error^response (l^err);
RETURN;
END;
! get the spi^command from the request buffer!
IF (err := ssgettkn (req^buffer, zspi^tkn^command, spi^command)) THEN
BEGIN
CALL display^spi^error (err, zspi^val^ssgettkn,
zspi^tkn^command, true);
END;
IF (l^err := validate^tokens) THEN ! This is a procedure call
BEGIN
CALL error^response (l^err);
RETURN;
END;
! Security checks on the command/user could be done here.
CALL build^hdr^response;
source^idx := 1;
dest^idx := 1;
tkn^count := 1;
Example E-11. TAL File: A Simple SPI Server (page 4 of 10)