星期四, 4月 29, 2004

Solution for Rms replyi..

Q uestion:
Current Smart's argorithm use many RAM (1 var needs another 2 spaces to store the bcd).
but this argothm seems use less ROM, it use array to store the reply sequence.

R equirement:
When sending RMS reply data out, cannot blok the other job. so program is only allowed to
send one byte out in one "loop".

S olution:
Use txqueue to queue the output data, and Tx interrupt driven output (a basic method for output).

Rms module:

if( qIsEmpty() )
. needSpace=0;
. if( (seq+=elemlen)>hasBeenSent) ) {
. if( (needSpace+=elemlen) < qSpace() ) {
. .... sendOutThisElement......
. hasBeenSent+=elemlen;
. }else{
. goto _exit;
. }
. }else{
. goto _exit;
. }
}



needSpace : local
.....the data has been added to queueu in this time.
seq : local
.....the data sequence number of this "elememt"
hasBeenSent : static
......the data sequence number has been sent.
elemlen : const , property
,......the data length of this "element"


沒有留言:

網誌存檔