Return to previous page Return to menu Go to next page

(3) Transfer function settings

When transferring the data of stream B to read_buf using the function “decodeFunc” in program (1), change as follows.

(a) Change STM_SetTrBuf in the dotted line part to STM_SetTrFunc.

STM_SetTrFunc(b_stm, decodeFunc, read_buf);

This causes decodeFunc to be invoked each time the server function STM_ExecServer tries to transfer stream B data.

(b) “decodeFunc” is as follows.

Uint8 read_buf [READBUF_SIZE];

 Sint32 decodeFunc (void * obj, StmHn stm, Sint32 nsct) 
{
Sint32 i;
Sint32 read_len; / * Number of longwords transferred by subFunc
Sint32 nlongword; / * Number of transfer long words
Uint32 * src; / * Source address
Sint32 dadr; / * Address / change for each longword transfer
Uint32 * buffer; / * Transfer area



* /
* /
* /
* /
* /
/ * Conversion from number of sectors to number of words (called before transfer starts)
nlongword = STM_SctToWord (stm, nsct) / 2;
* /
 src = STM_StartTrans (stm, & dadr); / * Start transfer 
* /
 buffer = (Uint8 *) obj; / * The third argument of STM_SetTrFunc is passed to obj 
* /
 for (i = 0; i  / * Function that returns the number of expanded bytes 
buffer + = subFunc (src, dadr, buffer, & read_len) ;
src + = read_len * dadr;
}
return (nsct); / * returns the number of transferred sectors
}

* /



* /

 (c) Must be transferred in units of sectors.
(d) If data transfer has not been completed when decodeFunc ends, (-1) must be returned.
In this case, other streams cannot be transferred until the data transfer is completed. Once you ’ve transferred the data,
Returns the number of transferred sectors. During this time, do not call STM_StartTrans. 


Return to previous page Return to menu Go to next page