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

General SPI Programming Guidelines
SPI Programming Manual427506-006
5-45
Consistency Between Response Records in
Different Replies
then go to continue;
if MAXRESP > -1 then
if num-responses >= MAXRESP then go to continue;
if multiple-responses then
SSPUT(ZSPI-TKN-DATALIST); ! start response
SSPUT(subsys-TKN-xxxxx,object name);
processing-loop:
do some work;
SSGET(ZSPI-TKN-LASTPOSITION,remember-place); *
insert next token or error list into response;
if buffer is full then go to backout; *
if ZSPI-TKN-BUFLEN - ZSPI-TKN-USEDLEN < overflow-need *
then go to backout; *
if more to do then go to processing-loop;
go to response-done;
backout: *
SSPUT(ZSPI-TKN-POSITION,remember-place); *
SSGET(ZSPI-TKN-NEXTTOKEN,dummy); *
SSPUT(ZSPI-TKN-DATAFLUSH); *
SSPUT(ZSPI-TKN-ERRLIST); *
SSPUT(ZSPI-TKN-ERROR, overflow error number); *
SSPUT(subsys-TKN-xxxxx, object-name); *
SSPUT(ZSPI-TKN-ENDLIST); *
response-done:
SSPUT(ZSPI-TKN-RETCODE,current-retcode);
if multiple-responses then
SSPUT(ZSPI-TKN-ENDLIST);
num-responses := num-responses + 1;
go to next-obj-loop;
continue:
SSPUT(ZSPI-TKN-CONTEXT,context);
done:
send reply;
If the server needs to decide the number of response records that fit in a buffer before
starting to fill the buffer, the code must be a bit different, but the same idea applies.
The server would divide the buffer size by the maximum expected size for a response
record to get the number of response records that should fit. Then the test in the
processing loop would check to see whether the response record has run past its
allowed ending point in the buffer, by comparing ZSPI-TKN-USEDLEN to the response
number times the size allowed for each response.
Consistency Between Response Records in Different Replies
When information about various parts of an object is returned in different responses,
there is a potential for presenting an inconsistent picture of the object to the requester
because the object might change between commands. If you encounter a case where
this situation might be a problem (not all cases present a problem), you can:
Implement some form of locking. A problem with locking is knowing when to
release the lock if the requester fails to do so.