[En-Nut-Discussion] Problem: read uart port
Ole Reinhardt
ole.reinhardt at embedded-it.de
Fri Mar 20 00:08:51 CET 2009
Hi,
> > do {
> > got = _read(_fileno(uart), inbuf + offset, 58 - offset);
> > if (got >= 0) offset += got;
> > } while ((got >= 0) && (offset < 58));
>
> This will make a 100% busy loop that eats a lot of CPU power. Is that
> possible in Nut/OS to use select function to sleep between reads? Or
> maybe _read function works in blocking mode and select is not necessary?
NutOS does not support select or poll, but you might set a read timeout
(via ioctl).
The above function does not eat any cpu time at all, if there is no data
arriving, as read (as all other I/O functions as well) is implemented
using NutOS event handling. So the scheduler will give the cpu to
another thread ready to run if there is no data pending.
Regards,
Ole Reinhardt
--
_____________________________________________________________
| |
| 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