[En-Nut-Discussion] unblocking get char

Uwe Bonnes bon at elektron.ikp.physik.tu-darmstadt.de
Thu Oct 11 11:00:53 CEST 2012

>>>>> "Ole" == Ole Reinhardt <ole.reinhardt at embedded-it.de> writes:

    Ole> 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.

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

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

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

But timeout is in Milliseconds. And '0' means infinite wait. So you have to
specify at least '1' . And that can mean a blocking behaviour for up to 1
Millisecond. Does perhaps have 0xffffffff ('-1') have another special
meaning, as to _not_ wait at all. Would that be usefull?

Uwe Bonnes                bon at elektron.ikp.physik.tu-darmstadt.de

Institut fuer Kernphysik  Schlossgartenstrasse 9  64289 Darmstadt
--------- Tel. 06151 162516 -------- Fax. 06151 164321 ----------

More information about the En-Nut-Discussion mailing list