Changeset 93c86ac
- Timestamp:
- Jun 17, 2023, 1:26:32 PM (17 months ago)
- Branches:
- master
- Children:
- c8f0199
- Parents:
- dc9dd94
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
tests/coroutine/devicedriver.cfa
rdc9dd94 r93c86ac 10 10 // Created On : Sat Mar 16 15:30:34 2019 11 11 // Last Modified By : Peter A. Buhr 12 // Last Modified On : Sat Apr 20 09:07:19 201913 // Update Count : 9 012 // Last Modified On : Sat Jun 17 09:11:56 2023 13 // Update Count : 94 14 14 // 15 15 … … 18 18 19 19 enum Status { CONT, MSG, ESTX, ELNTH, ECRC }; 20 20 21 coroutine Driver { 21 22 Status status; … … 23 24 }; // Driver 24 25 25 void ?{}( Driver & d, char * m ) { d.msg = m; } 26 Status next( Driver & d, char b ) with( d ) { 27 byte = b; resume( d ); return status; 26 void ?{}( Driver & d, char * m ) { d.msg = m; } // constructor 27 28 Status next( Driver & d, char b ) with( d ) { // called by interrupt handler 29 byte = b; resume( d ); return status; // resume coroutine at last suspend 28 30 } // next 29 31 … … 73 75 if ( eof( sin ) ) break eof; // eof ? 74 76 choose( next( driver, byte ) ) { // analyse character 75 case MSG: 76 sout | "msg:" | msg; 77 case ESTX: 78 sout | "STX in message"; 79 case ELNTH: 80 sout | "message too long"; 81 case ECRC: 82 sout | "CRC failure"; 83 default: ; 77 case CONT: ; 78 case MSG: sout | "msg:" | msg; 79 case ESTX: sout | "STX in message"; 80 case ELNTH: sout | "message too long"; 81 case ECRC: sout | "CRC failure"; 84 82 } // choose 85 83 } // for … … 87 85 88 86 // Local Variables: // 89 // tab-width: 4 //90 87 // compile-command: "cfa -g -Wall -Wextra devicedriver.cfa" // 91 88 // End: //
Note: See TracChangeset
for help on using the changeset viewer.