mirror of
https://github.com/apache/nuttx.git
synced 2026-06-08 01:42:58 +08:00
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:
+21
-1
@@ -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;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user