SPI Programming Manual (H06.24+, J06.13+)
General SPI Programming Guidelines
SPI Programming Manual—427506-007
5-32
Checking Tokens in the Command
Checking Tokens in the Command
Your subsystem should report missing required tokens, and should detect and report
any extraneous tokens (including too many occurrences of valid tokens).
This pseudocode example illustrates one way to approach these tasks. It shows the
code to check a buffer for a specific command. It is assumed that there is a section of
code like this for each command:
int count[min^tnm:max^tnm]
struct token(ZSPI^DDL^TOKENCODE^DEF)
struct ssid(ZSPI^DDL^SSID^DEF)
int byte^len
for each token number do
count [token number] := 0
end do
! Scan the buffer, checking that we recognize each token,
! counting the occurrences, and retrieving the values.
SSPUT(buf,ZSPI^TKN^INITIAL^POSITION,0) ! position to
! start of buffer
do until end of buffer
SSGET(buf,ZSPI^TKN^NEXTTOKEN,token,,,ssid)
if SSGET error then
begin
ssgeterr(ZSPI^TKN^NEXTTOKEN,0,SSGET status)
go to send^reply
end
if ssid <> subsys^VAL^SSID then
begin
reject(token,1,subsys^ERR^IMPROPER^TOKEN,ssid)
go to send^reply
end
case token.z^tkn.z^number of
subsys^TNM^TOKEN1 -> ! simple token
if token.z^tkncode <> subsys^TKN^TOKEN1 then
begin
reject(token,1,subsys^ERR^IMPROPER^TOKEN)
go to send^reply
end
count[subsys^TNM^TOKEN1] :=
count[subsys^TNM^TOKEN1] + 1
if count[subsys^TNM^TOKEN1] > limit^for^token1 then
begin
reject(token,count[subsys^TNM^TOKEN1],
subsys^ERR^TOO^MANY^OCCURENCES)
go to send^reply
end
! For simple, variable-length tokens, a check of










