Changeset 7cfd6d4


Ignore:
Timestamp:
Mar 19, 2019, 4:07:13 PM (3 years ago)
Author:
Peter A. Buhr <pabuhr@…>
Branches:
arm-eh, cleanup-dtors, jacob/cs343-translation, jenkins-sandbox, master, new-ast, new-ast-unique-expr
Children:
81a05ca
Parents:
2e041e27
Message:

illustrate coroutine refactoring

File:
1 edited

Legend:

Unmodified
Added
Removed
  • tests/coroutine/devicedriver.cfa

    r2e041e27 r7cfd6d4  
    1010// Created On       : Sat Mar 16 15:30:34 2019
    1111// Last Modified By : Peter A. Buhr
    12 // Last Modified On : Mon Mar 18 08:29:20 2019
    13 // Update Count     : 79
     12// Last Modified On : Tue Mar 19 15:59:06 2019
     13// Update Count     : 87
    1414//
    1515
     
    2828} // next
    2929
     30void checkCRC( Driver & d, unsigned int sum ) with( d ) {
     31        suspend();
     32        unsigned short int crc = byte << 8;                                     // sign extension over written
     33        suspend();
     34        // prevent sign extension for signed char
     35        status = (crc | (unsigned char)byte) == sum ? MSG : ECRC;
     36} // checkCRC
     37
    3038void main( Driver & d ) with( d ) {
    3139        enum { STX = '\002', ESC = '\033', ETX = '\003', MaxMsg = 64 };
    32         unsigned short int crc;                                                         // error checking
    3340  msg: for () {                                                                                 // parse message
    3441                status = CONT;
     
    5259                } // for
    5360                msg[lnth] = '\0';                                                               // terminate string
    54                 suspend();
    55                 crc = (unsigned char)byte << 8; // prevent sign extension for signed char
    56                 suspend();
    57                 status = (crc | (unsigned char)byte) == sum ? MSG : ECRC;
     61                checkCRC( d, sum );                                                             // refactor CRC check
    5862                suspend();
    5963        } // for
Note: See TracChangeset for help on using the changeset viewer.