Grr,

Yeah, in Nuttx, fgets, fgetc, etc. don't echo. Even in Linux, the echo is actually a function of the terminal, not the running program and 'fgets'.

In Nuittx, use the readline routine instead. But keep in mind that readline is only *inspired* by GNU readline and has different calling parameters (you also have to ensure it is enabled / configured in 'make menuconfig':

#include <system/readline.h>

my_get_command(struct spitest_s *spitest)
{
  char    input[80];
  ssize_t len = 0;

  while (len == 0)
   {
     printf("\nEnter Command:");
     fflush(stdout);

     len = readline(input, sizeof(input), stdin, stdout);
     if (len)
       {
         spitest->cmd = input[0];   /* First char is the command */
         ...
       }
    }
   ...
}

Ken

On 1/26/21 3:54 AM, Grr wrote:
Hello

That fflush is for fgets

Yes, with a stdout flush, message prints but the question remains about why
is it needed and how can I get input echo

Thanks

Grr

El lun, 25 ene 2021 a las 13:30, Ken Pettit (<petti...@gmail.com>) escribió:

Hey Grr,

You need the fflush(stdout) call to be *after* the printf("\nEnter
Command:").

If the printf doesn't end with \n, then the stdout won't be flushed.

Ken

On 1/25/21 11:25 AM, Grr wrote:
Hello to all

Is there a way to get stdout without a LF?

I have something like

case INPUT_CMD:
    fflush(stdin);
    printf("\nEnter Command:");
    fgets(input, INPUT_STRING, stdin);
    spitest.cmd = input[0];         /* First char is the command
*/
that in Linux prints message and waits for input but in Nuttx shows
nothing.
I don't want LF because that destroys the format I want for program
interface

Another related issue is I don't get echo from input

How do I get messages printed without a LF and echo from input?

TIA

Grr



Reply via email to