[En-Nut-Discussion] unblocking get char

Ole Reinhardt ole.reinhardt at embedded-it.de
Thu Oct 11 09:49:13 CEST 2012


Hi Ayman,

> I need to add a function that not locking until the user input char through
> standard input, by another meaning  using getchar(); function will lock the
> thread until the user enter a char, I need the opposite that if the user
> was keep pressing a certain char, it will get that char if not, the
> execution will keep running without any blocking.

Please read http://www.ethernut.de/nutwiki/Advanced_UART_Functions,
especially the chapter about read timeouts.

You can set a timeout until which the read functions (and getchar is
only one of them) will return an error code instead of the char. 

Btw: Nut/OS uses more or less the same behaviour like other POSIX c-lib
implementations.

Bye,

Ole

-- 

Thermotemp GmbH, Embedded-IT

Embedded Hard-/ Software and Open Source Development, 
Integration and Consulting

http://www.embedded-it.de

Geschäftsstelle Siegen - Steinstraße 67 - D-57072 Siegen - 
tel +49 (0)271 5513597, +49 (0)271-73681 - fax +49 (0)271 736 97

Hauptsitz - Hademarscher Weg 7 - 13503 Berlin
Tel +49 (0)30 4315205 - Fax +49 (0)30 43665002
Geschäftsführer: Jörg Friedrichs, Ole Reinhardt
Handelsregister Berlin Charlottenburg HRB 45978 UstID DE 156329280 




More information about the En-Nut-Discussion mailing list