- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
tests/coroutine/devicedriver.cfa
r427854b re7fdd76 1 // 1 // 2 2 // Cforall Version 1.0.0 Copyright (C) 2017 University of Waterloo 3 3 // 4 4 // The contents of this file are covered under the licence agreement in the 5 5 // file "LICENCE" distributed with Cforall. 6 // 7 // devicedriver.cfa -- 8 // 6 // 7 // devicedriver.cfa -- 8 // 9 9 // Author : Peter A. Buhr 10 10 // Created On : Sat Mar 16 15:30:34 2019 … … 12 12 // Last Modified On : Sat Apr 20 09:07:19 2019 13 13 // Update Count : 90 14 // 14 // 15 15 16 16 #include <fstream.hfa> … … 29 29 30 30 void checkCRC( Driver & d, unsigned int sum ) with( d ) { 31 suspend ;31 suspend(); 32 32 unsigned short int crc = byte << 8; // sign extension over written 33 suspend ;33 suspend(); 34 34 // prevent sign extension for signed char 35 35 status = (crc | (unsigned char)byte) == sum ? MSG : ECRC; … … 41 41 status = CONT; 42 42 unsigned int lnth = 0, sum = 0; 43 while ( byte != STX ) suspend ;43 while ( byte != STX ) suspend(); 44 44 emsg: for () { 45 suspend ;45 suspend(); 46 46 choose ( byte ) { // process byte 47 47 case STX: 48 status = ESTX; suspend ; continue msg;48 status = ESTX; suspend(); continue msg; 49 49 case ETX: 50 50 break emsg; 51 51 case ESC: 52 suspend ;52 suspend(); 53 53 } // choose 54 54 if ( lnth >= MaxMsg ) { // buffer full ? 55 status = ELNTH; suspend ; continue msg;55 status = ELNTH; suspend(); continue msg; 56 56 } // if 57 57 msg[lnth++] = byte; … … 60 60 msg[lnth] = '\0'; // terminate string 61 61 checkCRC( d, sum ); // refactor CRC check 62 suspend ;62 suspend(); 63 63 } // for 64 64 } // main
Note: See TracChangeset
for help on using the changeset viewer.