[En-Nut-Discussion] Problem: read uart port

Ole Reinhardt ole.reinhardt at embedded-it.de
Thu Mar 19 21:06:00 CET 2009


Hi,

> int got;
> static char inbuf[58];
> got = _read(_fileno(uart), inbuf, 58);

Just write the code like this:

int got
int offset = 0;
static char inbuf[58];

do {
   got = _read(_fileno(uart), inbuf + offset, 58 - offset);
   if (got >= 0) offset += got;
} while ((got >= 0) && (offset < 58));

Bye,

Ole


-- 
 _____________________________________________________________
|                                                             |
| Embedded-IT          Hard- und Softwarelösungen             |
|                                                             |
| Ole Reinhardt        Tel. / Fax:        +49 (0)271  7420433 |
| Luisenstraße 29      Mobil:             +49 (0)177  7420433 |
| 57076 Siegen         eMail:    ole.reinhardt at embedded-it.de |
| Germany              Web:         http://www.embedded-it.de |
|                      UstID / VAT:       DE198944716         |
|_____________________________________________________________|




More information about the En-Nut-Discussion mailing list