[riot-devel] shell and putchar

Gaëtan Harter gaetan.harter at fu-berlin.de
Wed Oct 17 17:13:14 CEST 2018


Hi Neil,

digging through old unread emails

Answering inline.


On 7/6/18 4:58 PM, Neil Jones wrote:
> Hi all,
> 
> I'm working on improving IRQ support on PIC32 and I'm testing UART Rx using
> the shell.
> 
> The shell uses putchar, but putchar is buffered and needs a flush, thus
> when typing at the console I get no feedback until I press enter (the line
> feed gets echo'd and then we get the flush).
> 
> I'm surprised other newlib implementations don't see this ?


I think most developers have their local program doing the 'echo' for 
them and only sending lines by lines anyway.
So I personally do not really pay attention to this. I did not even knew 
we were doing 'echo' by default…


> 
> A flush is probably needed here:
> 
> #if !defined(SHELL_NO_ECHO) || !defined(SHELL_NO_PROMPT)
> #ifdef MODULE_NEWLIB
> /* use local copy of putchar, as it seems to be inlined,
>   * enlarging code by 50% */
> static void _putchar(int c) {
>      putchar(c);
>      fflush(STDOUT)   <------- HERE
> 
> }
> #else
> #define _putchar putchar
> #endif
> #endif
> 


I agree it could make sense to add it when in `echo` mode only.

     putchar(c)
#ifndef SHELL_NO_ECHO
     fflush(stdout);
#endif


As for the shell prompt it is already handled here 
https://github.com/RIOT-OS/RIOT/blob/master/sys/shell/shell.c#L273-L280


> I'm happy to do a PR for this, but this is very core functionality, I don't
> want to break anything ??

But maybe other developers have more knowledge about this.

Cheers,
Gaëtan


> 
> Cheers,
> 
> Neil
> 
> 
> _______________________________________________
> devel mailing list
> devel at riot-os.org
> https://lists.riot-os.org/mailman/listinfo/devel
> 


More information about the devel mailing list