Changeset 8028
- Timestamp:
- 01/01/13 20:01:12 (11 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/csctapi/io_serial.c
r8020 r8028 362 362 bool IO_Serial_Read (struct s_reader * reader, uint32_t delay, uint32_t timeout, uint32_t size, unsigned char * data) 363 363 { 364 unsigned char c;365 364 uint32_t count = 0; 366 365 … … 370 369 } 371 370 372 rdr_debug_mask(reader, D_DEVICE,"Read timeout %d us, read delay %d us, to read %d char(s), chunksize 1 char(s)", timeout, delay, size);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); 373 372 #if defined(__SH4__) 374 373 bool readed; … … 386 385 } 387 386 388 for (count = 0; count < size ; count++)387 while(count < size) 389 388 { 390 389 #if defined(__SH4__) 391 390 gettimeofday(&tv,0); 392 391 memcpy(&tv_spent,&tv,sizeof(struct timeval)); 393 readed=0;392 394 393 while( (((tv_spent.tv_sec-tv.tv_sec)*1000000) + ((tv_spent.tv_usec-tv.tv_usec)/1000000L)) < (time_t)(timeout)) 395 394 { 396 if (read (reader->handle, &c, 1) == 1) 397 { 398 readed = 1; 399 break; 400 } 395 readed =read(reader->handle, &data[count], size-count) 401 396 gettimeofday(&tv_spent,0); 402 397 } … … 405 400 return ERROR; 406 401 } 402 count +=readed; 407 403 #else 408 404 int16_t readed = -1, errorcount=0; … … 414 410 415 411 while (readed <0 && errorcount < 10) { 416 readed = read (reader->handle, & c, 1);412 readed = read (reader->handle, &data[count], size-count); 417 413 if (readed < 0) { 418 414 if (errno == EINTR) continue; // try again in case of interrupt … … 428 424 return ERROR; 429 425 } 430 #endif 431 data[count] = c; 426 count +=readed; 427 #endif 432 428 } 433 429 rdr_ddump_mask(reader, D_DEVICE, data, count, "Receiving:");
Note:
See TracChangeset
for help on using the changeset viewer.