Changeset 8043
- Timestamp:
- 01/02/13 23:35:12 (11 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/csctapi/io_serial.c
r8038 r8043 370 370 371 371 rdr_debug_mask(reader, D_DEVICE,"Read timeout %d us, read delay %d us, to read %d char(s), chunksize %d char(s)", timeout, delay, size, size); 372 #if defined(__SH4__)373 int16_t readed = -1;374 struct timeval tv, tv_spent;375 #endif376 372 377 373 if (reader->crdr.read_written && reader->written > 0) { // these readers need to read all transmitted chars before they can receive! … … 385 381 } 386 382 387 while(count < size) 388 { 389 #if defined(__SH4__) 383 #if defined(__SH4__) //read char one by one for sh4 boxes 384 bool readed; 385 unsigned char c; 386 struct timeval tv, tv_spent; 387 for (count = 0; count < size ; count++){ 390 388 gettimeofday(&tv,0); 391 389 memcpy(&tv_spent,&tv,sizeof(struct timeval)); 392 390 393 while( (((tv_spent.tv_sec-tv.tv_sec)*1000000) + ((tv_spent.tv_usec-tv.tv_usec)/1000000L)) < (time_t)(timeout)) 394 { 395 readed =read(reader->handle, &data[count], size-count); 396 gettimeofday(&tv_spent,0); 391 while( (((tv_spent.tv_sec-tv.tv_sec)*1000000) + ((tv_spent.tv_usec-tv.tv_usec)/1000000L)) < (time_t)(timeout)){ 392 if (read (reader->handle, &c, 1) == 1){ 393 readed = 1; 394 break; 395 } 396 gettimeofday(&tv_spent,0); 397 397 } 398 398 if(!readed) { … … 400 400 return ERROR; 401 401 } 402 count +=readed; 403 #else 402 data[count] = c; 403 } 404 #else // read all chars at once for non sh boxes 405 while(count < size){ 404 406 int16_t readed = -1, errorcount=0; 405 407 AGAIN: … … 424 426 return ERROR; 425 427 } 426 427 #endif 428 } 428 count +=readed; 429 } 430 #endif 429 431 rdr_ddump_mask(reader, D_DEVICE, data, count, "Receiving:"); 430 432 return OK;
Note:
See TracChangeset
for help on using the changeset viewer.