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

The SPI Procedures
SPI Programming Manual427506-006
3-32
Example: Moving Buffer Tokens Using SSMOVETKN
/*
* Get the tokens in the SPI buffer "b1"
*/
get_count = 1;
/*
* Note that the following code moves all the nonheader tokens from
* B1 to B2.
* B1 = ["A","B","C","D"]
* B2 = ["A","B","C","D"]
*/
while (!err)
{
if (err = SSGETTKN (b1, ZSPI_TKN_NEXTTOKEN, (char *) &tkn_code,
0, &get_count, (short *) &mySsid))
continue;
else
err = SSMOVETKN (tkn_code, b1, ZERO,
b2, ZERO,, &mySsid);
if (tkn_code == ZSPI_TKN_DATALIST
|| tkn_code == ZSPI_TKN_ERRLIST
|| tkn_code == ZSPI_TKN_SEGLIST)
{
/* The SSMOVETKN call moved the entire list. Go to the ENDLIST
and then continue on with the GET (NEXTTOKEN) loop */
err = SSGETTKN (b1, ZSPI_TKN_ENDLIST, (char *) &tkn_code,
0, &get_count, (short *) &mySsid);
}
}
if (tkn_code != ZSPI_TKN_DATALIST)
{
printf ("At end of loop2: TKN_CODE should = DATALIST, \n");
printf ("B2: \n");
dump_buf (b2);
if (err != ZSPI_ERR_MISTKN)
{
printf ("At end of loop2: ERROR should = -8, was %d \n", err);
printf ("B2: \n");
dump_buf (b2);
}
/*
* Reset the SPI buffer "b2"
*/
if (err = SSPUTTKN (b2, ZSPI_TKN_RESET_BUFFER, (char *) &bufsize))
{
display_spi_error (err, ZSPI_VAL_SSPUTTKN,
ZSPI_TKN_RESET_BUFFER, true);
}
/*
* Get the tokens in the SPI buffer "b2"
*/
get_count = 1;
Example 3-1. Moving Buffer Tokens Using SSMOVETKN (page 6 of 7)