Copyright 2014 Craig Scratchley (March 25), craig_scratchley AT alumni.sfu.ca
Receiver StateChart for XMODEM file-transfer protocol.
Real events are either
SER (serial character recieved),
KB_C (cancel command received from keyboard) TM (timeout occurred)
The WorkaroundTransient states were introduced to work around a bug in the current version of the SmartState program. Without these WorkaroundTransient states, the triggering of the
applicable transitions would not result in the StateChart
ending up in the FirstByte state. Instead, the StateChart would stay in exactly the same state. The transition that sets ctx.KbCan to true exploits this bug. Here, we want the StateChart to return to exactly the same state after the transition that it had been in before the transition.
CompleteReceiverTopLevel
[Entry]
if (ctx.useCrc) {ctx.NCGbyte=C; ctx.tmSoh = TM_SOH_C;}
else {ctx.NCGbyte=NAK; ctx.tmSoh = TM_SOH;} /*ctx.purge();*/ctx.sendByte(ctx.NCGbyte); ctx.errCnt=0; ctx.KbCan=false; [Exit]
Ordinarily
TM_SOH (normal timeout waiting for SOH) gives 10 seconds TM_SOH_C (timeout waiting for SOH after C) gives 3 seconds TM_2CHAR gives a period longer than the
inter-character timeout of 1 sec.
WorkaroundTransient1
onEvent(TM) [ctx.errCnt < errB & !ctx.KbCan]/if (ctx.NCGbyte==’C’ & ctx.errCnt == 3) {ctx.NCGbyte=NAK; ctx.tmSoh=TM_SOH; ctx.useCrc=false;}ctx.sendByte(ctx.NCGbyte); ctx.errCnt++;WorkaroundTransient2 onEvent(CONT) [Entry]POST(“*”, CONT);[Exit][Entry] ctx.tm(ctx.tmSoh); [Exit]KBcancelable onEvent(CONT) [Entry]POST(“*”, CONT);[Entry] [Exit]BETWEEN onEvent(SER) CAN[Exit]onEvent(SER) [!ctx.KbCan & c!=SOH] /ctx.purge(); [c==CAN][Entry] ctx.tmPush(TM_2CHAR); [Exit]ctx.tmPop();SERcancelable onEvent(TM)onEvent(SER)[c==CAN]/ctx.clearCan(); ctx.result=”SndCancelled”;onEvent(SER) [c==EOT] /ctx.sendByte(ACK); ctx.result=”Done”;onEvent(SER) [ctx.KbCan] /ctx.purge(); ctx.can8(); ctx.result=”KbCancelled (delayed)”;onEvent(TM)[ctx.errCnt>=errB || ctx.KbCan] /ctx.can8();
if (ctx.KbCan)
ctx.result=KbCancelled; else
ctx.result=ExcessiveErrors;
[Entry]
[Exit] FirstByte
[Entry] [Exit]
onEvent(SER)
[!ctx.KbCan & c==EOT] /ctx.purge();ctx.sendByte(NAK); [Entry] ctx.errCnt++;ctx.tm(TM_SOH); [Exit] ctx.NCGbyte=NAK;
onEvent(KB_C) /ctx.KbCan=true; /* use history */
EOT
onEvent(TM)
[!ctx.syncLoss & (ctx.errCnt <= errB)] /if (ctx.goodBlk) ctx.sendByte(ACK); else ctx.sendByte(NAK); ctx.NCGbyte=NAK; ctx.tmSoh=TM_SOH; if (ctx.goodBlk1st)onEvent(SER) [!ctx.KbCan & c==SOH] /ctx.getRestBlk();if (!ctx.goodBlk1st)ctx.errCnt++; else ctx.errCnt=0;onEvent(SER)[c!=EOT & ctx.errCnt>=errB] /ctx.purge(); ctx.can8(); ctx.result=Error from EOT;
ctx.writeChunk();
TimeoutTransient
[Entry] ctx.tm(0); [Exit]
onEvent(SER) /ctx.purge();
onEvent(TM)
[ctx.syncLoss || ctx.errCnt > errB] /ctx.can8();
if (ctx.syncLoss)
ctx.result=LossOfSyncronization; else
ctx.result=ExcessiveErrors;
onEvent(KB_C)
/ctx.can8();
ctx.result=kbCancelled (immediate);
Programming
[SOLVED] Copyright 2014 Craig Scratchley (March 25), craig_scratchley AT alumni.sfu.ca
$25
File Name: Copyright_2014_Craig_Scratchley_(March_25),_craig_scratchley_AT_alumni.sfu.ca.zip
File Size: 725.34 KB
Only logged in customers who have purchased this product may leave a review.
Reviews
There are no reviews yet.