From: Edward Jubenville Date: Fri, 18 Aug 2006 15:30:02 -0700 Subject: [U-Boot-Users] non-canonical input mode for standalone app In-Reply-To: <20060818195011.D6B06352627@atlas.denx.de> Message-ID: List-Id: MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit To: u-boot@lists.denx.de Wolfgang wrote: > Your message makes no sense. > > tstc() *never* returns any keycodes. It returns 1 if there was > any key pressed (without actually emptying the receive buffer). > What you probably might want is getc(), and this function returns > each and every key code without any processing. Sorry for the confusion. I tried to be too concise. Let me clarify. I'm using a customized MPC5200 IceCube configuration, and my testing shows that getc() blocks unless there is input pending, and tstc() will not return 1 until after an ENTER key has been hit. This doesn't fit too nicely into my application, which wants to perform background processing while waiting for single character operator input, as in a simple menuing system. A simplified version of my application looks something like this... done = 0; while(!done) { // perform a single pass of hardware testing here, then... // check for user input to quit or alter the test mode while (tstc()) { c = getc(); // handle input (e.g. 'Q' = quit, '?' to display help, etc.) if (c == 'Q') done = 1; else if (c == '?') ... display the help screen... else if (c == ANOTHER_OPTION_HERE) ... etc. } In past Linux applications that I've written, I've been able to implement code loops like this by first disabling canonical input on stdin (using tcgetattr/tcsetattr to modify flag ICANON), then turning off blocking and buffering on stdin. After those steps, getchar() will return -1 if no input is pending. How can I make tstc() return 1 as soon as any key is hit? If such a capability existed, u-boot commands "loop", "iloop", and "loopw" could benefit, giving the operator an exit path without a reset. Ed Jubenville