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

The SPI Procedures
SPI Programming Manual427506-006
3-28
Example: Moving Buffer Tokens Using SSMOVETKN
/*
* Initialize the SPI buffer "b2"
*/
if (err = SSINIT (b2, bufsize, (short *) &ssid, ZSPI_VAL_CMDHDR))
display_spi_error (err, ZSPI_VAL_SSINIT, 0L, true);
/*
* Reset the SPI buffer "b1"
*/
if (err = SSPUTTKN (b1, 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 "b1"
*/
get_count = 1;
/*
* Note that the following code doesn’t work as expected. This is
* because SSMOVETKN will move an entire list if positioned on a
* list and GET(NEXTTOKEN) will enter the list. So
* B1 = ["A","B","C","D"]
* B2 = ["A","B","C","D"],"A","B","C","D" and you will get an
* error -8 (Missing Tkn) when you try to move the last ENDLIST from
* B1 to B2. This is returned because there is no matching DATALIST,etc.
*/
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_ENDLIST)
{
printf ("At end of loop: TKN_CODE should = ENDLIST, \n");
printf ("B2: \n");
dump_buf (b2);
}
if (err != ZSPI_ERR_MISTKN)
{
printf ("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);
}
Example 3-1. Moving Buffer Tokens Using SSMOVETKN (page 2 of 7)