Add option to use C buffered I/O in examples/serloop
git-svn-id: svn://svn.code.sf.net/p/nuttx/code/trunk@1274 42af7a65-404d-4744-a932-0658087f49c3
This commit is contained in:
parent
17edec8443
commit
f74a19b9fd
@ -120,7 +120,12 @@ examples/serloop
|
||||
^^^^^^^^^^^^^^^^
|
||||
|
||||
This is a mindlessly simple loopback test on the console. Useful
|
||||
for testing new serial drivers.
|
||||
for testing new serial drivers. Configuration options include:
|
||||
|
||||
* CONFIG_EXAMPLES_SERLOOP_BUFIO
|
||||
Use C buffered I/O (getchar/putchar) vs. raw console I/O
|
||||
(read/read). The behavior of the NuttX getchar() call is
|
||||
very hostile unless you also set CONFIG_STDIO_BUFFER_SIZE=0.
|
||||
|
||||
examples/udp
|
||||
^^^^^^^^^^^^
|
||||
|
@ -38,6 +38,8 @@
|
||||
****************************************************************************/
|
||||
|
||||
#include <nuttx/config.h>
|
||||
|
||||
#include <stdio.h>
|
||||
#include <unistd.h>
|
||||
|
||||
/****************************************************************************
|
||||
@ -71,6 +73,23 @@ void user_initialize(void)
|
||||
|
||||
int user_start(int argc, char *argv[])
|
||||
{
|
||||
#ifdef CONFIG_EXAMPLES_SERLOOP_BUFIO
|
||||
int ch;
|
||||
|
||||
for (;;)
|
||||
{
|
||||
ch = getchar();
|
||||
if (ch < 1)
|
||||
{
|
||||
ch = '!';
|
||||
}
|
||||
else if ((ch < 0x20 || ch > 0x7e) && ch != '\n')
|
||||
{
|
||||
ch = '.';
|
||||
}
|
||||
putchar(ch);
|
||||
}
|
||||
#else
|
||||
ubyte ch;
|
||||
int ret;
|
||||
|
||||
@ -81,12 +100,13 @@ int user_start(int argc, char *argv[])
|
||||
{
|
||||
ch = '!';
|
||||
}
|
||||
else if (ch < 0x20 || ch > 0x7e)
|
||||
else if ((ch < 0x20 || ch > 0x7e) && ch != '\n')
|
||||
{
|
||||
ch = '.';
|
||||
}
|
||||
ret = write(1, &ch, 1);
|
||||
}
|
||||
#endif
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user